Archive

Posts Tagged ‘Jboss Seam’

How to read values from properties file in JBoss Seam

April 11, 2009 Leave a comment
Let us assume we have two properties files namely  messages.properties and application.properties

In components.xml we place the below line

<core:resource-loader bundle-names=”messages application”/>

Then in the Seam component where we want to retrieve the value for a given property (key), we inject the ResourceBundle as below.

   @In
    java.util.ResourceBundle resourceBundle;

The retrieval is done as below

String imagesLocation = resourceBundle.getString(“IMAGESLOCATION”);
Categories: Jboss Seam Tags:

Navigation in Seam/JSF

April 8, 2009 Leave a comment

 <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!

Categories: Jboss Seam Tags: ,

No phase id bound to current thread (make sure you do not have two SeamPhaseListener

April 8, 2009 Leave a comment

This error occurs if you have two jboss-seam-*.jar in the deploy folder of the jboss. Please make sure to have only on jboss seam related jars.

Categories: Jboss Seam Tags: