You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by "Adkinson, Sean" <SA...@kcdistancelearning.com> on 2008/10/01 00:41:36 UTC

SharedFlowControllers can't access the session in non-action methods

Hey there,

 

We have recently started utilizing shared flow controllers for session
getters that used to be in inherited controllers.  The reason for this
was to abstract out our inherited controllers in order to be used across
multiple applications in a common code sort of way, but still have a
central location for accessing certain session values.

 

However, it doesn't appear as if you can access the session in a
SharedFlowController when you haven't come in through an action, since
setPerRequestState is never called in FlowController in this case.
Would it be appropriate to call setPerRequestState for each
SharedFlowController whenever setPerRequestState is called?

 

Here are snippets of what I am doing:

 

 

@Jpf.Controller(...)

public class UtilityController extends SharedFlowController

{

 

public Integer getOrganizationId()

{

return
(Integer)getSession().getAttribute(SessionConstants.ORGANIZATION_ID);

}

 

}

 

 

@Jpf.Controller(

      ...

sharedFlowRefs = { @Jpf.SharedFlowRef(name = "utilityController", type =
UtilityController.class) }

)

public class LoginController extends PageFlowController

{

 

@Jpf.SharedFlowField(name = "utilityController")

private UtilityController utilityController;

 

 

protected final synchronized void beforeAction() throws Exception

{

      //fail here

      System.out.println("Organization ID: " +
utilityController.getOrganizationId());

}

}

 

 

When getOrganizationId() lived in an inherited controller, the method
worked fine, since setPerRequestState() had been called for this
controller.  If the code were changed to call setPerRequestState() for
each of the shared controllers when it called was called for the current
controller, this looks like it would work just fine.

 

Any thoughts or suggestions?  Thanks for you help!  

 

 

Sean Adkinson  |  Web Developer/Programmer  |  KCDL  |
sadkinson@klcorp.com  |  (503) 731-5488  |  (503) 866-0852 cell