2 Replies Latest reply on Apr 20, 2011 5:16 AM by georges.goebel

    seam 3 and jsf navigation (pages.xml)

    georges.goebel

      Hi,


      I have some applications using seam 2 and jsf frameworks (mainly icefaces)
      I took a look at seam3 and jsf2 and have some difficulties to get a proper navigation to work. In seam2/pages.xml I could have my actions which are referenced in the commandButton have a void return argument. I prefer having as less as possible navigation logic in my beans. So I do not want to return the view id in a save method.
      In seam2 that was fine because the whole navigation and security logic was in my pages.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <pages xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd"
             login-view-id="/login.xhtml">
      
          <page view-id="/login.xhtml">
              <navigation>
                  <rule if="#{identity.loggedIn}">
                      <redirect view-id="/main.seam"/>
                  </rule>
              </navigation>
          </page>
      
          <page view-id="/modifyVehicule.xhtml" login-required="true">
              <begin-conversation join="true"/>
      
              <navigation from-action="#{modifyVehicule.endActionSaveVehicule}">
                  <redirect view-id="/main.xhtml"/>
              </navigation>
              <navigation from-action="#{modifyVehicule.endActionCancel}">
                  <redirect view-id="/main.xhtml"/>
              </navigation>
          </page>
      



      I tried a simple example in seam3 with the navigation rules in the faces-config.xml, but it does not work as expected.
      For example :


      The following rule works only if the return type of the create method is a String. The value of the return value is not important.


      <navigation-rule>
              <from-view-id>/add.xhtml</from-view-id>
              <navigation-case>
                  <from-action>#{vehiculeBean.create}</from-action>
                  <to-view-id>/view.xhtml</to-view-id>
                  <redirect/>
              </navigation-case>
          </navigation-rule>
      



      Is it possible to achieve the same behavior of the old seam2/pages.xml with seam3 ?


      I checked out the faces module and saw something with the @ViewConfig but I do not know if this would solve my problem.


      Thanks for all suggestions


      Regards


      Georges Goebel

        • 1. Re: seam 3 and jsf navigation (pages.xml)
          bleathem

          One of the goals with Seam 3 is to carry on with the idea of the type-safe programming model that CDI began.  As much as possible, we would like to apply this idea of type-safety to application configuration as well.  As such we've introduced the @ViewConfig type safe view configuration in Seam Faces.  It would be using this configuration that we could support the behaviour you are describing.


          Can you (or anyone else for that matter) come up with a way of referring to the from-action in a type-safe way?  Maybe an annotation on the method or something similar?


          Any thoughts or input on this would be much appreciated.

          • 2. Re: seam 3 and jsf navigation (pages.xml)
            georges.goebel

            Hi


            I think this would be a good start
            http://seamframework.org/Community/PageActionInViewConfig


            There is still the rule element in pages.xml which should also be possible in the @ViewConfig


            Glad I am not alone with this feature/problem :-)


            Regards


            Georges