OK, so the whole mechanism does work correctly, but only if the stale
session occurs when the user is accessing an ExternalLink.  In that
case, storing the serviceParameters in the ExternalCallback is
sufficient for getting good values to deal with during
activateExternalPage().  Unfortunately, it is inevitably possilbe to
get a stale session when clicking non-external links, such as table
colum sorts or page changes, etc.  My solution was to include a
special parameter on all ExternalLinks, which I check for in the
activate code.  If I don't find the special parameter, I assume I am
not in an ExternalLink call, so I handle it via some other default
mechanism.  If the page doesn't absolutely require certain parameters,
then I just let the page load, but if it does, the page has to provide
an alternative location to redirect to.  It works, but required some
significant changes to my BasePage class in order to provide
overridable methods in all my pages.  I'm just posting this here so
that it is findable in the web archives for the next person to stumble
across it.

--sam


On 6/20/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
Nope, same problem from within validate() instead of pageValidate(),
so the javadoc for ExternalCallback appears to be just plain old
incorrect.  Bummer.

--sam


On 6/20/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
> Judging by the javadoc example in ExternalCallback, if I overlod the
> validate() method instead of implementig pageValidateListener, I will
> be able to do what i need to do.  Is there any reason not to do this,
> since validate() doesn't appear to actually be deprecated?
>
> --sam
>
>
> On 6/20/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
> > So the entire ExternalCallback/ExternalPage thing is actually entirely
> > worthless when it comes to handling something like remembering where
> > they were going when they failed to authenticate?  That seems odd,
> > especially since it is called out as being suitable for exactly that
> > in the tapestry pdf book.  How are people doing form based
> > authentication or is everyone just going to some default page after
> > logging in?  It seems odd to me that validate() would be called out as
> > an adequate place to do authentication/authorization and yet provide
> > no way to discover what would have happened if validation succeeded.
> >
> > Incidentally, how would one execute a listener arbitrarily from
> > somewhere? I can see a way to do what I want by using the
> > ServletRequest directly, but I'd have to be able to call the listener
> > myself.
> >
> > --sam
> >
> >
> > On 6/20/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> > > Not a fun circumstance I'm sure. It's still probably better than getting
> > > NPE's.
> > >
> > > At the point when your pageValidate() method is called I'm not sure if you
> > > are in the right "state" to even bother looking for the parameters this 
way.
> > > The majority of requests in Tapestry end up going through the 
DirectService.
> > > 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/engine/DirectService.java?view=markup
> > >
> > > There are two very distinct states that things can be in within this
> > > service..Form submissions / listener method invocations is one, page 
renders
> > > are another. If you look at the source of the supplied link you will find
> > > that it is very probably that your listener parameters have not even been
> > > set yet.
> > >
> > > Someone else was working on this Callback interface for things. Who was 
it ?
> > > Scott Russel / Ron Piterman ? I can't tell anymore, there are always so 
many
> > > hidden libraries these days.
> > >
> > > On 6/20/06, Sam Gendler <[EMAIL PROTECTED]> wrote:
> > > >
> > > > I am trying to build an ExternalCallback during my validate method, in
> > > > order to return to the same place I was trying to reach when my
> > > > session expired.  I click on a link which includes query string
> > > > parameters courtesy of the parameter included in my listener and the
> > > > validate() method fails to authorize the anonymous user, so it builds
> > > > an ExternalCallback with parameters cycle.getListenerParameters() as
> > > > the array of params, which is always null.  The same thing occurs when
> > > > accessing getServiceParameters().
> > > >
> > > > So, the brief form of the code looks like this:
> > > >
> > > > public class MyPage
> > > >     extends BasePage
> > > >     implements IExternalPage, PageValidateListener
> > > > {
> > > >     public void pageValidate(PageEvent event)
> > > >     {
> > > >         if (notLoggedIn()) {
> > > >             LoginPage page = getLoginPage();
> > > >             page.setNextPage(new ExternalCallback(event.getPage(),
> > > > event.getRequestCycle().getServiceParameters());
> > > >             throw new PageRedirectException(page);
> > > >         }
> > > >     }
> > > >
> > > >     public void activateExternalPage(Object[] parameters, IRequestCycle
> > > > cycle) {
> > > >         cycle.setListenerParameters(parameters);
> > > >         log.debug("set listenerParams: " + parameters);
> > > >     }
> > > >
> > > >     public IPage sampleListener(int someParameter) {
> > > >        IPage somePage = getSomePage();
> > > >         // do some work
> > > >         return somePage;
> > > >     }
> > > > }
> > > >
> > > > So, basically, I can't figure out how to get the parameters AND I
> > > > cannot figure out how I would cause the listener to be called after
> > > > the redirect.
> > > >
> > > > Any thoughts?
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tacos/Tapestry, team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind.
> > >
> > >
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to