|
|
Best Practice
CMS Integration... Deep LinkingIn order to integrate deep linking in your wingS application you can use an SRequestListener. Assuming that your wingS session should look for a parameter named id and call a class method named loadId if the parameter exists and represents an int the code handling a URL similar to http://example.com/?id=23 could look like this:
import org.wings.event.SRequestEvent;
import org.wings.event.SRequestListener;
import org.wings.session.SessionManager;
SessionManager.getSession().addRequestListener(new SRequestListener() {
public void processRequest(SRequestEvent re) {
if (re.getType() == SRequestEvent.DISPATCH_START)
if (SessionManager.getSession().getServletRequest().getParameter("id") != null) {
try {
int idNo = Integer.parseInt(SessionManager.getSession().getServletRequest().getParameter("id"));
loadId(idNo);
} catch (NumberFormatException ex) { }
}
}
});
It is important to know that changing the session state is allowed in the event dispatching phase only, in the above example --Szymon Polom 04-Dec-2007 23:05 CET |
|
All contents copyright of the author. ©2007. JAMWiki Version 0.5.3 |
|