public int doEndTag()
            throws JspException
    {
        String idScript = null;

        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

        // Acquire the label value we will be generating
        if (_value == null)
            _value = Bundle.getString("Tags_ButtonText", null);
        _state.value = _value;

        // Generate an HTML element
        _state.disabled = isDisabled();

        // Add parameters for popup window support.
        if (_popupSupport != null) {
            _popupSupport.addParams(this, request);
        }

        // targetScope implies an extra parameter.  If there's no action on this button, get the action from the
        // nearest form, so we can construct an action url with our extra parameter.
        if (_targetScope != null && _action == null) {
            Form parentForm = getNearestForm();
            if (parentForm != null) {
                _action = parentForm.getAction();
            }
        }

        if (_action == null && _params != null && _popupSupport == null) {
            Form parentForm = getNearestForm();
            if (parentForm != null) {
                _action = parentForm.getAction();
            }
        }

        if (_action != null) {
            boolean isAction = PageFlowTagUtils.isAction(request, _action);
            if (isAction) {

                // If the action we're submitting to is checking for double-submits, save a token in the session.
                // This will be written out as a param (below), and will be checked in PageFlowRequestProcessor.
                String token = PageFlowTagUtils.getToken(request, _action);
                if (token != null) {
                    if (_params == null) {
                        _params = new HashMap();
                    }
                    _params.put(Constants.TOKEN_KEY, token);
                }

                // Add the scope ID parameter if there's one on the tag, or if there's one in the request.
                if (_targetScope != null) {
                    if (_params == null) {
                        _params = new HashMap();
                    }
                    _params.put(ScopedServletUtils.SCOPE_ID_PARAM, _targetScope);
                }

                String overrideAction = ACTION_OVERRIDE + _action;
                overrideAction = HtmlUtils.addParams(overrideAction, _params, response.getCharacterEncoding());
                String buttonOutput = URLRewriterService.getNamePrefix(pageContext.getServletContext(),
                        pageContext.getRequest(), overrideAction) + overrideAction;
                if (buttonOutput.indexOf(";") > -1) {
                    buttonOutput = buttonOutput.substring(0, buttonOutput.indexOf(";"));
                }
                _state.name = buttonOutput;

                // don't write the id attribute
                Form parentForm = getNearestForm();
                idScript = renderNameAndId(request, _state, parentForm);
            }
            else {
                // set the error because the action is invalid
                registerTagError(Bundle.getString("Tags_BadAction", _action), null);
            }
        }
        else {
            Form parentForm = getNearestForm();
            idScript = renderNameAndId(request, _state, parentForm);
        }

        boolean buttonDisableAndSubmit = false;
        boolean buttonDisable = false;
        
        // if the user overrides the onclick we will ignore this
        if (getOnClick() == null) {
            if (_disableSecondClick) {
                Form parentForm = getNearestForm();
                String href = getActionUrl(request, response);
                String entry;
                if (parentForm != null && href != null && (_state.type == null || _state.type == INPUT_SUBMIT)) {
                    entry = ScriptRequestState.getString("buttonDisableAndSubmitFormAction",
                            new Object[]{parentForm.getRealFormId(), href});
                    buttonDisableAndSubmit = true;
                }
                else {
                    entry = ScriptRequestState.getString("buttonDisableAction", null);
                    buttonDisable = true;
                }
                _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, entry);
                if (parentForm != null)
                    parentForm.insureRealId();
            }
            else if (_popupSupport != null) {
                String href = getActionUrl(request, response);

                if (href != null) {
                    href = response.encodeURL(href);
                    setOnClick(_popupSupport.getOnClick(request,href));
                }
            }
        }
        
        // report any errors that may have been generated.
        if (hasErrors())
            return reportAndExit(EVAL_PAGE);

        WriteRenderAppender writer = new WriteRenderAppender(pageContext);
        TagRenderingBase br = null;
        if (_renderAsButton) {
            br = TagRenderingBase.Factory.getRendering(TagRenderingBase.BUTTON_TAG, request);
            br.doStartTag(writer, _state);
            // add the body content
            if (_text != null)
                write(_text);
            else if (_value != null)
                write(_value);
        }
        else {
            br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_SUBMIT_TAG, request);
            br.doStartTag(writer, _state);
        }
        br.doEndTag(writer);

        //Emit javascript if this button needs to sumbit the form or open a popup window
        if (idScript != null || _popupSupport != null || buttonDisable || buttonDisableAndSubmit) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            InternalStringBuilder script = new InternalStringBuilder(32);
            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);
            IScriptReporter sr = getScriptReporter();

            if (buttonDisableAndSubmit)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE_AND_SUBMIT, true, false, null);
            if (buttonDisable)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.BUTTON_DISABLE, true, false, null);
            if (_popupSupport != null)
                _popupSupport.writeScript(request, srs, getScriptReporter(), scriptWriter);
            if (idScript != null)
                scriptWriter.append(idScript);
            write(script.toString());
        }
        
        // Evaluate the remainder of this page
        localRelease();
        return EVAL_PAGE;
    }
public int doEndTag ( ) throws JspException { String idScript = null ; HttpServletRequest request = ( HttpServletRequest ) pageContext . getRequest ( ) ; HttpServletResponse response = ( HttpServletResponse ) pageContext . getResponse ( ) ; if ( _value == null ) _value = Bundle . getString ( "Tags_ButtonText" , null ) ; _state . value = _value ; _state . disabled = isDisabled ( ) ; if ( _popupSupport != null ) { _popupSupport . addParams ( this , request ) ; } if ( _targetScope != null && _action == null ) { Form parentForm = getNearestForm ( ) ; if ( parentForm != null ) { _action = parentForm . getAction ( ) ; } } if ( _action == null && _params != null && _popupSupport == null ) { Form parentForm = getNearestForm ( ) ; if ( parentForm != null ) { _action = parentForm . getAction ( ) ; } } if ( _action != null ) { boolean isAction = PageFlowTagUtils . isAction ( request , _action ) ; if ( isAction ) { String token = PageFlowTagUtils . getToken ( request , _action ) ; if ( token != null ) { if ( _params == null ) { _params = new HashMap ( ) ; } _params . put ( Constants . TOKEN_KEY , token ) ; } if ( _targetScope != null ) { if ( _params == null ) { _params = new HashMap ( ) ; } _params . put ( ScopedServletUtils . SCOPE_ID_PARAM , _targetScope ) ; } String overrideAction = ACTION_OVERRIDE + _action ; overrideAction = HtmlUtils . addParams ( overrideAction , _params , response . getCharacterEncoding ( ) ) ; String buttonOutput = URLRewriterService . getNamePrefix ( pageContext . getServletContext ( ) , pageContext . getRequest ( ) , overrideAction ) + overrideAction ; if ( buttonOutput . indexOf ( ";" ) > - 1 ) { buttonOutput = buttonOutput . substring ( 0 , buttonOutput . indexOf ( ";" ) ) ; } _state . name = buttonOutput ; Form parentForm = getNearestForm ( ) ; idScript = renderNameAndId ( request , _state , parentForm ) ; } else { registerTagError ( Bundle . getString ( "Tags_BadAction" , _action ) , null ) ; } } else { Form parentForm = getNearestForm ( ) ; idScript = renderNameAndId ( request , _state , parentForm ) ; } boolean buttonDisableAndSubmit = false ; boolean buttonDisable = false ; if ( getOnClick ( ) == null ) { if ( _disableSecondClick ) { Form parentForm = getNearestForm ( ) ; String href = getActionUrl ( request , response ) ; String entry ; if ( parentForm != null && href != null && ( _state . type == null || _state . type == INPUT_SUBMIT ) ) { entry = ScriptRequestState . getString ( "buttonDisableAndSubmitFormAction" , new Object [ ] { parentForm . getRealFormId ( ) , href } ) ; buttonDisableAndSubmit = true ; } else { entry = ScriptRequestState . getString ( "buttonDisableAction" , null ) ; buttonDisable = true ; } _state . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONCLICK , entry ) ; if ( parentForm != null ) parentForm . insureRealId ( ) ; } else if ( _popupSupport != null ) { String href = getActionUrl ( request , response ) ; if ( href != null ) { href = response . encodeURL ( href ) ; setOnClick ( _popupSupport . getOnClick ( request , href ) ) ; } } } if ( hasErrors ( ) ) return reportAndExit ( EVAL_PAGE ) ; WriteRenderAppender writer = new WriteRenderAppender ( pageContext ) ; TagRenderingBase br = null ; if ( _renderAsButton ) { br = TagRenderingBase . Factory . getRendering ( TagRenderingBase . BUTTON_TAG , request ) ; br . doStartTag ( writer , _state ) ; if ( _text != null ) write ( _text ) ; else if ( _value != null ) write ( _value ) ; } else { br = TagRenderingBase . Factory . getRendering ( TagRenderingBase . INPUT_SUBMIT_TAG , request ) ; br . doStartTag ( writer , _state ) ; } br . doEndTag ( writer ) ; if ( idScript != null || _popupSupport != null || buttonDisable || buttonDisableAndSubmit ) { ScriptRequestState srs = ScriptRequestState . getScriptRequestState ( request ) ; InternalStringBuilder script = new InternalStringBuilder ( 32 ) ; StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender ( script ) ; IScriptReporter sr = getScriptReporter ( ) ; if ( buttonDisableAndSubmit ) srs . writeFeature ( sr , scriptWriter , CoreScriptFeature . BUTTON_DISABLE_AND_SUBMIT , true , false , null ) ; if ( buttonDisable ) srs . writeFeature ( sr , scriptWriter , CoreScriptFeature . BUTTON_DISABLE , true , false , null ) ; if ( _popupSupport != null ) _popupSupport . writeScript ( request , srs , getScriptReporter ( ) , scriptWriter ) ; if ( idScript != null ) scriptWriter . append ( idScript ) ; write ( script . toString ( ) ) ; } localRelease ( ) ; return EVAL_PAGE ; }
Render the button.
@throws JspException if a JSP exception has occurred