The purpose of this post is to describe how you can redirect a user to a specific landing page within a JBoss Portal application. The jboss-service.xml file in your JBOSS_HOME/server/default/deploy/jboss-portal.sar/META-INF directory contains the managed bean definitions and registration of the beans that are used. There is one entry that is of importance to accomplish the redirect, which is the DeafultPortalCommandFactory. This factory is called when every request for your portal is made. Its main objective is to check what the next command is, and if it does not have one, it will render/return the default portal page in your -object.xml.
To change this behavior you can extend the org.jboss.portal.core.model.portal.DeafultPortalCommandFactory class and override the doMapping() method to invoke the desired redirect (which can be a redirect to another portlet other than the default or an entirely different portal). You may want to stick a flag in the session to notate that the session has been redirected to avoid a redirect loop. Below is the doMapping() method
of com.demo.NewDefaultPortalCommandFactory.java.
Then just package your new class as a JBoss component (.sar file) and register it within the jboss-service.xml. Your new JBoss component will have a packaging structure similar to the one below.
new-portal.sar/
com.demo.NewDefaultPortalCommandFactoryMETA-INF/jboss-service.xmlYou will need to define your new DefaultPortalCommandFactory within the jboss-service.xml inside your portal.sar.
Finally, you simply need to comment out (or modify) the registration of the DefaultPortal and add an entry your new Command Factory in the jboss-service.xml file in the jboss-portal.sar/META-INF.
No comments:
Post a Comment