Package org.apache.beehive.netui.script

Examples of org.apache.beehive.netui.script.ExpressionEvaluator


     * @return the qualified name or <code>null</code> if an error occurred
     */
    public String rewriteName(String name, Tag currentTag)
            throws ExpressionEvaluationException
    {
        ExpressionEvaluator eval = ExpressionEvaluatorFactory.getInstance();

        try {
            if (!eval.isExpression(name))
                return eval.qualify("actionForm", name);
            return name;
        }
        catch (Exception e) {
            if (logger.isErrorEnabled())
                logger.error("Could not qualify name \"" + name + "\" into the actionForm binding context.", e);
View Full Code Here


    public static void populate(HttpServletRequest request, HttpServletResponse response, ActionForm form, boolean requestHasPopulated)
        throws ServletException
    {
        String key = null;
        Map strutsProperties = null;
        ExpressionEvaluator ee = ExpressionEvaluatorFactory.getInstance();

        // a boolean so that we can avoid an instanceof below...
        boolean isMultipart = false;

        // if this returns null, it's not a mulitpart request
        Map params = MultipartRequestUtils.handleMultipartRequest(request, form);

        // make adjustments
        if(params != null)
            isMultipart = true;
        else params = request.getParameterMap();

        if(params == null)
        {
            if(_logger.isWarnEnabled()) _logger.warn("An error occurred checking a request for multipart status.  No model values were updated.");
            return;
        }

        /* explicitly build a variable resolver that is used to provide objects that may be updated to the expression engine */
        VariableResolver variableResolver = ImplicitObjectUtil.getUpdateVariableResolver(form, request, response, true);

        /* todo: are there any ordering issues with using an Iterator vs. an Enumeration here? */
        Iterator iterator = params.keySet().iterator();
        while (iterator.hasNext())
        {
            key = (String) iterator.next();
            String expr = null;

            // if there is an expression map, lookup the real expression from the name
            expr = key;
            if (_logger.isDebugEnabled())
                _logger.debug("key: " + key + " value type: " + params.get(key).getClass().getName() + " value: " + params.get(key));

            try
            {
                Object paramsValue = params.get(key);
                if (ee.containsExpression(expr))
                {
                    Object updateValue = null;
                    if (!isMultipart || paramsValue instanceof String[])
                    {
                        String[] values = (String[]) paramsValue;

                        // the only "contains" case that is accepted
                        if (expr.startsWith(WLW_TAG_HANDLER_PREFIX))
                        {
                            if (_logger.isDebugEnabled()) _logger.debug("Found an expression requiring a TAG HANDLER");

                            ExpressionUpdateNode node = doTagHandler(key, expr, values, request);

                            expr = node.expression;
                            values = node.values;
                        }

                        if (values != null && values.length == 1)
                            updateValue = values[0];
                        else
                            updateValue = values;
                    }
                    // handle funky types that Struts returns for a file upload request handler
                    else
                    {
                        updateValue = params.get(key);
                    }

                    try
                    {
                        // trap any bad expressions here
                        if (ee.isExpression(expr))
                        {
                            // common case, make this fast
                            if (!requestHasPopulated)
                                ee.update(expr, updateValue, variableResolver, true);
                            // must check the expression to make sure pageFlow. and globalApp. don't get executed more than once
                            else
                            {
                                Expression pe = ee.parseExpression(expr);
                                String contextName = pe.getContext();
                                if (!contextName.equals(PAGE_FLOW_CONTEXT) && !contextName.equals(GLOBAL_APP_CONTEXT))
                                    ee.update(expr, updateValue, variableResolver, true);
                            }
                        }
                    }
                            // catch any errors, particularly expression parse failures
                    catch (ExpressionUpdateException e)
View Full Code Here

                                ActionForm form,
                                boolean requestHasPopulated)
        throws ServletException {
        String key = null;
        Map strutsProperties = null;
        ExpressionEvaluator ee = ExpressionEvaluatorFactory.getInstance();

        /* Boolean used to avoid instanceof check below */
        boolean isMultipart = false;

        // if this returns null, it's not a mulitpart request
        Map params = MultipartRequestUtils.handleMultipartRequest(request, form);

        // make adjustments
        if(params != null)
            isMultipart = true;
        else params = request.getParameterMap();

        if(params == null) {
            LOG.warn("An error occurred checking a request for multipart status.  No model values were updated.");
            return;
        }

        /* explicitly build a variable resolver that is used to provide objects that may be updated to the expression engine */
        VariableResolver variableResolver = ImplicitObjectUtil.getUpdateVariableResolver(form, request, response, true);

        Iterator iterator = params.keySet().iterator();
        while (iterator.hasNext()) {
            key = (String)iterator.next();
            String expr = null;

            // if there is an expression map, lookup the real expression from the name
            expr = key;
            LOG.debug("key: " + key + " value type: " + params.get(key).getClass().getName() + " value: " + params.get(key));

            try {
                Object paramsValue = params.get(key);
                if (ee.containsExpression(expr)) {
                    Object updateValue = null;
                    if (!isMultipart || paramsValue instanceof String[]) {
                        String[] values = (String[]) paramsValue;

                        // the only "contains" case that is accepted
                        if (expr.startsWith(TAG_HANDLER_PREFIX)) {
                            LOG.debug("Found an expression requiring a TAG HANDLER");

                            ExpressionUpdateNode node = doTagHandler(key, expr, values, request);

                            expr = node.expression;
                            values = node.values;
                        }

                        if (values != null && values.length == 1)
                            updateValue = values[0];
                        else
                            updateValue = values;
                    }
                    // handle funky types that Struts returns for a file upload request handler
                    else {
                        updateValue = params.get(key);
                    }

                    try {
                        // trap any bad expressions here
                        if (ee.isExpression(expr)) {
                            // common case, make this fast
                            if (!requestHasPopulated)
                                ee.update(expr, updateValue, variableResolver, true);
                            // must check the expression to make sure pageFlow. and globalApp. don't get executed more than once
                            else {
                                Expression pe = ee.parseExpression(expr);
                                String contextName = pe.getContext();
                                if (!contextName.equals(PAGE_FLOW_CONTEXT) && !contextName.equals(GLOBAL_APP_CONTEXT))
                                    ee.update(expr, updateValue, variableResolver, true);
                            }
                        }
                    }
                    // catch any errors, particularly expression parse failures
                    catch (ExpressionUpdateException e) {
View Full Code Here

     * @return the qualified name or <code>null</code> if an error occurred
     */
    public String rewriteName(String name, Tag currentTag)
            throws ExpressionEvaluationException
    {
        ExpressionEvaluator eval = ExpressionEvaluatorFactory.getInstance();

        try {
            if (!eval.isExpression(name))
                return eval.qualify("actionForm", name);
            return name;
        }
        catch (Exception e) {
            if (logger.isErrorEnabled())
                logger.error("Could not qualify name \"" + name + "\" into the actionForm binding context.", e);
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.script.ExpressionEvaluator

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.