This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JSF Expression Language: scope for expression language syntax

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 101
Spring Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any jsf tag/EL has to be used inside <f:view> only.
 
Saloon Keeper
Posts: 24847
174
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>...
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic