You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2007/09/19 09:39:46 UTC

T5: redirecting page under onActivate

Hi,

Is there a way to redirect the page under onActivate? example: there might
be a logical error detected and program will direct user to another page
instead of the original one, possible? Thanks.
A.C.
-- 
View this message in context: http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12772266
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: redirecting page under onActivate

Posted by Josh Canfield <jo...@thedailytube.com>.
Another option for remembering where you have come from is to tell the page
explicitly.

 In Member have @Persist private Link _lastPageLink;
In Home/Other have @InjectPage private Member _memberPage;
You can use an action link handler to go to the page

protected Link getGotoMemberLink() {
 Object[] context = <your memberPage context>;
 return _resources.createActionLink("gotoMember", false, context);
}

protected Object onGotoMember(Object[] context) {
  Object[] homeContext = <whatever context you want for your home link>
  _memberPage.setLastPageLink(_resources.createPageLink("home", false,
homeContext ));
  _memberPage.onActivate(context); // presumably you are using
onpassivate in Member to properly remember this context
  return _memberPage;
}

in Home/Other template <a href="${gotoMemberLink}">Member</a>

This was from memory, so I may have messed up some specifics, but the
concept works.

I haven't investigated issues such as having the same session active in two
browsers (I assume the persisted _lastPageLink would be shared.)
Also, you might be worried about using the action link method if your page
does heavy initialization (loading stuff from a db for instance) in the
activate method, I've been moving it into setupRender.

I have the persisted _lastPageLink in a base class so that I can use it in
all my pages. You could probably make the gotoPage action and
getGotoPageLink generic and put it in the base class as well.

Josh

On 9/19/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>
>
> Hi Josh,
>
> Thanks, it works, a related question, how to redirect the page to the one
> calling? sometimes we don't know which one is "calling page", so we can't
> use page class/name to redirect, any idea? Thanks.
> A.C.
>
>
> Josh Canfield-2 wrote:
> >
> > You can return an object that represents the page you want to redirect
> to.
> > The allowed objects are described here:
> > http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html
> >
> > Josh
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12773205
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

Re: T5: redirecting page under onActivate

Posted by Marcus <mv...@gmail.com>.
Angelo,

Sorry, return false (or true) is not an option, you must known the page
name. Returning null allow access.

Marcus

Re: T5: redirecting page under onActivate

Posted by Marcelo Lotif <ml...@gmail.com>.
Angelo,
On a pretty creepy workaround, you can have, on the Member page, an String
attribute named caller that you can set with the "Other" or "Main"
values(depending on who called it)  and you can return it on the Member's
onActivate method...

2007/9/19, Angelo Chen <an...@yahoo.com.hk>:
>
>
> Thanks.
>
> Marcus-11 wrote:
> >
> > Hi Angelo,
> >
> > Maybe this hel with your first question:
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12775141
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Atenciosamente,
Marcelo Lotif

Re: T5: redirecting page under onActivate

Posted by Angelo Chen <an...@yahoo.com.hk>.
Thanks.

Marcus-11 wrote:
> 
> Hi Angelo,
> 
> Maybe this hel with your first question:
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12775141
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: redirecting page under onActivate

Posted by Marcus <mv...@gmail.com>.
Hi Angelo,

Maybe this hel with your first question:

public class ProtectedPage
{
    @ApplicationState
    private Visit _visit;

    public Visit getVisit() { return _visit; }
    public void setVisit(Visit _visit) { this._visit = _visit; }

    public Object onActivate()
    {
        if (!_visit.isLogged()) {
           return false;    // Access denied.
           // return "Start";    // Redirect to page Start.
        }
       return null;        // Return null ou true allow access.
    }
}

Marcus

Re: T5: redirecting page under onActivate

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Nick,

I think so, one way to persist caller is, adding a t:id, here is what I do:

< a t:type="pagelink" page="Member" context="rowBltn.id"
t:id="Home">${RowBltn.name}</> a>

the rendered page will have something like this:

/myapp/member/6 

Now, is there a way to access this id in the onActivate? if yes, then I can
compare the 'home' prefix and return accordingly.

