Modularising pages.xml for a Seam Application

Posted on Friday, February 19, 2010

0


If you are developing an enterprise application with Seam then chances are that you would end up with a huge pages.xml file. Fortunately seam gives you an easy way to modularise it.

The easy way is to split your existing pages.xml into smaller sub.pages.xml depending on the functionality/modules and then include the following in the components.xml file


xmlns="http://jboss.com/products/seam/components" xmlns:core="http://jboss.com/products/seam/core" xmlns:persistence="http://jboss.com/products/seam/persistence" xmlns:transaction="http://jboss.com/products/seam/transaction" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://jboss.com/products/seam/security"> xmlns:navigation="http://jboss.com/products/seam/navigation"
	xsi:schemaLocation="http://jboss.com/products/seam/core
               http://jboss.com/products/seam/core-2.0.xsd
               http://jboss.com/products/seam/transaction
               http://jboss.com/products/seam/transaction-2.0.xsd
               http://jboss.com/products/seam/persistence
               http://jboss.com/products/seam/persistence-2.0.xsd
               http://jboss.com/products/seam/security
               http://jboss.com/products/seam/security-2.2.xsd
               http://jboss.com/products/seam/components
    		   http://jboss.com/products/seam/components-2.2.xsd
    		  http://jboss.com/products/seam/navigation-2.0.xsd">
	<core:init debug="true"></core:init>
	<core:manager conversation-timeout="120000"></core:manager>
	<persistence:entity-manager-factory name="helloworld"></persistence:entity-manager-factory>
	<persistence:managed-persistence-context name="em" auto-create="true" entity-manager-factory="#{helloworld}">
        </persistence:managed-persistence-context>
	<security:identity authenticate-method="#{authenticator.authenticate}"></security:identity>
	<event type="org.jboss.seam.security.notLoggedIn">
		<action execute="#{redirect.captureCurrentView}"></action>
	</event>
	<event type="org.jboss.seam.security.postAuthenticate">
		<action execute="#{redirect.returnToCapturedView}"></action>
	</event>
	<navigation:pages>
		<navigation:resources>
			<value>/WEB-INF/pages.xml</value>
			<value>/WEB-INF/search.pages.xml</value>
		</navigation:resources>
	</navigation:pages>
</components>

Note all the portions in bold.

Advertisements
Posted in: Better Software, Java