Home > Jboss Seam > Navigation in Seam/JSF

Navigation in Seam/JSF

 <navigation>

Seam also allows you to specify navigation rules in pages.xml. This can be more convenient than specifying navigation in the typical JSF way.

Take the following JSF navigation rule, for example:

    <navigation-rule>
        <from-view-id>/pagewithlink.xhtml</from-view-id>  (1)
        <navigation-case>
            <from-outcome>first</from-outcome>            (2)
            <to-view-id>/first.xhtml</to-view-id>         (3)
            <redirect/>                                   (4)
        </navigation-case>
    </navigation-rule>
  1. The view id of the page that produces the outcome.
  2. The outcome id.
  3. The destination view.
  4. Optional redirect tag for redirect after post

Using Seam, this can be represented in pages.xml as:

  <page view-id="/pagewithlink.xhtml">       (1)
    <navigation>
      <rule if-outcome="first">              (2)
        <redirect view-id="/first.xhtml"/>   (3)
      </rule>
    </navigation>
  </page>
  1. The view id of the page that produces the outcome.
  2. The outcome id is specified using <rule if-outcome="...">.
  3. The destination is a redirect element in this case.

Not only is this more compact than the JSF way, it is also possible to eliminate the outcome strings from the application and replace them with EL expressions using <rule if="... EL expr"> syntax:

  <page view-id="/pagewithlink.xhtml">       (1)
    <navigation>
      <rule if="#{theSfsb.goodToGo}">        (2)
        <redirect view-id="/first.xhtml"/>   (3)
      </rule>
    </navigation>
  </page>
  1. The view id of the page that produces the outcome.
  2. Instead of specifying an outcome string, we use an EL expression to invoke a method on a SFSB which will return a boolean.
  3. The destination is the same  redirect element

No more nasty outcome strings in the EJB!

Advertisements
Categories: Jboss Seam Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: