You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Huhn <am...@insightbb.com> on 2007/11/24 20:37:04 UTC

T5: onActivate woes

Hello,

I'm having a problem with onActivate().  Here are my questions:
1) Why is onActivate() called when a context variable is included in the
URL?
2) Is there a way to prevent onActivate() from being called until AFTER
onActivate(Integer prmPrimaryKey) is called?

Here's my dilemma: I want to use one detail page to handle inserts and
updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
to initialize the page for an update; and another onActivate() handler
to initialize the page for an insert.

Each onActivate() handler checks to see if the user is allowed to access
this page.  If the user is not allowed to access, the onActivate()
handler generates a Link with the current page's context, uses that Link
to set a Session state variable, and then returns a Login page.  Once
the user logs in, the Session state variable is checked to see if it has
been set; if so, the user is taken back to that page.

My problem is that when the page is accessed with a context variable
(thus, to handle an UPDATE), onActivate() is being called before
onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
isn't being set before the Link is generated and added to the session
state.

The Link that is being generated, then, doesn't have any context
included, so when the user finishes logging in, the user is taken back
to the page, with no context.

Is this a Tapestry bug, or is there a better way of handling this?

Thanks,
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: onActivate woes

Posted by Howard Lewis Ship <hl...@gmail.com>.
Please add to JIRA.

On Nov 24, 2007 9:09 PM, Andy Huhn <am...@insightbb.com> wrote:
> Hi Howard,
>
> I am on 5.0.6.  The behavior you described here is what I expected to
> see (I have onActivate() with one parameter, and onActivate() with 0
> parameters, and I expected to see onActivate() with one parameter
> executed first...but that was not the case).
>
> Should I file a JIRA?  It sounds like this is the expected behavior.
>
> Thanks,
> Andy
>
>
> On Sat, 2007-11-24 at 17:00 -0800, Howard Lewis Ship wrote:
> > You are using 5.0.5?  I believe 5.0.6 has a fix for this, wherein the
> > method invocation order is by number of parameters, decreasing.
> >
> > You may have to do:
> >
> > Object onActivate(Object[] context)
> > {
> >  ...
> > }
> >
> > And check the context count explicitly, and convert the context values
> > explicitly, if you are on 5.0.5.
> >
> > On Nov 24, 2007 11:37 AM, Andy Huhn <am...@insightbb.com> wrote:
> > > Hello,
> > >
> > > I'm having a problem with onActivate().  Here are my questions:
> > > 1) Why is onActivate() called when a context variable is included in the
> > > URL?
> > > 2) Is there a way to prevent onActivate() from being called until AFTER
> > > onActivate(Integer prmPrimaryKey) is called?
> > >
> > > Here's my dilemma: I want to use one detail page to handle inserts and
> > > updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
> > > to initialize the page for an update; and another onActivate() handler
> > > to initialize the page for an insert.
> > >
> > > Each onActivate() handler checks to see if the user is allowed to access
> > > this page.  If the user is not allowed to access, the onActivate()
> > > handler generates a Link with the current page's context, uses that Link
> > > to set a Session state variable, and then returns a Login page.  Once
> > > the user logs in, the Session state variable is checked to see if it has
> > > been set; if so, the user is taken back to that page.
> > >
> > > My problem is that when the page is accessed with a context variable
> > > (thus, to handle an UPDATE), onActivate() is being called before
> > > onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
> > > isn't being set before the Link is generated and added to the session
> > > state.
> > >
> > > The Link that is being generated, then, doesn't have any context
> > > included, so when the user finishes logging in, the user is taken back
> > > to the page, with no context.
> > >
> > > Is this a Tapestry bug, or is there a better way of handling this?
> > >
> > > Thanks,
> > > Andy
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: onActivate woes

Posted by Andy Huhn <am...@insightbb.com>.
Hi Howard,

I am on 5.0.6.  The behavior you described here is what I expected to
see (I have onActivate() with one parameter, and onActivate() with 0
parameters, and I expected to see onActivate() with one parameter
executed first...but that was not the case).

Should I file a JIRA?  It sounds like this is the expected behavior.

Thanks,
Andy

