• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF Expression Language: scope for expression language syntax  RSS feed

 
Tim Wise
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any jsf tag/EL has to be used inside <f:view> only.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Wise
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!