File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter from URL inside EL

 
Kristian Kaa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
First off, im very green at JSF, but im trying to get a hold of it, so forgive me if my question is stupid

Im trying to make an activation page with JSF, but i got a problem.
Can i parse a parameter from GET into a bean call?
I've tried different things like

#{myBean.method(#{param['key']})}

but without any success. Is this even possible?

Thanks in advance!
 
Brendan Healey
Ranch Hand
Posts: 218
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
param is an implicit object, will #{param['key']} work? Just to be clear, use the
text "param", don't replace this with your parameter name. I tend to use these
things in system event listeners rather than in the page so can't speak from
experience. If this doesn't work I have a plan B, but that's got to wait for
tomorrow.

Regards,
Brendan.
 
Kristian Kaa
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i have the url
www.url.com/index.xhtml?key=8
and i use the #{param['key']}, it will print out 8, just like php's $_GET['key']

When you say you use "these things in system event listeners", do you mean you "get" the param all the way down from the java classes?
Not sure I understand what you mean, but thanks for your answer anyway :-)
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't "call" beans in JSF. JSF backing beans are made up of properties and/or action methods (along with the occasional listener or other lifecycle support method). The methods are invoked ("called") by JSF. JSF Views are display constructs, not logic constructs. Or at least that's what they're intended to be.

It's possible to pull in GET-method parameters inside a bean method by dereferencing objects from FacesContext. Not pretty, but often done, regardless. I think in JSF2 there's a simpler way. Or you can use PrettyFaces and have it inject the GET parameter in as a standard property.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic