String vname, XFTextInputAttributes inputAttributes )
throws JspTagException, IOException
{
HttpSession session = pageContext.getSession();
HiddenFieldsSessionMap sessionMap = (HiddenFieldsSessionMap)session.getAttribute("_HIDDENATGFIELDS");
XMLWriter writer = new XMLWriter(pageContext.getOut());
try {
// Type attribute is optional. If not present, it defaults to text
if (inputAttributes.getType()==null)
{
inputAttributes.setType("text");
}
// Submit button... we need an XFAction instead of an XFInput
if( ( inputAttributes.getType().equals( "submit" ) ) || ( inputAttributes.getType().equals( "reset" ) ) )
{
XFActionAttributes actionAttributes = new XFActionAttributes();
actionAttributes.setType( inputAttributes.getType() );
actionAttributes.setStyleClass( inputAttributes.getStyleClass() );
actionAttributes.setShortcut( inputAttributes.getShortcut() );
actionAttributes.setCaption( inputAttributes.getCaption() );
actionAttributes.setName( "i_" + vname );
actionAttributes.setHelp( inputAttributes.getHelp() );
actionAttributes.setPrompt( inputAttributes.getPrompt() );
actionAttributes.setActive( "true" );
actionAttributes.setCaptionPane( inputAttributes.getCaptionPane() );
actionAttributes.setEntryPane( inputAttributes.getEntryPane() );
writer.openElement(actionAttributes);
writer.closeElement(actionAttributes);
if (logger.isDebugEnabled()) {
logger.debug ( "Submit input. For group "+ getFormName(pageContext)+" setting attribute _V" + vname + " to " + inputAttributes.getName() );
}
sessionMap.setAttribute(getFormName(pageContext), "_V"+vname, inputAttributes.getName());
// Deal with IE and image submit buttons.
// IE sends i_button.x=anInt&i_button.y=anInt
// Mozilla: i_button.x=anInt&i_button.y=anInt&i_button=valueOfCaptionAttribute
// So we store a hashtable containing the name and the value of the caption
sessionMap.setButton(getFormName(pageContext), "i_"+vname, inputAttributes.getCaption());
} else {
if( inputAttributes.getType().equals( "hidden" ) == false )
{
if (logger.isDebugEnabled()) {
logger.debug ( "Visible input. For group "+getFormName(pageContext)+ " setting attribute _V" + vname + " to " + inputAttributes.getName() );
}
sessionMap.setAttribute(getFormName(pageContext), "_V"+vname, inputAttributes.getName());
inputAttributes.setName( "i_" + vname );
writer.openElement(inputAttributes);
writer.closeElement(inputAttributes);
} else {
if( ( vname != null ) && (vname.length() > 0 ) )
{
if( inputAttributes.getName().startsWith( "_D" ) )
{
// _DARGS is a special case
if( inputAttributes.getName().equals( "_DARGS" ) )
{
if (logger.isDebugEnabled()) {
logger.debug ( "Hidden input. For group "+getFormName(pageContext)+" setting attribute " + vname + " to " + inputAttributes.getInitial() );
}
sessionMap.setAttribute(getFormName(pageContext), "_DARGS", inputAttributes.getInitial());
} else {
if (logger.isDebugEnabled()) {
logger.debug ( "Hidden input. For group "+getFormName(pageContext)+" setting attribute _D" + vname + " to " + inputAttributes.getName() );
}
sessionMap.setAttribute(getFormName(pageContext), "_D"+vname, inputAttributes.getName());
}
} else {
XFImplicitAttributes ia = new XFImplicitAttributes();
ia.setName( "i_" + vname );
ia.setValue( inputAttributes.getInitial() );
writer.openElement(ia);
writer.closeElement(ia);
if (logger.isDebugEnabled()) {
logger.debug ( "Hidden input. For group "+getFormName(pageContext)+" setting attribute _V" + vname + " to " + inputAttributes.getName() );
}
sessionMap.setAttribute(getFormName(pageContext), "_V"+vname, inputAttributes.getName());
}
} else {
if (logger.isDebugEnabled()) {
logger.debug ("hidden-input-undefined");
}
XFImplicitAttributes ia = new XFImplicitAttributes();
ia.setName( inputAttributes.getName() );
ia.setValue( inputAttributes.getInitial() );
writer.openElement(ia);
writer.closeElement(ia);
}
}
}
}