Saturday, June 26, 2010

Bit #21 - Overriding prepareSession() to do session-specific initializations

You can override prepareSession() in your custom Application Module class to do session-specific initializations, such as invoking a stored procedure to initialize the database state for the specific user, store user information, set application-wide configuration parameters based on the user and so on. The framework invokes prepareSession() when the Application Module is first checked-out from the Application Module pool for a new user session.

Example:

     @Override
     protected void prepareSession(Session session) {


          super.prepareSession(session);

         // do session-specific initializations
     }


Context:

Application Module Implementation Class

1 comment:

  1. Hi Nick
    In my case my custom appmodule's preparesession doesnt get called even though i have super called.
    i have a debug statement in the customappmodule.preparesession method, and this custom class extends my custom framework.appmodule class, and my customframeworkappmodule class extends ApplicationModule.
    having said that, another appmodule(e.g. xyzappmodule) gets its preparesession method called.
    the only difference between the one that gets called and mine is, the other one gets loaded in the initial spalsh page after logging in, and mine has to be clicked on a menuitem.
    can i know why this happens?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...