public int doEndTag ( ) throws JspException { Tag parent = getParent ( ) ; if ( parent instanceof CheckBoxGroup ) registerTagError ( Bundle . getString ( "Tags_CheckBoxGroupChildError" ) , null ) ; Object val = evaluateDataSource ( ) ; if ( hasErrors ( ) ) return reportAndExit ( EVAL_PAGE ) ; ByRef ref = new ByRef ( ) ; nameHtmlControl ( _state , ref ) ; String hiddenParamName = _state . name + OLDVALUE_SUFFIX ; ServletRequest req = pageContext . getRequest ( ) ; if ( val instanceof String ) { if ( val != null && Boolean . valueOf ( val . toString ( ) ) . booleanValue ( ) ) _state . checked = true ; else _state . checked = false ; } else if ( val instanceof Boolean ) { _state . checked = ( ( Boolean ) val ) . booleanValue ( ) ; } else { String oldCheckBoxValue = req . getParameter ( hiddenParamName ) ; if ( oldCheckBoxValue != null ) { _state . checked = new Boolean ( oldCheckBoxValue ) . booleanValue ( ) ; } else { _state . checked = evaluateDefaultValue ( ) ; } } _state . disabled = isDisabled ( ) ; //Create a hidden field to store the CheckBox oldValue String oldValue = req . getParameter ( _state . name ) ; WriteRenderAppender writer = new WriteRenderAppender ( pageContext ) ; // if the checkbox is disabled we need to not write out the hidden // field because it can cause the default state to change from // true to false. Disabled check boxes do not postback. if ( ! _state . disabled ) { _hiddenState . name = hiddenParamName ; if ( oldValue == null ) { _hiddenState . value = "false" ; } else { _hiddenState . value = oldValue ; } TagRenderingBase hiddenTag = TagRenderingBase . Factory . getRendering ( TagRenderingBase . INPUT_HIDDEN_TAG , req ) ; hiddenTag . doStartTag ( writer , _hiddenState ) ; hiddenTag . doEndTag ( writer ) ; } _state . type = INPUT_CHECKBOX ; TagRenderingBase br = TagRenderingBase . Factory . getRendering ( TagRenderingBase . INPUT_BOOLEAN_TAG , req ) ; br . doStartTag ( writer , _state ) ; if ( ! ref . isNull ( ) ) write ( ( String ) ref . getRef ( ) ) ; // Continue processing this page localRelease ( ) ; return EVAL_PAGE ; }
Render the checkbox .