On Sat, 2007-11-24 at 17:00 -0800, Howard Lewis Ship wrote:
> You are using 5.0.5?  I believe 5.0.6 has a fix for this, wherein the
> method invocation order is by number of parameters, decreasing.
> 
> You may have to do:
> 
> Object onActivate(Object[] context)
> {
>  ...
> }
> 
> And check the context count explicitly, and convert the context values
> explicitly, if you are on 5.0.5.
> 
> On Nov 24, 2007 11:37 AM, Andy Huhn <am...@insightbb.com> wrote:
> > Hello,
> >
> > I'm having a problem with onActivate().  Here are my questions:
> > 1) Why is onActivate() called when a context variable is included in the
> > URL?
> > 2) Is there a way to prevent onActivate() from being called until AFTER
> > onActivate(Integer prmPrimaryKey) is called?
> >
> > Here's my dilemma: I want to use one detail page to handle inserts and
> > updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
> > to initialize the page for an update; and another onActivate() handler
> > to initialize the page for an insert.
> >
> > Each onActivate() handler checks to see if the user is allowed to access
> > this page.  If the user is not allowed to access, the onActivate()
> > handler generates a Link with the current page's context, uses that Link
> > to set a Session state variable, and then returns a Login page.  Once
> > the user logs in, the Session state variable is checked to see if it has
> > been set; if so, the user is taken back to that page.
> >
> > My problem is that when the page is accessed with a context variable
> > (thus, to handle an UPDATE), onActivate() is being called before
> > onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
> > isn't being set before the Link is generated and added to the session
> > state.
> >
> > The Link that is being generated, then, doesn't have any context
> > included, so when the user finishes logging in, the user is taken back
> > to the page, with no context.
> >
> > Is this a Tapestry bug, or is there a better way of handling this?
> >
> > Thanks,
> > Andy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: onActivate woes

Posted by Howard Lewis Ship <hl...@gmail.com>.
Yes it does, if the onActivate() methods are in different places.
There's a very explicit order, base classes handle events before
subclasses.  Within a class, its handled alphabetically (ascending)
and by parameter count (descending, for a single method name with
multiple overrides).

What you may be seeing is onActivate() in the parent class being
invoked before the child class.

Ooops ... I was going to point you at the docs, but this is not
documented (outside of JavaDoc).

The rules are pretty much the same as for render phase methods:

http://tapestry.apache.org/tapestry5/tapestry-core/guide/rendering.html

But even that doc is out of date slightly (I need to update the
comment about ordering by number of parameters).

On Nov 26, 2007 4:38 PM, Andy Huhn <am...@insightbb.com> wrote:
> Howard,
>
> I'm on 5.0.6.  I'll try to boil this down to a simple test case and file
> a JIRA.  It might have something to do with the page inheritance I'm
> using?  ThisPage -> EditBasePage -> BasePage.  The onActivate() and
> onActivate(Integer) methods are on ThisPage.  Would this make a
> difference?
>
> Thanks,
> Andy
>
> On Sat, 2007-11-24 at 17:00 -0800, Howard Lewis Ship wrote:
>
> > You are using 5.0.5?  I believe 5.0.6 has a fix for this, wherein the
> > method invocation order is by number of parameters, decreasing.
> >
> > You may have to do:
> >
> > Object onActivate(Object[] context)
> > {
> >  ...
> > }
> >
> > And check the context count explicitly, and convert the context values
> > explicitly, if you are on 5.0.5.
> >
> > On Nov 24, 2007 11:37 AM, Andy Huhn <am...@insightbb.com> wrote:
> > > Hello,
> > >
> > > I'm having a problem with onActivate().  Here are my questions:
> > > 1) Why is onActivate() called when a context variable is included in the
> > > URL?
> > > 2) Is there a way to prevent onActivate() from being called until AFTER
> > > onActivate(Integer prmPrimaryKey) is called?
> > >
> > > Here's my dilemma: I want to use one detail page to handle inserts and
> > > updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
> > > to initialize the page for an update; and another onActivate() handler
> > > to initialize the page for an insert.
> > >
> > > Each onActivate() handler checks to see if the user is allowed to access
> > > this page.  If the user is not allowed to access, the onActivate()
> > > handler generates a Link with the current page's context, uses that Link
> > > to set a Session state variable, and then returns a Login page.  Once
> > > the user logs in, the Session state variable is checked to see if it has
> > > been set; if so, the user is taken back to that page.
> > >
> > > My problem is that when the page is accessed with a context variable
> > > (thus, to handle an UPDATE), onActivate() is being called before
> > > onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
> > > isn't being set before the Link is generated and added to the session
> > > state.
> > >
> > > The Link that is being generated, then, doesn't have any context
> > > included, so when the user finishes logging in, the user is taken back
> > > to the page, with no context.
> > >
> > > Is this a Tapestry bug, or is there a better way of handling this?
> > >
> > > Thanks,
> > > Andy
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: onActivate woes

