Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing Params

 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a page with a command button on it. On click of the button ,it calls a method in a bean which calls a BO class and gets a new VO object. If the new VO object is not null, then I need to extract some attributes of the new VO and pass it as request params to the new xhtml. The bean for the new XHTMl will read the params and displays appropriate data.How do I do this using JSF2.0

 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mary,

Please check this

It states to use a conversation scope but then you can't use this one on Tomcat, you need
application server like GlassFish.

HTH,
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Alternatively, you also put your object in the flash scope like this


and in the next page use the value as



Additionally, i was trying. It will only work page to page basis. Not with Ajax. I guess you have to put it in servlet
request as an attribute and then access it. It could be something like this


But unfortunately, i am unable to access the request parameter in the new page.

Hope this helps.

BR,
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Currently, i have found one solution, that you inject that bean as a managed property in the current bean.
You can do it either by the use of @ManagedProperty or explicitly set in faces-config.xml. I am also finding
out the proper way of passing parameters. As soon as i get some, i will update you.

My faces-config.xml looks something like this


My action method looks like this


HTH,
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Passing parameters isn't really JSF's style. More typically, you'd set properties in a backing bean and make that backing bean available to the next process down the line. Typically that bean would be in session or flash scope.
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ELFlash worked, thanks
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, but remember it won't work for an Ajax request.

As instructed by TOM, the best practice is to introduce managed properties.

HTH,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic