Why is a dynamically created JSF EL value expression not resolved?
Joined: Oct 18, 2010
this is my first post in this forum, so plese be gentle to me.
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.
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:
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,
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?
I haven't analyzed this in detail, but why use EL? If all you want to do is programmatically highlight a sub-component using CSS - which is how I (mis?)read your intentions - why not just modify the sub-component's styleClass property?
Directly, I mean. Not using EL to access it.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Oct 18, 2010
I tried that before, but the links won't be regenerated when I click on them. That's why I thought, the expression is the right way.
I also tried to set the reRender attribute, but with no effect.
An ActionListener will only fire if you pass validation and bean update phases, although that's probably not an issue with what you're describing. reRender implies that somewhere out there is a RichFaces element that's anchoring all this, but you didn't show it, so I know nothing about that.
Without a wearying level of detail, I can't really say what's wrong, but I try to keep logic out of my EL as much as possible, so I'd usually be setting the styleClass properties either directly or by referencing properties that returned the stylename.
As a general rule, the more non-POJO-code you use in JSF, the more likely you're doing it the hard way.
My own experience is that dynamically editing page elements can be a little frustrating sometimes, though, regardless.