aspose file tools
The moose likes JSF and the fly likes Why is a dynamically created JSF EL value expression not resolved? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Why is a dynamically created JSF EL value expression not resolved?" Watch "Why is a dynamically created JSF EL value expression not resolved?" New topic
Author

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

Christian Smolka
Greenhorn

Joined: Oct 18, 2010
Posts: 2
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

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.
Christian Smolka
Greenhorn

Joined: Oct 18, 2010
Posts: 2
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
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Why is a dynamically created JSF EL value expression not resolved?
 
Similar Threads
EL expression using a declared var in data table
Foreign key field population from datatable to textbox?
Displaying Two Buttons in one Row from HashMap
Providing anchor to columns in a datatable
Using selectManyCheckbox