[jboss-user] [JBoss Seam] - Request for feedback

gavin.king@jboss.com do-not-reply at jboss.com
Sun Dec 17 07:05:44 EST 2006


So I finally got fed up with the limitations of JSF navigation rules and I went ahead and implemented a stateless navigation system for Seam. There were four main reasons why I wanted this:

(1) to centralize orchestration in one place, instead of having it split between pages.xml and faces-config.xml

(2) to be able to specify request parameters when redirecting

(3) to be able to specify conversation begin/end according to an outcome

(4) to be able to have a value binding which evaluates the outcome, in addition to the action method binding - this lets me get rid of the ugly outcomes returned by action methods, and reduces the coupling of the model to the view.

(5) to support various "result types", other than a JSF view (eg. a file download, a http error, etc).


What I have today can do what you can do with JSF navigation rules, for example:

<page view-id="/getDocument.jsp">
  |     <navigation>
  |         <outcome value="success">
  |             <redirect view-id="/editDocument.jsp"/>
  |         </outcome>
  |         <outcome value="not-found">
  |             <redirect view-id="/404.jsp"/>
  |         </outcome>
  |     </navigation>
  | </page>

Is equivalent to:

<navigation-rule>
  |     <from-view-id>/getDocument.jsp</from-view-id>
  |     <navigation-case>
  |         <from-outcome>success</from-outcome>
  |         <to-view-id>/editDocument.jsp"</to-view-id>
  |         <redirect/>
  |     </navigation-case>
  |     <navigation-case>
  |         <from-outcome>not-found</from-outcome>
  |         <to-view-id>/404.jsp"</to-view-id>
  |         <redirect/>
  |     </navigation-case>
  | </navigation-rule>

And:

<page view-id="*">
  |     <navigation action="#{documentHome.get}">
  |         <outcome value="success">
  |             <render view-id="/editDocument.jsp"/>
  |         </outcome>
  |     </navigation>
  | </page>

Is equivalent to:

<navigation-rule>
  |     <navigation-case>
  |         <from-action>#{documentHome.get}</from-action>
  |         <from-outcome>success</from-outcome>
  |         <to-view-id>/editDocument.jsp"</to-view-id>
  |     </navigation-case>
  | </navigation-rule>


But it can also do this:

<page view-id="/getDocument.jsp">
  |     <navigation outcome="#{documentHome.document!=null}">
  |         <outcome value="true">
  |             <redirect view-id="/editDocument.jsp"/>
  |         </outcome>
  |         <outcome value="false">
  |             <redirect view-id="/404.jsp"/>
  |         </outcome>
  |     </navigation>
  | </page>

This lets you write a DocumentHome.get() method with a void return type! This is much more transparent to the model.

You can also do this:

<page view-id="/editDocument.jsp">
  |     <navigation action="#{documentHome.update}">
  |         <null-outcome>
  |             <redirect view-id="/document.jsp">
  |                 <param name="documentId" value="#{documentHome.document.id}"/>
  |             </redirect>
  |         </null-outcome>
  |     </navigation>
  | </page>

(Yay!)

Soon I'll also add <begin-conversation/> and <end-conversation/> to the case handling. Eventually I'll also add support for other things in addition to  and .

OK, so, what I need feedback on is the actual XML format. What I have there today is a little less verbose than the JSF XML, but has one higher level of indentation (which makes it more complex). The reason for this is that I want to allow different actions to specify different outcome expressions, and different lists of cases, eg:


<page view-id="/getDocument.jsp">
  | 
  |     <navigation action="#{documentHome.get}" 
  |                outcome="#{documentHome.document!=null}">
  |         <outcome value="true">
  |             <redirect view-id="/editDocument.jsp">
  |                 <param name="documentId" value="#{documentHome.document.id}"/>
  |             </redirect>
  |         </outcome>
  |         <outcome value="false">
  |             <redirect view-id="/404.jsp"/>
  |         </outcome>
  |     </navigation>
  |     
  |     <navigation action="#{logout.logout}">
  |         <null-outcome>
  |             <redirect view-id="/login.jsp"/>
  |         <null-outcome>
  |     </navigation>
  |     
  | </page>


So the question is should I go for something more similar to the JSF XML (one less level of nesting):

<page view-id="/getDocument.jsp">
  | 
  |     <navigation action="#{documentHome.get}"> 
  |         <outcome expression="#{documentHome.document!=null}"
  |                       value="true"/>
  |         <redirect view-id="/editDocument.jsp">
  |             <param name="documentId" value="#{documentHome.document.id}"/>
  |         </redirect>
  |     </navigation>
  |     
  |     <navigation action="#{documentHome.get}">
  |         <outcome expression="#{documentHome.document==null}"
  |                       value="true"/>
  |         <redirect view-id="/404.jsp"/>
  |     </navigation>
  |     
  |     <navigation action="#{logout.logout}">
  |         <redirect view-id="/login.jsp"/>
  |     </navigation>
  |     
  | </page>


Or does it make it easier to learn if we stay even more like standard JSF:


<page view-id="/getDocument.jsp">
  | 
  |     <navigation> 
  |         <from-action>#{documentHome.get}</from-action>
  |         <outcome-expression>#{documentHome.document!=null}</outcome-expression>
  |         <from-outcome>true</from-outcome>
  |         <redirect>
  |             <to-view-id>/editDocument.jsp</to-view-id>
  |             <param name="documentId" value="#{documentHome.document.id}"/>
  |         </redirect>
  |     </navigation>
  |     
  |     <navigation>
  |         <from-action>#{documentHome.get}</from-action>
  |         <outcome-expression>#{documentHome.document==null}</outcome-expression>
  |         <from-outcome>true</from-outcome>
  |         <redirect> 
  |             <to-view-id>/404.jsp"</to-view-id>
  |         </redirect>
  |     </navigation>
  |     
  |     <navigation action="#{logout.logout}">
  |         <redirect>
  |             <to-view-id>/login.jsp"</to-view-id>
  |     </navigation>
  |     
  | </page>

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

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



More information about the jboss-user mailing list