You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nicholas Krul <ni...@gmail.com> on 2008/05/02 14:43:25 UTC

onActivate

Hi guys.

I have a question about onActivate(Object[]) and onActivate(String[])...

The simplest way to explain it is what I want to do on my login page.
At the moment when you bounce through it it stores the page name in the
activation context, but because of the variable number of context args, they
are not stored.
It would be nice if bookmarked 'login required' pages still worked with
their activation contexts.

does onActivate(Object[] context) come as an (uncast) String array?

if so, why is there no default translator to String[]
and if not, how do I make it so that String[] _is_ a valid arg?

thanks

--nK

Re: onActivate

Posted by nicholas Krul <ni...@gmail.com>.
Its pretty basic... and I havent put in String[] performPassivate method
yet.

just a word of warning... it _is_ useful for some pages, and not for
others... too many if (context.length > 0) var0 = context[0];

Better would be having a conversion to String[] then I could move it out of
the back class and use 'normal' onActivate methods... Please, *anyone*, how
would I do this?

in the mean time, here is the bulk of it (enough to work)
//in base page class...

private String context[];

public abstract void performActivation(String[] context);

Object onActivate(EventContext eventContext) {
        context = new String[eventContext.getCount()];
        for (int i = 0; i < context.length; i++) {
            context[i] = eventContext.get(String.class, i);
        }
        Object page = componentResources.getPage();

        //handle admin pages - TODO

        //handle login required pages
        if (page instanceof AuthenticatedPage
                && !(page instanceof Login || isLoggedIn())) {
            loginPage.setNextPage(page.getClass(), context);
            return loginPage;
        }

        performActivation(context);
        return null; //return page?
    }


On Sat, May 10, 2008 at 12:30 PM, Mark W. Shead <mw...@gmail.com> wrote:

> Nicholas,
>
> Would you mind sharing code snippets of what you are doing?
>
> Mark
>
> On May 9, 2008, at 11:20 AM, nicholas Krul wrote:
>
>  Thanks, works just fine... so now everything is bundled into a String[]
>> anyway...
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: onActivate

Posted by "Mark W. Shead" <mw...@gmail.com>.
Nicholas,

Would you mind sharing code snippets of what you are doing?

Mark

On May 9, 2008, at 11:20 AM, nicholas Krul wrote:

> Thanks, works just fine... so now everything is bundled into a  
> String[]
> anyway...


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


Re: onActivate

Posted by nicholas Krul <ni...@gmail.com>.
Thanks, works just fine... so now everything is bundled into a String[]
anyway...

?wouldn't it be useful to have String[] as one of the default conversions
available?
I don't expect it would be hard ... and it was (for me, anyway) expected
behavior. after all, with the splitting on /, is IS an array of strings.

_either way_ , the solution given works just fine, thanks.

--nK

On Fri, May 2, 2008 at 3:10 PM, Howard Lewis Ship <hl...@gmail.com> wrote:

> A third, and perhaps better alternative is to use EventContext instead
> of Object[].  This interface allows you to get the count of the
> parameters, and retrieve each in whatever type you like (Tapestry will
> value decode or type coerce as necessary).
>
> On Fri, May 2, 2008 at 5:43 AM, nicholas Krul <ni...@gmail.com>
> wrote:
> > Hi guys.
> >
> >  I have a question about onActivate(Object[]) and onActivate(String[])...
> >
> >  The simplest way to explain it is what I want to do on my login page.
> >  At the moment when you bounce through it it stores the page name in the
> >  activation context, but because of the variable number of context args,
> they
> >  are not stored.
> >  It would be nice if bookmarked 'login required' pages still worked with
> >  their activation contexts.
> >
> >  does onActivate(Object[] context) come as an (uncast) String array?
> >
> >  if so, why is there no default translator to String[]
> >  and if not, how do I make it so that String[] _is_ a valid arg?
> >
> >  thanks
> >
> >  --nK
> >
>
>
>
> --
> Howard M. Lewis Ship
>
> 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: onActivate

Posted by Howard Lewis Ship <hl...@gmail.com>.
A third, and perhaps better alternative is to use EventContext instead
of Object[].  This interface allows you to get the count of the
parameters, and retrieve each in whatever type you like (Tapestry will
value decode or type coerce as necessary).

On Fri, May 2, 2008 at 5:43 AM, nicholas Krul <ni...@gmail.com> wrote:
> Hi guys.
>
>  I have a question about onActivate(Object[]) and onActivate(String[])...
>
>  The simplest way to explain it is what I want to do on my login page.
>  At the moment when you bounce through it it stores the page name in the
>  activation context, but because of the variable number of context args, they
>  are not stored.
>  It would be nice if bookmarked 'login required' pages still worked with
>  their activation contexts.
>
>  does onActivate(Object[] context) come as an (uncast) String array?
>
>  if so, why is there no default translator to String[]
>  and if not, how do I make it so that String[] _is_ a valid arg?
>
>  thanks
>
>  --nK
>



-- 
Howard M. Lewis Ship

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