aspose file tools
The moose likes JSF and the fly likes JSF Expression Language: scope for expression language syntax 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 "JSF Expression Language: scope for expression language syntax" Watch "JSF Expression Language: scope for expression language syntax" New topic
Author

JSF Expression Language: scope for expression language syntax

Tim Wise
Greenhorn

Joined: Jul 25, 2009
Posts: 15
Hi all,

I have a simple question: what is the scope where I can use JSF EL?

The point is that I need to use a value from a backing bean in the JSTL tag even before I use <f:view>. Here is an example:


But surely it doesn't work. It results to exactly "Details for "#{detailsController.entity.name}"" in page title, #{} syntax doesn't work there. I've tried to envelope the <c:set ...> with <f:view>...</f:view> but it didn't work either. So, the question is why? Should the syntax #{} work only in some specific context?
Shasi Mitra
Ranch Hand

Joined: Nov 27, 2008
Posts: 101

Any jsf tag/EL has to be used inside <f:view> only.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14487
    
    7

You'd be better off using Facelets. It does a very civilized approach to page tiling and you don't need JSTL or other kludges.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Wise
Greenhorn

Joined: Jul 25, 2009
Posts: 15
Thanks for your answers. Actually I finally found why it didn't work. I've been using a JST 1.1.2 which doesn't use the unified EL. Now I'm using JSTL 1.2, and my backing bean gets invoked, but I still don't get the desired result. The value from a backing bean property is not actually used. Given my previous example:

the value "Details for ''" is set to "title" variable. Getters getEntity() and getName() are invoked and return correct value (I've checked this in debugger).

I assume this behavior may be caused by the declaration of "value" attribute for <c:set ...> tag:



As seen here, the deferred value has Object type. Could it be the reason of this behavior? How could I overcome this and finally get my String value returned from a backing bean used in the <c:set ...> correctly? Or, if it is not the reason, why doesn't it work now?

Many thanks for your help and any ideas.

P.S. Tim, I already consider using Facelets indeed, thanks for hint
Tim Wise
Greenhorn

Joined: Jul 25, 2009
Posts: 15
Well, so as to close the topic... I've found what was wrong: it occurs that only ${} syntax should be used if the attribute is declared as rtexprvalue=true, which is the case for c:set's value attribute. So, finally, this works fine with JSTL 1.2 unified EL:

BTW, it even can be used outside of the <f:view>...
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JSF Expression Language: scope for expression language syntax
 
Similar Threads
problem when working with selectOneListbox
Problem with JSTL in RAD7.5
Problem with localization (MyFaces and JSTL)
Casting Exception
jstl in eclipse