@Test public void testBasicEL(){ JspPage page = new JspPage("testpath", new CodeLocation("testpath", 1, 1)); ExpressionFactory expressionFactory = ExpressionFactory.newInstance(); StandardELContext elContext = new StandardELContext(expressionFactory); elContext.getVariableMapper().setVariable("page", expressionFactory.createValueExpression(page, JspPage.class)); ValueExpression expr = expressionFactory.createValueExpression(elContext, "${page.name}", String.class); Object result = expr.getValue(elContext); assertEquals("testpath", result ); }
@Test public void testELWithString(){ JspPage page = new JspPage("testpath", new CodeLocation("testpath", 1, 1)); ExpressionFactory expressionFactory = ExpressionFactory.newInstance(); StandardELContext elContext = new StandardELContext(expressionFactory); elContext.getVariableMapper().setVariable("page", expressionFactory.createValueExpression(page, JspPage.class)); ValueExpression expr = expressionFactory.createValueExpression(elContext, "The page name is ${page.name}", String.class); Object result = expr.getValue(elContext); assertEquals("The page name is testpath", result ); }
@Override public ELContext newElContext() { ELContext context = new StandardELContext(newExpressionFactory()); setupFunctions(context); return context; }
private void init() { final StandardELContext context = new StandardELContext(factory); functionMapper = context.getFunctionMapper(); variableMapper = context.getVariableMapper(); }