• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why is a dynamically created JSF EL value expression not resolved?  RSS feed

 
Christian Smolka
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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?

Can anyone tell me why? Thanks in advance!
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christian Smolka
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!