4

Environment: JSF 2.0 (Mojarra 4.0), Facelets, Richfaces, Websphere 7.0

I have a custom inputText component, which needs to execute EL expressions in the JSTL EL Context. I have a special situation, where I need JSTL "foreach" to create a complex table (can't use "a4j:reapeat").

Custom Component example:

<c:forEach var="cell" items="#{line.cellDescriptorList}" >
        <rich:column>
            <k:inputText onkeyup="#{cell.onKeyup}" id="#{cell.jsfId}" value="#{cell.wert.wert}">
                <f:converter converterId="PercentageConverterBigDecimal" />
            </k:inputText>
        </rich:column>
</c:forEach>

In my custom component Renderer I need to evaluate an expression on #{cell}. This variable is stored in the JSTL (JSP?) EL context. Executing expressions in the JSF EL context or the Facelets EL context works just fine. But how can I access the JSTL EL context programatically?

Example for JSF EL Context:

final ELContext elContext = facesContext.getELContext();
final Application application = facesContext.getApplication();
ExpressionFactory expressionFactory = application.getExpressionFactory();
ValueExpression exp = expressionFactory.createValueExpression(elContext, expression, Object.class);
Object result = exp.getValue(elContext);

Example for Facelets EL context here.

Can you please point me to a solution for the JSTL EL context?

Thanks in advance. Kai

Community
  • 1
  • 1
Kai Berkau
  • 91
  • 1
  • 6

1 Answers1

0

Does this JSP demonstrate anything helpful ?

<%@ page import="java.util.Arrays,javax.el.*" %>
<jsp:useBean id="list" class="java.util.ArrayList" />
<jsp:useBean id="newList" class="java.util.ArrayList" />
<%
  list.addAll(Arrays.asList("red","green","blue"));
  newList.addAll(Arrays.asList("brown", "yellow", "purple"));
  JspFactory jspFactory= JspFactory.getDefaultFactory();
  ExpressionFactory expFactory = jspFactory.getJspApplicationContext(application).getExpressionFactory();
  ELContext elContext =  pageContext.getELContext();
  ValueExpression valueEx = expFactory.createValueExpression(elContext, "${list}",String.class);
%>
My favorite colors are ${list[0]}, ${list[1]}, and ${list[2]}.<br/>
<% valueEx.setValue(elContext, newList); %>
No, I changed my mind. I like ${list[0]}, ${list[1]}, and ${list[2]}.
rickz
  • 4,324
  • 2
  • 19
  • 30