Thanks,
A.C.



Nick Westgate wrote:
> 
> I suspected you meant this. You'll have to persist the "caller" somehow.
> If you're using a base page class you could store it in an ASO there.
> 
> Cheers,
> Nick.
> 
> 
> Angelo Chen wrote:
>> Hi Marcus,
>> 
>> < a t:type="pagelink" page="Member"
>> context="rowBltn.id">${RowBltn.name}</
>> a>
>> </t:loop>
>> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12774964
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: redirecting page under onActivate

Posted by Nick Westgate <ni...@key-planning.co.jp>.
I suspected you meant this. You'll have to persist the "caller" somehow.
If you're using a base page class you could store it in an ASO there.

Cheers,
Nick.


Angelo Chen wrote:
> Hi Marcus,
> 
> Example: both Home.html and Other.html has a link to Member, when the link
> is clicked, Member.class' onActivate will be called, if I return null, it
> displays Member.html, but I'd like to display Home or Other if there is
> validation error, possible?
> 
> If not possible, is there a way to pass the name of calling class to Member?
> the link is like this:
> <t:loop source="bulletin" value="RowBltn">
> < a t:type="pagelink" page="Member" context="rowBltn.id">${RowBltn.name}</
> a>
> </t:loop>
> 
> 
> Marcus Schmidke-2 wrote:
>> Just return null.
>>
>> On 9/19/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>>> Hi Josh,
>>>
>>> Thanks, it works, a related question, how to redirect the page to the one
>>> calling? sometimes we don't know which one is "calling page", so we can't
>>> use page class/name to redirect, any idea? Thanks.
>>> A.C.
>>>
>>>
> 

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


Re: T5: redirecting page under onActivate

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Marcus,

Example: both Home.html and Other.html has a link to Member, when the link
is clicked, Member.class' onActivate will be called, if I return null, it
displays Member.html, but I'd like to display Home or Other if there is
validation error, possible?

If not possible, is there a way to pass the name of calling class to Member?
the link is like this:
<t:loop source="bulletin" value="RowBltn">
< a t:type="pagelink" page="Member" context="rowBltn.id">${RowBltn.name}</
a>
</t:loop>


Marcus Schmidke-2 wrote:
> 
> Just return null.
> 
> On 9/19/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>>
>> Hi Josh,
>>
>> Thanks, it works, a related question, how to redirect the page to the one
>> calling? sometimes we don't know which one is "calling page", so we can't
>> use page class/name to redirect, any idea? Thanks.
>> A.C.
>>
>>
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12774165
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: redirecting page under onActivate

Posted by Marcus Schmidke <Ma...@Schmidke.de>.
Just return null.

On 9/19/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi Josh,
>
> Thanks, it works, a related question, how to redirect the page to the one
> calling? sometimes we don't know which one is "calling page", so we can't
> use page class/name to redirect, any idea? Thanks.
> A.C.
>
>
> Josh Canfield-2 wrote:
> >
> > You can return an object that represents the page you want to redirect to.
> > The allowed objects are described here:
> > http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html
> >
> > Josh
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12773205
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: redirecting page under onActivate

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Josh,

Thanks, it works, a related question, how to redirect the page to the one
calling? sometimes we don't know which one is "calling page", so we can't
use page class/name to redirect, any idea? Thanks.
A.C.


Josh Canfield-2 wrote:
> 
> You can return an object that represents the page you want to redirect to.
> The allowed objects are described here:
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html
> 
> Josh
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12773205
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5: redirecting page under onActivate

Posted by Josh Canfield <jo...@thedailytube.com>.
You can return an object that represents the page you want to redirect to.
The allowed objects are described here:
http://tapestry.apache.org/tapestry5/tapestry-core/guide/pagenav.html

Josh

On 9/19/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>
>
> Hi,
>
> Is there a way to redirect the page under onActivate? example: there might
> be a logical error detected and program will direct user to another page
> instead of the original one, possible? Thanks.
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3A-redirecting-page-under-onActivate-tf4479292.html#a12772266
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.