aspose file tools*
The moose likes JSF and the fly likes Passing Params Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Passing Params" Watch "Passing Params" New topic
Author

Passing Params

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
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

Joined: Oct 13, 2009
Posts: 774
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,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
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

Joined: Oct 13, 2009
Posts: 774
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

Joined: Jun 25, 2001
Posts: 16065
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
ELFlash worked, thanks
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 774
Yes, but remember it won't work for an Ajax request.

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

HTH,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing Params