File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes scoped variable as attribute 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 "scoped variable as attribute" Watch "scoped variable as attribute" New topic
Author

scoped variable as attribute

Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
Hi folks,

Is it possible to use some scoped variable (or its properties) in attributes of JSF tags? I tried JSP expressions (${variable.property} or ${scope.var.prop}), but the compiler complained that I can't use expressions in attributes.
So far, in order to do that kind of thing I obtain the needed object from a managed-bean property (therefore using #{managedBean.prop}). Is this the right way to do things?
Thanks in advance


Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400

Is it possible to use some scoped variable (or its properties) in attributes of JSF tags?


You certainly can, for e.g. through managed bean getters setters


Is this the right way to do things?

Can you explain what are you trying to do?


- Varun
Henrique Sousa
Ranch Hand

Joined: Apr 29, 2004
Posts: 92
Sorry for the late reply, I was out for the weekend. Anyway, what I would like to achieve is something like this:

where "someVariable" is a variable in request or session scope but not declared as a managed-bean. My first approach was to use JSP Expression Language (JSP 2.0 specs):

but it didn't work because I can't use EL in attributes of JSF tags. Other naive approaches didn't work either: "#{someVariable}", "someVariable", ...
The only way I did get it working was by setting the object to some managed-bean in the desired scope, as you suggested:

Is this the only way to do this?
[ June 13, 2005: Message edited by: Henrique Sousa ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scoped variable as attribute
 
Similar Threads
accessing object declared in useBean
Checking for Session Timeout
capturing variable in "value" field of the form
Difference between Page and PageContext
What is the best practice of handling attribute names?