Package org.apache.beehive.netui.tags.javascript

Examples of org.apache.beehive.netui.tags.javascript.ScriptRequestState


    {
        String idScript = null;

        // map the tagId to the real id
        if (TagConfig.isDefaultJavaScript()) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            idScript = srs.mapTagId(getScriptReporter(), _trs.tagId, realId, null);
        }
        return idScript;
    }
View Full Code Here


                registerTagError(s, null);
                reportErrors();
                return;
            }

            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            if (!srs.isFeatureWritten(CoreScriptFeature.DYNAMIC_INIT)) {
                String s = Bundle.getString("Tags_TreeHtmlRunAtClient", null);
                registerTagError(s, null);
                reportErrors();
                return;
            }

            assert(treeRoot instanceof ITreeRootElement);
            ITreeRootElement tre = (ITreeRootElement) treeRoot;

            Object[] args = new Object[8];
            args[0] = _iState.getImageRoot() + "/";
            args[1] = tre.getObjectName();
            args[2] = _iState.getNodeCollapsedImage();
            args[3] = _iState.getNodeExpandedImage();
            args[4] = _iState.getLastNodeCollapsedImage();
            args[5] = _iState.getLastNodeExpandedImage();
            args[6] = Bundle.getString("Tags_TreeAltTextExpand", null);
            args[7] = Bundle.getString("Tags_TreeAltTextCollapse", null);
            srs.writeFeature(sr, writer, CoreScriptFeature.TREE_INIT, false, false, args);

            tre.setTreeRenderState(_trs);
            tre.setInheritableState(_iState);
        }
View Full Code Here

        // Legacy Java Script support -- This writes out a single table with both the id and names
        // mixed.  This is legacy support to match the pre beehive behavior.
        String idScript = null;
        if (TagConfig.isLegacyJavaScript()) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            if (!ctrlState) {
                idScript = srs.mapLegacyTagId(getScriptReporter(), id, state.id);
            }
            else {
                AbstractHtmlControlState cState = (AbstractHtmlControlState) state;
                if (cState.name != null)
                    idScript = srs.mapLegacyTagId(getScriptReporter(), id, cState.name);
                else
                    idScript = srs.mapLegacyTagId(getScriptReporter(), id, state.id);
            }
        }

        // map the tagId to the real id
        String name = null;
View Full Code Here

    protected String renderDefaultNameAndId(HttpServletRequest request, AbstractHtmlState state, String id, String name) {
        // map the tagId to the real id
        String script = null;
        if (TagConfig.isDefaultJavaScript()) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            script = srs.mapTagId(getScriptReporter(), id, state.id, name);
        }
        return script;
    }
View Full Code Here

    public int doStartTag() throws JspException
    {

        if (_rolloverImage != null && getJavaScriptAttribute(ONMOUSEOVER) == null) {
            // cause the roll over script to be inserted
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState((HttpServletRequest) pageContext.getRequest());
            WriteRenderAppender writer = new WriteRenderAppender(pageContext);
            srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.ROLLOVER, true, false, null);
        }

        return EVAL_BODY_BUFFERED;
    }
