Example usage for org.springframework.expression ParserContext TEMPLATE_EXPRESSION

List of usage examples for org.springframework.expression ParserContext TEMPLATE_EXPRESSION

Introduction

In this page you can find the example usage for org.springframework.expression ParserContext TEMPLATE_EXPRESSION.

Prototype

ParserContext TEMPLATE_EXPRESSION

To view the source code for org.springframework.expression ParserContext TEMPLATE_EXPRESSION.

Click Source Link

Document

The default ParserContext implementation that enables template expression parsing mode.

Usage

From source file:org.focusns.common.web.page.engine.widget.WidgetPageEngine.java

public void doAction(HttpServletRequest request, HttpServletResponse response) throws PageEngineException {
    ////from   w  w  w  .j  a  va2  s  .  com
    try {
        //
        PageConfig pageConfig = (PageConfig) request.getSession().getAttribute("pageConfig");
        String widgetId = (String) request.getAttribute("widgetId");
        WidgetConfig widgetConfig = pageConfig.getWidgetConfigById(widgetId);
        //
        WidgetRequest widgetRequest = new WidgetRequest(request, widgetConfig, "action");
        WidgetResponse widgetResponse = new WidgetResponse(response);
        //
        String lookupPath = urlPathHelper.getLookupPathForRequest(request);
        String queryString = urlPathHelper.getOriginatingQueryString(request);
        String actionPath = "/widget" + lookupPath + "?" + queryString;
        ServletContext widgetContext = getServletContext();
        if (StringUtils.hasText(widgetConfig.getContext())) {
            widgetContext = getServletContext().getContext(widgetConfig.getContext());
            if (widgetContext == null) {
                return;
            }
        }
        //
        widgetRequest.setAttribute("requestType", "action");
        widgetRequest.setAttribute("widgetConfig", widgetConfig);
        //
        Navigator navigator = Navigator.reset();
        //
        for (WidgetActionInterceptor actionInterceptor : widgetActionInterceptors) {
            actionInterceptor.beforeAction(request, response);
        }
        widgetContext.getRequestDispatcher(actionPath).forward(widgetRequest, widgetResponse);
        //
        for (WidgetActionInterceptor actionInterceptor : widgetActionInterceptors) {
            actionInterceptor.afterAction(request, response);
        }
        //
        if (!StringUtils.hasText(navigator.getNavigateTo())) {
            widgetResponse.flushBuffer();
            return;
        }
        //
        String pathExpr = widgetConfig.getNavigationMap().get(navigator.getNavigateTo());
        if (StringUtils.hasText(pathExpr)) {
            Expression expression = expressionParser.parseExpression(pathExpr,
                    ParserContext.TEMPLATE_EXPRESSION);
            EvaluationContext evaluationContext = createEvaluationContext();
            String path = (String) expression.getValue(evaluationContext, request);
            //
            request.getSession().setAttribute("redirectAttributes", navigator.getRedirectAttributes());
            response.sendRedirect(request.getContextPath() + path);
        }
        //
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new PageEngineException(e.getMessage(), e);
    } finally {
        Navigator.reset();
    }
}

From source file:it.geosolutions.geoserver.sira.security.expression.ExpressionRuleEngine.java

/**
 * Get the specialized {@link ParserContext}.
 *
 * @return the specialized {@link ParserContext}
 *//*  w  ww  . java  2s . co m*/
public static ParserContext getTemplateExpression() {
    return ParserContext.TEMPLATE_EXPRESSION;
}