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

Passing and retrieving query string values in jsf

Sathish Ankat
Greenhorn

Joined: Jan 01, 2013
Posts: 2
I am new to JSF framework and I am stuck with some doubts.I need to pass and retrieve some parameters using query string from "http://www.domain.com/project/jsps/register.jsp", on button click, I am entering the data in to database and if any error occurs, I am returning "error" String. My plan is to pass different error codes for different errors.

<navigation-rule>
<from-view-id>/jsps/register.jsp</from-view-id>
<navigation-case>
<from-outcome>error1</from-outcome>
<to-view-id>/jsps/error.jsp?code=1</to-view-id>
</navigation-case><navigation-case>
<from-outcome>error2</from-outcome>
<to-view-id>/jsps/error.jsp?code=2</to-view-id>
</navigation-case>
</navigation-rule>

Is it the exact way to pass parameters as query String?
Again in my error.jsp, I need to access the error codes and display the corresponding errors.
http://domain.com/project/jsps/error.jsp?code=1 should show like,
"An Error occurred..(error corresponding to the code)"
In the managed bean of error.jsp I need the check against each error codes and then display the corresponding error in error.jsp
I am using JSF 1.2 Thanks in advance..
Divyesh Shani
Greenhorn

Joined: Jan 01, 2013
Posts: 1
I am facing same problem..:-(
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

"JavaKing Developer",

We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see
http://www.javaranch.com/name.jsp .

Customer surveys are for companies who didn't pay proper attention to begin with.
Sathish Ankat
Greenhorn

Joined: Jan 01, 2013
Posts: 2
Wats in a name! Any ways I have made request to change the display name :-) Please somebody help me find a solution to my problem.

@Divyesh Shani : do inform me if a find the soln :-)
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

your can get query string in java bean by following code

Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

you can redirect and pass the query string from the javabean as follows

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16058
    
  21

What's in a name? Well, I think we explained why we require real names in our FAQ. We're not doing it just to be pompous and obnoxious. Besides, I do pompous and obnoxious for free.

JSF is considerably different from most web frameworks. One of those differences is that most operations are done using HTTP form POST operations, not GET requests. Also, the POST may be done multiple times (postback). So passing parameters in via a URL has limited utility. It can get you into a page edit, but once you start working with that page, subsequent operations will be managed via POST.

In JSF version 1, getting the GET parameters did require brute-force access via the FacesContext, but JSF version 2 has some extra View Template tags that can make the job easier. There's also PrettyFaces, which is a third-party add-on that can handle not only parameters, but also alternative URL forms such as "Target/id=1234" or even "Target/1234". This is extremely handy for making "bookmarkable" URLs, since you can't "bookmark" HTTP POSTs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing and retrieving query string values in jsf