• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Passing Params

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Saloon Keeper
Posts: 28239
198
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ELFlash worked, thanks
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
The moustache of a titan! The ad of a flea:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic