• Post Reply Bookmark Topic Watch Topic
  • New Topic

scoped variable as attribute  RSS feed

 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!