View Full Code Here

                registerTagError(s, null);
                reportErrors();
                return;
            }

            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            if (!srs.isFeatureWritten(CoreScriptFeature.DYNAMIC_INIT)) {
                String s = Bundle.getString("Tags_TreeHtmlRunAtClient", null);
                registerTagError(s, null);
                reportErrors();
                return;
            }

            assert(treeRoot instanceof ITreeRootElement);
            ITreeRootElement tre = (ITreeRootElement) treeRoot;

            Object[] args = new Object[8];
            args[0] = _iState.getImageRoot() + "/";
            args[1] = tre.getObjectName();
            args[2] = _iState.getNodeCollapsedImage();
            args[3] = _iState.getNodeExpandedImage();
            args[4] = _iState.getLastNodeCollapsedImage();
            args[5] = _iState.getLastNodeExpandedImage();
            args[6] = Bundle.getString("Tags_TreeAltTextExpand", null);
            args[7] = Bundle.getString("Tags_TreeAltTextCollapse", null);
            srs.writeFeature(sr, writer, CoreScriptFeature.TREE_INIT, false, false, args);

            AjaxUrlInfo ajaxInfo = URLRewriterService.getAjaxUrl(pageContext.getServletContext(),request,treeRoot);
            if (ajaxInfo.getCommandPrefix() != null) {
                args = new Object[2];
                args[0] = tre.getObjectName();
                args[1] = ajaxInfo.getCommandPrefix();
                srs.writeFeature(sr,writer, CoreScriptFeature.AJAX_PREFIX, false,false,args);
            }
            if (ajaxInfo.getAjaxParameter() != null) {
                args = new Object[2];
                args[0] = tre.getObjectName();
                args[1] = ajaxInfo.getAjaxParameter();
                srs.writeFeature(sr,writer, CoreScriptFeature.AJAX_PARAM, false,false,args);
            }

            tre.setTreeRenderState(_trs);
            tre.setInheritableState(_iState);
        }
View Full Code Here

    {
        String idScript = null;

        // map the tagId to the real id
        if (TagConfig.isDefaultJavaScript()) {
            ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);
            idScript = srs.mapTagId(getScriptReporter(), _trs.tagId, realId, null);
        }
        return idScript;
    }
View Full Code Here

        WriteRenderAppender writer = new WriteRenderAppender(pageContext);

        // verify hat we are in a container with run at client on...
        IScriptReporter sr = getScriptReporter();
        ScriptRequestState srs = ScriptRequestState.getScriptRequestState(req);
        if (!srs.isFeatureWritten(CoreScriptFeature.DYNAMIC_INIT)) {
            String s = Bundle.getString("Tags_DivPanelHtmlRunAtClient", null);
            registerTagError(s, null);
            reportAndExit(SKIP_BODY);
        }
        srs.writeFeature(sr, writer, CoreScriptFeature.DIVPANEL_INIT, true, false, null);

        // figure out if there is a page to render
        String page = _firstPage;
        if (state != null) {
            String fp = state.getFirstPage();
View Full Code Here

    {
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
        if (!hasErrors()) {
            if (TagConfig.isDefaultJavaScript()) {
                if (_divState.id != null) {
                    ScriptRequestState srs = ScriptRequestState.getScriptRequestState(req);
                    srs.mapTagId(getScriptReporter(), _divState.id, _divState.id, null);
                }
            }
            WriteRenderAppender writer = new WriteRenderAppender(pageContext);
            TagRenderingBase divRenderer = TagRenderingBase.Factory.getRendering(TagRenderingBase.DIV_TAG, req);
            divRenderer.doEndTag(writer);
View Full Code Here

        String idScript = null;

        if (_formSubmit)
            _form = getNearestForm();

        ScriptRequestState srs = ScriptRequestState.getScriptRequestState(request);

        // check the parameters that the user provided
        if (_href != null) have++;
        if (_action != null) have++;
        if (_clientAction != null) have++;
        if (_linkName != null) have++;

        String tagId = getTagId();

        // if only the _linkName or _tagId is set then we are creating the name attribute only.
        if (have == 0 && !_formSubmit && tagId != null) {
            return createNameAnchor(request, trb);
        }

        // if the anchor is submitting a consider this a submit level problem
        // set the action to the form action.
        if (_formSubmit) {
            formAction = getFormAction();
            if ((formAction != null) && (have == 0)) {
                have++;
            }
            if (_action == null) {
                _action = formAction;
                _location = getFormLocation();
            }
        }

        // if we have not specified a destination or we've specified too many
        // then we need to report an error.
        if (have == 0 || have > 1) {
            String s = Bundle.getString("Tags_Anchor_InvalidAnchorURI",
                    new Object[]{getTagName(), requiredAttrs});
            registerTagError(s, null);
            return false;
        }

        if (_linkName != null) {
            return createPageAnchor(request, trb);
        }

        if (_action != null) {
            // report that action is not an action
            if (!PageFlowTagUtils.isAction(request, _action)) {
                String s = null;
                if (_action.equals("")) {
                    s = Bundle.getString("Tags_NullBadAction", null);
                }
                else {
                    s = Bundle.getString("Tags_BadAction", _action);
                }
                registerTagError(s, null);
            }
            else {
                //
                // 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) {
                    addParamInternal(Constants.TOKEN_KEY, token);
                }
            }
        }
       
        // we assume that tagId will over have override id if both
        // are defined.
        if (tagId != null) {
            _state.id = tagId;
            idScript = renderNameAndId(request, _state, null);
        }

        // Special case for name anchors
        if (_clientAction != null) {
            _state.href = "";
        }
        else {
            // Add the scope-ID parameter, if the targetScope attribute is present.
            if (_targetScope != null) {
                addParamInternal(ScopedServletUtils.SCOPE_ID_PARAM, _targetScope);
            }

            if (_popupSupport != null) {
                _popupSupport.addParams(this, request);
            }
           
            // Generate the opening anchor element
            String uri = null;
            try {
                if (_action != null) {
                    uri = PageFlowTagUtils.rewriteActionURL(pageContext, _action, _params, _location);
                }
                else if (_href != null) {
                    uri = PageFlowTagUtils.rewriteHrefURL(pageContext, _href, _params, _location);
                }
            }
            catch (URISyntaxException e) {
                // report the error...
                logger.error(Bundle.getString("Tags_URISyntaxException"));
                String s = Bundle.getString("Tags_Anchor_URLException",
                        new Object[]{e.getMessage()});
                registerTagError(s, e);
            }

            if (uri == null) {
                if (hasErrors())
                    return false;
            }
            else {
                HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
                _state.href = response.encodeURL(uri);
            }
        }

        // We need to combine the onclick features
        IScriptReporter sr = getScriptReporter();
        if (_clientAction != null && srs.isFeatureWritten(CoreScriptFeature.DYNAMIC_INIT)) {
            //@todo: we need to support onclick chaining here also...
            String action = HtmlUtils.escapeEscapes(_clientAction);
            String entry = ScriptRequestState.getString("netuiAction",
                    new Object[]{action});
            _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, entry);
            // Jira 299
            //_state.onClick = entry;
        }

        // if the user overrides the onclick we will ignore this
        String onclick = _state.getAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK);
        if (onclick == null) {
            if (_formSubmit && formAction != null) {
                String realFormName = getFormId();
                String key = (_disableSecondClick ? "anchorDisableAndSubmitFormAction" : "anchorFormSubmitAction");
                String entry = ScriptRequestState.getString(key, new Object[]{realFormName, _state.href});
                _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, entry);
                // Jira 299
                //_state.onClick = ScriptRequestState.getString("anchorFormSubmitAction",
                //        new Object[]{realFormName, _state.href});
                if (_form != null)
                    _form.insureRealId();
            }
            else if (_disableSecondClick) {
                String entry = ScriptRequestState.getString("anchorDisableAction", null);
                _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, entry);
            }
            else if (_popupSupport != null) {
                _state.registerAttribute(AbstractHtmlState.ATTR_JAVASCRIPT, ONCLICK, _popupSupport.getOnClick(request,_state.href));
                // Jira 299
                //_state.onClick = _popupSupport.getOnClick(_state.href);
            }
        }

        if (hasErrors())
            return false;

        trb.doStartTag(writer, _state);

        // Emit javascript if this anchor needs to sumbit the form or open a popup window
        if (_formSubmit && formAction != null || idScript != null || _popupSupport != null) {
            InternalStringBuilder script = new InternalStringBuilder(32);
            StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script);

            if (_formSubmit && formAction != null)
                srs.writeFeature(sr, scriptWriter, CoreScriptFeature.ANCHOR_SUBMIT, true, false,
                        null);
            if (_popupSupport != null)
                _popupSupport.writeScript(request, srs, getScriptReporter(), scriptWriter);
            if (idScript != null)
                scriptWriter.append(idScript);
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.tags.javascript.ScriptRequestState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.