//-------------------------------------
public int doStartTag ()
throws JspException
{
DynamoHttpServletResponse response = null;
boolean oldStrictValue = false;
try {
//JspWriter out = mPageContext.getOut ();
// Get the enclosing form tag
DSPFormTag dspFormTag = getDSPFormTag ();
Properties inputAttrs = new Properties();
// Get the request and response
DynamoHttpServletRequest request =
Utils.getDynamoRequest (mPageContext.getRequest ());
response = request.getResponse();
// Turn off IllegalStateException for dspjsp pages
oldStrictValue = response.setStrictOutputAccess(false);
// See if this is a submit tag
boolean isSubmit =
(mTypeSpecified &&
mType != null &&
("submit".equals (mType) ||
"image".equals (mType)));
// utility booleans
boolean isCheckbox =
(mTypeSpecified &&
mType != null &&
"checkbox".equals (mType));
boolean isRadio =
(mTypeSpecified &&
mType != null &&
"radio".equals (mType));
// Resolve the bean name against the imports
mBean = ImportedBeans.resolveName (mBean, mPageContext);
// Compute the property name
PropertyName propertyName = PropertyName.createPropertyName (mBean);
// Compute the string name, which must be calculated specially
// if the bean is an array reference
String nameString =
(mBean.indexOf ('[') >= 0) ?
DropletDescriptor.evalDynamicDimensions (propertyName, request) :
mBean;
// See if that tag's name is overridden by an explicit "name"
String tagName =
mNameSpecified ?
mName :
nameString;
// Compute the converters
ConverterInfo converterInfo =
Utils.computeConverterInfo
(mConverter,
mConverterSpecified,
mFormat,
mFormatSpecified,
mDate,
mDateSpecified,
mNumber,
mNumberSpecified,
mCurrency,
mCurrencySpecified,
mRequired,
mRequiredSpecified,
mValueishtml,
mMindate,
mMindateSpecified,
mMaxdate,
mMaxdateSpecified,
mNullable,
mLocale,
mLocaleSpecified,
mSymbol,
mSymbolSpecified,
mEuro,
mEuroSpecified,
mCurrencyConversion,
mCurrencyConversionSpecified,
mGroupingsize,
mGroupingsizeSpecified);
TagConverter converter = null;
Properties converterArgs = null;
if (converterInfo != null) {
converter = converterInfo.getConverter ();
converterArgs = converterInfo.getConverterArgs ();
if (mMindateSpecified && mMindate != null) {
converterArgs.setProperty("mindate",mMindate);
}
if (mMaxdateSpecified && mMaxdate != null){
converterArgs.setProperty("maxdate",mMaxdate);
}
}
// Get the value as a String
String valueString;
if (mBeanvalueSpecified) {
if (mParamvalueSpecified || mValueSpecified) {
throw new JspException (Constants.INPUT_TAG_BAD_VALUEATTRIBUTES);
}
// Resolve the bean name against the imports
mBeanvalue = ImportedBeans.resolveName (mBeanvalue, mPageContext);
valueString =
DropletDescriptor.getPropertyStringValue
(request,
response,
mBeanvalue,
true,
null,
null);
}
else if (mParamvalueSpecified) {
if (mBeanvalueSpecified || mValueSpecified) {
throw new JspException (Constants.INPUT_TAG_BAD_VALUEATTRIBUTES);
}
Object paramvalue = request.getObjectParameter(mParamvalue);
if (null == paramvalue){
valueString = "";
}else{
if(null != converter){
valueString = converter.convertObjectToString(request,
paramvalue,
converterArgs);
}else{
valueString = paramvalue.toString();
}
}
}
else if (mValueSpecified) {
if (mBeanvalueSpecified || mParamvalueSpecified) {
throw new JspException (Constants.INPUT_TAG_BAD_VALUEATTRIBUTES);
}
if (null != converter &&
null != mValue &&
((String)mValue).trim().length() > 0){
Object obj = converter.convertStringToObject(request,
(String)mValue,
converterArgs);
valueString = converter.convertObjectToString(request,
obj,
converterArgs);
}else{
valueString = (mValue == null) ? "" : mValue.toString ();
}
}
else if (isSubmit &&
(mType.equals("image") ||
!DropletDescriptor.hasPropertyValue(request, propertyName)))
{
// We're trying to emulate the code in
// atg.servlet.pagecompile.InputSGMLTree
// that omits a value attribute for certain kinds of submit and all
// image tags.
valueString = null;
}
else if (isCheckbox &&
!mValueSpecified){
valueString = "true";
}
else {
valueString =
DropletDescriptor.getPropertyHtmlStringValue
(request,
response,
propertyName,
true,
converter,
converterArgs);
}
// Output the input tag
//out.print ("<input");
// Output the type
if (mTypeSpecified) {
inputAttrs.put("type",mType);
//out.print (" type=\"");
//out.print (mType);
//out.print ("\"");
}
// Output the name
inputAttrs.put("name",tagName);
//out.print (" name=\"");
//out.print (tagName);
//out.print ("\"");
// Output the value
if (valueString != null) {
inputAttrs.put("value",valueString);
//out.print (" value=\"");
// out.print (valueString);
//out.print ("\"");
}
// Output the "src"
if (mSrcSpecified) {
String encodedSrc = request.encodeURL ( mSrc,
true,
true,
true,
true);
inputAttrs.put("src",encodedSrc);
//out.print (" src=\"");
//out.print (encodedSrc);
//out.print ("\"");
}
//CHECKBOX -- See if the value should be "checked"
if (isCheckbox) {
boolean shouldCheck = false;
// See if "checked" was specified explicitly
if (mCheckedSpecified) {
shouldCheck = mChecked;
}
else { // or if value matches property value
shouldCheck =
DropletDescriptor.matchesPropertyValue
(request,
response,
propertyName,
valueString, // if checkbox, is never null
true,
converter,
converterArgs);
}
// Print the "checked" if appropriate
if (shouldCheck) {
inputAttrs.put("checked","checked");
//out.print (" checked");
}
}
//RADIO -- See if the value should be checked
if (isRadio) {
boolean shouldCheck = false;
// See if "checked" was specified explicitly
if (mCheckedSpecified) {
shouldCheck = mChecked;
}
else if (valueString != null) {
shouldCheck =
valueString.equalsIgnoreCase
(DropletDescriptor.getPropertyStringValue
(request,
response,
propertyName,
true,
null,
null));
}
// Print the "checked" if appropriate
if (shouldCheck) {
inputAttrs.put("checked","checked");
//out.print (" checked");
}
}
doAdditionalAttributes (inputAttrs);
// Render INPUT tag
renderTag("input",inputAttrs);
//out.print (">");
// Calculate the priority
int priority =
(mPrioritySpecified) ?
mPriority :
(isSubmit ?
DropletConstants.SUBMIT_PRIORITY_DEFAULT :
DropletConstants.PRIORITY_DEFAULT);
// if no default has been specified, we still need to set a checkbox's
// default to "false" if default has not been specified, since
// checkboxes only show up in the POST arg list on submission if
// they've been checked.
String temp_default = null;
if (isCheckbox && !mDefaultSpecified)
temp_default="false";
else if (mDefaultSpecified)
temp_default=mDefault;
//else -- no default specified, pass null
dspFormTag.doAddTag
(this,
(mNameSpecified) ? mName : null,
nameString,
(mTypeSpecified) ? mType : null,
temp_default,
priority,
(mSubmitvalueSpecified) ? mSubmitvalue : null,
converter,
converterArgs);
return EVAL_BODY_INCLUDE;
}
catch (IOException exc) {
throw new ContainerJspException (exc.getMessage (), exc);
}
catch (ServletException exc) {
throw new ContainerJspException (exc.getMessage (), exc);
}
finally {
// restore old value for flag
if (response != null)
response.setStrictOutputAccess(oldStrictValue);
}
}