• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing and retrieving query string values in jsf

 
Sathish Ankat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing same problem..:-(
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 .
 
Sathish Ankat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your can get query string in java bean by following code

 
Avik Mazunder
Ranch Hand
Posts: 39
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can redirect and pass the query string from the javabean as follows

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic