[jboss-user] [JBoss Seam] - Re: How to return to a previous page without conversations

christian.bauer@jboss.com do-not-reply at jboss.com
Fri Apr 6 12:18:58 EDT 2007


- User viewing a contact page 

This view.xhtml page needs a page action, e.g. #{myViewer.rememberThis}. In the rememberThis() method you can get the "redirect" component from Seam and call captureCurrentRequest()/captureCurrentView().

- User clicks "Add Note" 

This needs to be a call to the "view.xhtml" page, e.g. <s:link action="addNote"/>. In your pages.xml you can then have a navigation rule like this:


  |     <page view-id="/view.xhtml" action="#{myViewer.rememberThis}">
  | 
  |         <navigation>
  |             <rule if-outcome="addNote">
  |                 <begin-conversation flush-mode="MANUAL"/>
  |                 <redirect view-id="/noteEditor.xhtml"/>
  |             </rule>
  | 

The rememberThis() runs again and remembers the "entry point" for your long running conversation. Which is what <begin-conversation> does, it promotes the temporary conversation to a long-running conversation. The "redirect" component is carried on in that same conversation.

- New page and user enters a note 

This is a conversational flow, so you stay inside the long running conversation on the /noteEditor.xhtml screen (during validation errors, etc.)

- User clicks save, note saved and contact page reshown 

You can get out of your long running conversation by first ending it, and then redirecting to the last remembered location in the "redirect" component. This code could be in your NoteEditor.java bean as the exit code after save (or mapped to the Cancel button in the UI):


  | 
  |     public void exitConversation() {
  |         Conversation currentConversation = Conversation.instance();
  |         Redirect redirect = (Redirect)Component.getInstance("redirect");
  |         currentConversation.end();
  |         // Have a chance here to modify the redirect.setParameters() for the following GET, e.g.
  |         // strip off the action=(addNote) parameter which would lead me into a circle
  |         redirect.returnToCapturedView();
  |     }
  | 
  | 

Yes, this is not ideal and we are currently working on a better concept that involves "entry points". Not sure yet how that will exactly look like in code and pages.xml. You also have the case of nested conversations, where you want to exit to the last view shown in the parent conversation. Or a root conversation that was started from another root conversation.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035386#4035386

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035386



More information about the jboss-user mailing list