views:

22

answers:

0

Hi,

I got a simple setup (and a big issue): a JSP page with en empty panel grid item container and a binding to a bean.

<h:panelGrid binding="#{ bean.container }" id="container" />

When the getter of the bean will be called, the container is filled with a random number of columns with a command link inside. So far so good. The container is filled up with the right number of elements, and with the use of an ActionListener on the links, I get all click events.

Here comes the tricky part: I want to mark the 'selected' or 'pressed' column via a different style class. With a static setup, I would do this with an expression like:

<h:column styleClass="#{ bean.selectedColumn eq 'id' ? 'btnSelected' : 'btn' }">
    <!-- command link and some blahblah -->
</h:column>

The bean contains a simple getter getSelectedColumn() , that returns an id. Straight forward, so this works perfect!

But when I try to do the same inside the bean,

ELContext elContext = FacesContext.getCurrentInstance().getELContext();
String expression = "#{ bean.selectedColumn eq 'id' ? 'btnSelected' : 'btn' }";
new ExpressionFactoryImpl().createValueExpression(elContext, expression, String.class);
column.setValueExpression("styleClass", valueExpression);

the expression won't ever be resolved. To make myself clear: both the command links, the columns and the value expressions are generated inside the bean. Is that the cause?

Can anyone tell me why? Thanks in advance!