Search in sources :

Example 1 with EvaluationException

use of org.apache.tiles.evaluator.EvaluationException in project struts by apache.

the class StrutsAttributeEvaluator method evaluate.

@Override
public Object evaluate(String expression, Request request) {
    try {
        HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
        ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
        if (ctx == null) {
            LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
            throw new ConfigurationException("There is no ActionContext for current request!");
        }
        OgnlUtil ognlUtil = ctx.getContainer().getInstance(OgnlUtil.class);
        LOG.debug("Trying evaluate expression [{}] using OgnlUtil's getValue", expression);
        Object result = ognlUtil.getValue(expression, ctx.getContextMap(), ctx.getValueStack().getRoot());
        LOG.debug("Final result of evaluating expression [{}] is: {}", expression, result);
        return result;
    } catch (OgnlException e) {
        throw new EvaluationException(e);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) OgnlException(ognl.OgnlException) ConfigurationException(com.opensymphony.xwork2.config.ConfigurationException) OgnlUtil(com.opensymphony.xwork2.ognl.OgnlUtil) EvaluationException(org.apache.tiles.evaluator.EvaluationException) ActionContext(com.opensymphony.xwork2.ActionContext) ServletActionContext(org.apache.struts2.ServletActionContext)

Aggregations

ActionContext (com.opensymphony.xwork2.ActionContext)1 ConfigurationException (com.opensymphony.xwork2.config.ConfigurationException)1 OgnlUtil (com.opensymphony.xwork2.ognl.OgnlUtil)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 OgnlException (ognl.OgnlException)1 ServletActionContext (org.apache.struts2.ServletActionContext)1 EvaluationException (org.apache.tiles.evaluator.EvaluationException)1