-
1. Re: How to return to a previous page without conversations
fhh Apr 6, 2007 11:13 AM (in response to chane)Simply annotate the action method behind the return button with @End.
Regards
Felix -
2. Re: How to return to a previous page without conversations
chane Apr 6, 2007 11:30 AM (in response to chane)Thanks for the reply.
Although, I'm going to say I don't understand how that will help return to a previous page.
Isn't @End for transaction control. How can I use end on the "return" action method to navigate back to a previous page?
Do you know if there is an example in the Seam distribution that does this? I'm walking through them right now to see....
Thanks,
Chris.... -
3. Re: How to return to a previous page without conversations
fhh Apr 6, 2007 11:58 AM (in response to chane)Use faces-navigation.
Regards
Felix -
4. Re: How to return to a previous page without conversations
christian.bauer Apr 6, 2007 12:18 PM (in response to chane)- 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. -
5. Re: How to return to a previous page without conversations
christian.bauer Apr 6, 2007 12:21 PM (in response to chane)BTW, the /examples/wiki in Seam CVS is what I'm currently working on with these concepts. It's very alpha but the navigation works almost as I want it to work. We'll take these learned lessons into Seam in some way.
-
6. Re: How to return to a previous page without conversations
chane Apr 6, 2007 12:36 PM (in response to chane)Christian,
Thanks for the reply, very helpful.
I will check out the example also.
One idea: Trinidad has a concept of pageFlowScope (http://incubator.apache.org/adffaces/devguide/communicatingBetweenPages.html)
I'm not sure if I want to use this or not; however, in the document they use an action listener to communicate. Right now I use pages.xml very sparingly (that might change though) and the action listener instead of a page action might be something I try and explore over the next couple of days. Their example is:<h:dataTable var="employee" value="#{....}"> ... <h:column> <h:outputText value="#{employee.name}"/> <h:column> <h:column> <h:outputText value="#{employee.id}"/> <h:column> <h:column> <h:commandButton value="Show more" action="showEmployee"> <tr:setActionListener from="#{employee}" to="#{pageFlowScope.employeeDetail}"/> </h:commandButton> <h:column> </h:dataTable>
Looking forward to seeing entry points in Seam (realizing it will take a while to get in...)
Thanks again,
Chris.... -
7. Re: How to return to a previous page without conversations
christian.bauer Apr 6, 2007 1:24 PM (in response to chane)That sounds pretty much like the Seam Conversation scope, although much narrower and more focused on a particular use case. You can use the same examples and put it in Conversation scope - and then handle conversation propagation independently in your navigation rules.
We have a quite complete model and the machinery for all of this already, what we need in Seam is the notion of entry points of conversations and the ability to return to that entry point at the end of a conversation or for a particular outcome during the conversation.
Right now there are several disjunct facilities in Seam for this (the Redirect component covers half of these cases, Conversation.redirect() can return you to the last view of the parent conversation from a nested conversation) that need to be unified, extended, and tied into the metadata.
So right now I do the polymorphic "exit a conversation correctly, no matter if it's nested or a root conversation" manually:public void exitConversation(Boolean endBeforeRedirect) { Conversation currentConversation = Conversation.instance(); if (currentConversation.isNested()) { // End this nested conversation and return to last rendered view-id of parent currentConversation.endAndRedirect(endBeforeRedirect); } else { // Always end this conversation currentConversation.end(); ConversationEntry entryPoint = (ConversationEntry)Contexts.getConversationContext().get("conversationEntryPoint"); if (entryPoint != null) { // We came here from another conversation if (entryPoint.isDisplayable()) { entryPoint.switchConversation(); } else { // The entry point is gone... What now? Go to start page... Manager.instance().redirect("/display.xhtml", new HashMap<String,Object>(), true); } } else { // We came here from a non-conversational page if (endBeforeRedirect) redirectToLastBrowsedPage(); else redirectToLastBrowsedPageWithConversation(); } } }
I have to remember my entry points manually and return to them, see "conversationEntryPoint" and the mysterious redirectTo*() methods that do what I described earlier. -
8. Re: How to return to a previous page without conversations
fhh Apr 7, 2007 9:32 AM (in response to chane)Isn't this all a bit overkill for the current use case? To add notes to a certain contact using the standard faces navigation with Seam's conversations seems absolutely sufficient to me.
Am I mssing something?
Regards
Felix -
9. Re: How to return to a previous page without conversations
christian.bauer Apr 7, 2007 9:54 AM (in response to chane)No, a simple navigation case would be fine if you just want to go from note browser to note editor and back. But often you don't have a note browser, but don't even know where the user is coming from when a particular conversational editor is opened. I'd argue that this is even the common case with any nontrivial webapp.
-
10. Re: How to return to a previous page without conversations
pmuir Apr 7, 2007 2:50 PM (in response to chane)+1 on this :)
-
11. Re: How to return to a previous page without conversations
waynebagguley Apr 8, 2007 4:44 AM (in response to chane)Along with the new entry-point concept, will you be adding something to prevent a user from jumping to a page out of sequence?
Currently I can easily skip to a page as long as I put the conversation id in the URL, I then get a useless page but I fear that this might lead to security holes.
It seems at the moment that pages, page flow and conversations are loosely coupled and there are myriad ways of specifying the same behaviour. This is flexible in one sense but doesn't allow for limitations to be easily imposed on the user.
I'd like to see something like this:<conversation id=placeOrder"> <page id="pageOne"/> <page id="pageTwo" back="pageOne"/> <page id="pageThree" back="pageOne,pageTwo"/> </conversation>
Given that conversations are central to Seam it seems strange that you can't organise a conversation like this where back and forward movement is restricted. -
12. Re: How to return to a previous page without conversations
christian.bauer Apr 8, 2007 6:18 AM (in response to chane)Use jBPM pageflows in Seam if you want a statemachine controlling the navigation flow and preventing users from making illegal transitions. The concept of entry/exit points also needs to be added to this model though.
-
13. Re: How to return to a previous page without conversations
spambob Apr 8, 2007 6:41 AM (in response to chane)"christian.bauer@jboss.com" wrote:
...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...
Do you know if this will make it into 1.3 (which hopefully will be availabe a short time after AS 4.2GA)? Or if not can you give me please a raw guess on the ETA? -
14. Re: How to return to a previous page without conversations
christian.bauer Apr 8, 2007 6:56 AM (in response to chane)No idea when this will be available and in what form.