• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in passing parameters in navigation  RSS feed

 
Priti Shah
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one settings page on which I have submit button which executes bean's method when pressed. Now this method returns 'success' or 'failure' outcome. In either case request navigates to main.jsp page (navigation rule is specified in faces-config.xml). But my problem is that based on the outcome I want to show success or failure message in header of main.jsp.

I tried following things :

I tried to set requestparameter in my bean's method but it throws UnsupportedOperation exception.

I can set it in session e.g. session.set('message', message) and then retrieve message on main.jsp but
but I have many such pages and user can navigate to any page any time. so if I retrieve session variable (message) on each main page it will return me last set message which is not proper.

I also tried to specify navigation rules something like this

<navigation-rule>
<navigation-case id="ctrlSettings">
<from-view-id> ControllerSettings.jsp</from-view-id>
<to-view-id>/ControllerTabs.jsp?message={#controllerSettings.message}</to-view-id>
</navigation-case>
</navigation-rule>

where controllerSettings is my bean defined in faces-config.xml and it has one private property message. and then I retrieve message on my main.jsp using {#param.message} but this also doesnot work.

Does any one has any suggestion ? Should I just use requestdispatcher in my bean's method?

Thanks
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No hard answer for you.

1) Set a message in JSF's standard message system. You'll have to make sure you don't actually redirect the browser, but the message should show up on the main.jsp page (with the <h:messages/> tag)

2) Try facesContext.getExternalContext().getRequestMap().set("message", message); Then pull that in your page. Same deal with the redirect. However, that's essentially the same as #1, so you might as well use JSF's standard message facility.

If you want a redirect, I'm not sure. I don't know that you want to get into trying to pass stuff on the query string. I've had some growing pains with JSF myself. I'm personally a big fan of redirect. Mainly because the user can then get away with browser refresh. However, browser back and refresh are frowned upon in the JSF world, so I'm not sure it matters.

Now that I think about it, I'm going to make a post on that topic when I'm done with this.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!