You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by lifestyles_ <li...@hotmail.com> on 2011/09/07 17:25:57 UTC

Page redirection

Hi, i'm trying to implement a situation where as, i have a PageA, PageB and
PageC.  When using PageA, depending on different situations, i would want
the page to render, otherwise, it would want to render PageC.

What happen's in real life is :
Start of with PageA::onActivate(), the conditions don't apply for a
redirection to PageC, so PageA is rendered.  On PageA, i've got a PageLink
that brings me to PageB.  When i click on it, PageA::onActivate() is called,
and at this point, the conditions apply for a redirection to PageC, so PageB
is never called (since i clicked on the PageLink, i want to show PageB, but
the onActivate is called and i don't have a way to determine if it's from
the PageLink).

Everywhere i read, it's suggested that the onActivate : <&lt;A good
&quot;rule of thumb&quot; is to use onActivate(...) and onPassivate() for no
more than receiving and returning the activation context.
In this page, for example, onActivate(...) receives a person id and
onPassivate() returns a person id. It can be tempting to put setup code into
onActivate(...) but avoid this because onActivate(...) is called very
often&quot; &gt;> 
http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/onactivateandonpassivate/3
Jumpstart - PageNavigation .

Question #1 : Why is the onActivate() called when choosing the PageLink ?

Question #2 : What other way can i redirect a to another page without using
onActivate ?

Thank you for your time

Rene

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Page-redirection-tp4778938p4778938.html
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: Page redirection

Posted by Muhammad Gelbana <m....@gmail.com>.
I haven't tried to solve your situation as I'm not sure I understand
your case but here is my attempt to give back to this list something
in return :)

Q1. onActivate is "eventually" called because the page link directed
to that page, it's not the direct result of clicking that link (event
handling method), it's just the eventual result.

Q2. This page will help you
http://tapestry.apache.org/page-navigation.html. May be you need to
have a "actionlink" instead, and handle it, then return what suits you
most.

Tell me if this helps :)

On Wed, Sep 7, 2011 at 5:25 PM, lifestyles_ <li...@hotmail.com> wrote:
> Hi, i'm trying to implement a situation where as, i have a PageA, PageB and
> PageC.  When using PageA, depending on different situations, i would want
> the page to render, otherwise, it would want to render PageC.
>
> What happen's in real life is :
> Start of with PageA::onActivate(), the conditions don't apply for a
> redirection to PageC, so PageA is rendered.  On PageA, i've got a PageLink
> that brings me to PageB.  When i click on it, PageA::onActivate() is called,
> and at this point, the conditions apply for a redirection to PageC, so PageB
> is never called (since i clicked on the PageLink, i want to show PageB, but
> the onActivate is called and i don't have a way to determine if it's from
> the PageLink).
>
> Everywhere i read, it's suggested that the onActivate : <<A good
> "rule of thumb" is to use onActivate(...) and onPassivate() for no
> more than receiving and returning the activation context.
> In this page, for example, onActivate(...) receives a person id and
> onPassivate() returns a person id. It can be tempting to put setup code into
> onActivate(...) but avoid this because onActivate(...) is called very
> often" >>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/onactivateandonpassivate/3
> Jumpstart - PageNavigation .
>
> Question #1 : Why is the onActivate() called when choosing the PageLink ?
>
> Question #2 : What other way can i redirect a to another page without using
> onActivate ?
>
> Thank you for your time
>
> Rene
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Page-redirection-tp4778938p4778938.html
> 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
>
>



-- 
Regards,
Muhammad Gelbana
Java Developer

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


RE: Page redirection

Posted by lifestyles_ <li...@hotmail.com>.
Thank you again for your prompt response and time.

public class PageA
{        
    public Object onActivate()
    {
        System.out.println("PageA.onActivate()");

//*********** Start of selected code ***********
        if (condition)
            return PageC.class;
        else        
            return null; //Stay on same page
//*********** End of selected code ***********
    }
    
    @OnEvent(value = "doSomeThingAndGotoPageB")
    public Object gotoPageB()
    {
        System.out.println("PageA.onDoSomeThingAndGotoPageB()");
        return PageB.class;
    }
}

This is the code that we want to use, as you stated in previous emails, if we want to redirect to a different page, we do it in the PageA.onActivate().   (Code in between ******************************)

What advice can you give me for this situation where the condition in the PageA.onActivate() for the redirection can give a different result when the user click's on the eventlink ?  (The condition is related to a time base issue, so the first time you render the page, the condition is going to take in account the time, but when the user click's on the eventlink, we don't want to consider time as a issue anymore)

If we moved the selected code in the @BeginRender, the redirection 
cannot be done (The return value from a render phase event method was 
not compatible the
 expected return type of java.lang.Boolean. You should change the method
 to return the correct type.)



    @BeginRender

    public Object beginRender()

    {

        System.out.println("PageA.beginRender()");



//*********** Start of selected code ***********


        if (condition)


            return PageC.class;


        else        


            return null; //Stay on same page


//*********** End of selected code ***********


    }



Again, thank you for your time and patience

René


Date: Thu, 8 Sep 2011 08:11:28 -0700
From: ml-node+4782791-1196683961-92344@n5.nabble.com
To: lifestyles_@hotmail.com
Subject: Re: Page redirection



	On Thu, 08 Sep 2011 11:50:31 -0300, LifeStyles ® <[hidden email]>  

wrote:


> Assuming that I cannot avoid calling PageA.onActivate(), is there a way  

> to distinguish between the PageA.onActivate() called by the eventlink vs  

> PageA.onActivate called from elsewhere ?

> There is some code I would not like to execute in onActivate when it is  

> called as a result of the eventlink...


If you want to do something just when your rendering a page, use a  

@BeginRender method instead of onActivate().


-- 

Thiago H. de Paula Figueiredo

Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  

and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.

http://www.arsmachina.com.br

---------------------------------------------------------------------

To unsubscribe, e-mail: [hidden email]

For additional commands, e-mail: [hidden email]



	
	

	

	
	
		If you reply to this email, your message will be added to the discussion below:
		http://tapestry.1045711.n5.nabble.com/Page-redirection-tp4778938p4782791.html
	
	
		
		To unsubscribe from Page redirection, click here.
	 		 	   		  

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Page-redirection-tp4778938p4783358.html
Sent from the Tapestry - User mailing list archive at Nabble.com.