Posted by Andy Huhn <am...@insightbb.com>.
Howard,

I'm on 5.0.6.  I'll try to boil this down to a simple test case and file
a JIRA.  It might have something to do with the page inheritance I'm
using?  ThisPage -> EditBasePage -> BasePage.  The onActivate() and
onActivate(Integer) methods are on ThisPage.  Would this make a
difference?

Thanks,
Andy

On Sat, 2007-11-24 at 17:00 -0800, Howard Lewis Ship wrote:
> You are using 5.0.5?  I believe 5.0.6 has a fix for this, wherein the
> method invocation order is by number of parameters, decreasing.
> 
> You may have to do:
> 
> Object onActivate(Object[] context)
> {
>  ...
> }
> 
> And check the context count explicitly, and convert the context values
> explicitly, if you are on 5.0.5.
> 
> On Nov 24, 2007 11:37 AM, Andy Huhn <am...@insightbb.com> wrote:
> > Hello,
> >
> > I'm having a problem with onActivate().  Here are my questions:
> > 1) Why is onActivate() called when a context variable is included in the
> > URL?
> > 2) Is there a way to prevent onActivate() from being called until AFTER
> > onActivate(Integer prmPrimaryKey) is called?
> >
> > Here's my dilemma: I want to use one detail page to handle inserts and
> > updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
> > to initialize the page for an update; and another onActivate() handler
> > to initialize the page for an insert.
> >
> > Each onActivate() handler checks to see if the user is allowed to access
> > this page.  If the user is not allowed to access, the onActivate()
> > handler generates a Link with the current page's context, uses that Link
> > to set a Session state variable, and then returns a Login page.  Once
> > the user logs in, the Session state variable is checked to see if it has
> > been set; if so, the user is taken back to that page.
> >
> > My problem is that when the page is accessed with a context variable
> > (thus, to handle an UPDATE), onActivate() is being called before
> > onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
> > isn't being set before the Link is generated and added to the session
> > state.
> >
> > The Link that is being generated, then, doesn't have any context
> > included, so when the user finishes logging in, the user is taken back
> > to the page, with no context.
> >
> > Is this a Tapestry bug, or is there a better way of handling this?
> >
> > Thanks,
> > Andy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: onActivate woes

Posted by Howard Lewis Ship <hl...@gmail.com>.
You are using 5.0.5?  I believe 5.0.6 has a fix for this, wherein the
method invocation order is by number of parameters, decreasing.

You may have to do:

Object onActivate(Object[] context)
{
 ...
}

And check the context count explicitly, and convert the context values
explicitly, if you are on 5.0.5.

On Nov 24, 2007 11:37 AM, Andy Huhn <am...@insightbb.com> wrote:
> Hello,
>
> I'm having a problem with onActivate().  Here are my questions:
> 1) Why is onActivate() called when a context variable is included in the
> URL?
> 2) Is there a way to prevent onActivate() from being called until AFTER
> onActivate(Integer prmPrimaryKey) is called?
>
> Here's my dilemma: I want to use one detail page to handle inserts and
> updates.  So I have written an onActivate(Integer prmPrimaryKey) handler
> to initialize the page for an update; and another onActivate() handler
> to initialize the page for an insert.
>
> Each onActivate() handler checks to see if the user is allowed to access
> this page.  If the user is not allowed to access, the onActivate()
> handler generates a Link with the current page's context, uses that Link
> to set a Session state variable, and then returns a Login page.  Once
> the user logs in, the Session state variable is checked to see if it has
> been set; if so, the user is taken back to that page.
>
> My problem is that when the page is accessed with a context variable
> (thus, to handle an UPDATE), onActivate() is being called before
> onActivate(Integer prmPrimaryKey).  Thus, the entity ID of the page
> isn't being set before the Link is generated and added to the session
> state.
>
> The Link that is being generated, then, doesn't have any context
> included, so when the user finishes logging in, the user is taken back
> to the page, with no context.
>
> Is this a Tapestry bug, or is there a better way of handling this?
>
> Thanks,
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org