You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by manuel aldana <al...@gmx.de> on 2009/03/06 02:10:56 UTC

Page navigation passed value not displayed (@InjectPage style)

Hi,

I want to pass one value to one page with the InjectPage pattern 
(http://tapestry.apache.org/tapestry5/guide/pagenav.html). But below 
code does not work (email does not get displayed on other page).


public class Registration
{
    @Property
    private String email;
   
    @InjectPage
    private SendingActivationEmail sendingActivationEmail;

    @OnEvent(value = "submit", component = "newUser")
    Object newUser()
    {
       //WHEN DEBUGGING VALUE GETS PASSED CORRECTLY
        sendingActivationEmail.setEmail(email);
        return sendingActivationEmail;
    }
}
-------
public class SendingActivationEmail
{

    private String email;

    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }
}
-------
SendingActivationMail.tml (I would not see email printed here):
<t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
   We send an email to your registrated email ${email}. check it out.
</t:layout>
--------

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by DH <ni...@gmail.com>.
Even though same page instance is used for requests, page field value is set to default value when it is released to pagepool (after every request), so email are always null after redirect-aftre-post .

Use persist or activate/passivate pattern, please refer to http://tapestry.apache.org/tapestry5/guide/pagenav.html # Page Navigation Patterns


Thanks

DH


----- Original Message ----- 
From: "Andy Pahne" <an...@googlemail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Friday, March 06, 2009 10:33 AM
Subject: Re: Page navigation passed value not displayed (@InjectPage style)


> 
> 
> I usually do it a little differnet and it works for me:
> 
> 
> 
> class YourPage{
>    @InjectPage
>    private DestinationPage destinationPage;
> 
>   
> 
>    Object onAction(String emailAddress){
>        return destinationPage.startEdit(emailAddress);
>    }
> 
> 
> }
> 
> 
> class DestinationPagePage{
>    
>    @Property @Persist
>    String emailAddress;
> 
> 
>     Object startEdit(String emailAddress){
>              this.emailAddress = emailAddress;
>              return this;
>     }
> 
> }
> 
> 
> 
> Hope that helps,
> Andy
> 
> 
> 
> 
> 
> manuel aldana schrieb:
>> thanks, but same issue. Anyway I think with the InjectPage pattern and 
>> returning an Object you have control which page-instance is passed. I 
>> debugged an the same page instance is used to retrieve the value.
>>
>> But further debugging shows that the setter is called, but when 
>> displaying the page the email field is reset to 'null' (which I 
>> wouldn't expect from the lifecycle when using the InjectPage + 
>> returnPage pattern).
>>
>> Luther Baker schrieb:
>>> Try adding @Persist to the destination class ... otherwise, I'm not sure
>>> you're guaranteed which page instance will get rendered.
>>>
>>> public class SendingActivationEmail
>>> {
>>>
>>>   @Persist
>>>   private String email;
>>>
>>>
>>> -Luther
>>>
>>>
>>> On Thu, Mar 5, 2009 at 7:10 PM, manuel aldana <al...@gmx.de> wrote:
>>>
>>>  
>>>> Hi,
>>>>
>>>> I want to pass one value to one page with the InjectPage pattern (
>>>> http://tapestry.apache.org/tapestry5/guide/pagenav.html). But below 
>>>> code
>>>> does not work (email does not get displayed on other page).
>>>>
>>>>
>>>> public class Registration
>>>> {
>>>>   @Property
>>>>   private String email;
>>>>     @InjectPage
>>>>   private SendingActivationEmail sendingActivationEmail;
>>>>
>>>>   @OnEvent(value = "submit", component = "newUser")
>>>>   Object newUser()
>>>>   {
>>>>      //WHEN DEBUGGING VALUE GETS PASSED CORRECTLY
>>>>       sendingActivationEmail.setEmail(email);
>>>>       return sendingActivationEmail;
>>>>   }
>>>> }
>>>> -------
>>>> public class SendingActivationEmail
>>>> {
>>>>
>>>>   private String email;
>>>>
>>>>   public String getEmail()
>>>>   {
>>>>       return email;
>>>>   }
>>>>
>>>>   public void setEmail(String email)
>>>>   {
>>>>       this.email = email;
>>>>   }
>>>> }
>>>> -------
>>>> SendingActivationMail.tml (I would not see email printed here):
>>>> <t:layout 
>>>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>>>>  We send an email to your registrated email ${email}. check it out.
>>>> </t:layout>
>>>> --------
>>>>
>>>> -- 
>>>> manuel aldana
>>>> aldana@gmx.de
>>>> software-engineering blog: http://www.aldana-online.de
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
> 
>

Why t5 ioc module 'id' was removed?

Posted by 丁振波 <ze...@gmail.com>.
In t5's former version, module has a id like hivemind does, using format 
like below

-----
package org.example.myapp.services;

import org.apache.tapestry.ioc.annotations.Id;

@Id("myapp")
public class MyAppModule
{
  public static Indexer buildIndexer()
   {
    return new IndexerImpl();
   }
}

Inject("service:myapp.Indexer")
private Indexer   indexer;

-----

Why the feature was removed? are there any reasons? 


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by Andy Pahne <an...@googlemail.com>.

I usually do it a little differnet and it works for me:



class YourPage{
    @InjectPage
    private DestinationPage destinationPage;

   

    Object onAction(String emailAddress){
        return destinationPage.startEdit(emailAddress);
    }


}


class DestinationPagePage{
    
    @Property @Persist
    String emailAddress;


     Object startEdit(String emailAddress){
              this.emailAddress = emailAddress;
              return this;
     }

}



Hope that helps,
Andy





manuel aldana schrieb:
> thanks, but same issue. Anyway I think with the InjectPage pattern and 
> returning an Object you have control which page-instance is passed. I 
> debugged an the same page instance is used to retrieve the value.
>
> But further debugging shows that the setter is called, but when 
> displaying the page the email field is reset to 'null' (which I 
> wouldn't expect from the lifecycle when using the InjectPage + 
> returnPage pattern).
>
> Luther Baker schrieb:
>> Try adding @Persist to the destination class ... otherwise, I'm not sure
>> you're guaranteed which page instance will get rendered.
>>
>> public class SendingActivationEmail
>> {
>>
>>   @Persist
>>   private String email;
>>
>>
>> -Luther
>>
>>
>> On Thu, Mar 5, 2009 at 7:10 PM, manuel aldana <al...@gmx.de> wrote:
>>
>>  
>>> Hi,
>>>
>>> I want to pass one value to one page with the InjectPage pattern (
>>> http://tapestry.apache.org/tapestry5/guide/pagenav.html). But below 
>>> code
>>> does not work (email does not get displayed on other page).
>>>
>>>
>>> public class Registration
>>> {
>>>   @Property
>>>   private String email;
>>>     @InjectPage
>>>   private SendingActivationEmail sendingActivationEmail;
>>>
>>>   @OnEvent(value = "submit", component = "newUser")
>>>   Object newUser()
>>>   {
>>>      //WHEN DEBUGGING VALUE GETS PASSED CORRECTLY
>>>       sendingActivationEmail.setEmail(email);
>>>       return sendingActivationEmail;
>>>   }
>>> }
>>> -------
>>> public class SendingActivationEmail
>>> {
>>>
>>>   private String email;
>>>
>>>   public String getEmail()
>>>   {
>>>       return email;
>>>   }
>>>
>>>   public void setEmail(String email)
>>>   {
>>>       this.email = email;
>>>   }
>>> }
>>> -------
>>> SendingActivationMail.tml (I would not see email printed here):
>>> <t:layout 
>>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>>>  We send an email to your registrated email ${email}. check it out.
>>> </t:layout>
>>> --------
>>>
>>> -- 
>>> manuel aldana
>>> aldana@gmx.de
>>> software-engineering blog: http://www.aldana-online.de
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
thanks, but same issue. Anyway I think with the InjectPage pattern and 
returning an Object you have control which page-instance is passed. I 
debugged an the same page instance is used to retrieve the value.

But further debugging shows that the setter is called, but when 
displaying the page the email field is reset to 'null' (which I wouldn't 
expect from the lifecycle when using the InjectPage + returnPage pattern).

Luther Baker schrieb:
> Try adding @Persist to the destination class ... otherwise, I'm not sure
> you're guaranteed which page instance will get rendered.
>
> public class SendingActivationEmail
> {
>
>   @Persist
>   private String email;
>
>
> -Luther
>
>
> On Thu, Mar 5, 2009 at 7:10 PM, manuel aldana <al...@gmx.de> wrote:
>
>   
>> Hi,
>>
>> I want to pass one value to one page with the InjectPage pattern (
>> http://tapestry.apache.org/tapestry5/guide/pagenav.html). But below code
>> does not work (email does not get displayed on other page).
>>
>>
>> public class Registration
>> {
>>   @Property
>>   private String email;
>>     @InjectPage
>>   private SendingActivationEmail sendingActivationEmail;
>>
>>   @OnEvent(value = "submit", component = "newUser")
>>   Object newUser()
>>   {
>>      //WHEN DEBUGGING VALUE GETS PASSED CORRECTLY
>>       sendingActivationEmail.setEmail(email);
>>       return sendingActivationEmail;
>>   }
>> }
>> -------
>> public class SendingActivationEmail
>> {
>>
>>   private String email;
>>
>>   public String getEmail()
>>   {
>>       return email;
>>   }
>>
>>   public void setEmail(String email)
>>   {
>>       this.email = email;
>>   }
>> }
>> -------
>> SendingActivationMail.tml (I would not see email printed here):
>> <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>>  We send an email to your registrated email ${email}. check it out.
>> </t:layout>
>> --------
>>
>> --
>> manuel aldana
>> aldana@gmx.de
>> software-engineering blog: http://www.aldana-online.de
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   


-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
-------- Original-Nachricht --------
> Datum: Sat, 07 Mar 2009 13:01:33 +0100
> Von: Andy Pahne <an...@googlemail.com>
> An: Tapestry users <us...@tapestry.apache.org>
> Betreff: Re: Page navigation passed value not displayed (@InjectPage style)

> manuel aldana schrieb:
> > So you mean if I provide a coercion for User, the User gets serialized 
> > to an activation-context snippet in the URL, and after that the 
> > snippets gets deserialized back to my User object?
> >
> 
> I don't think that serialization is used. It's more that you pass those 
> values necessary to construct the object in question.
> 

Sorry I did not mean serialization in view of Java objects. Just forth and back encoding inside URL.

> 
> > Maybe an out of the box coercion for custom types would be interesting 
> > (to an ordered comma separated String list). Surely it will also show 
> > up problems, especially if my User does not only include simple types 
> > only (and object graph is more complicated).
> >
> >
> 
> I don't see the use case. In my opinion, it's not that often in real 
> life that you have to provide your own type coercions. And this kind of 
> "out of the box coercion for custom types" cries for too much problems.

I guess you're right with that, I will look in an alternative where I just do a creation beforehand and am passing an id.

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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by Andy Pahne <an...@googlemail.com>.
manuel aldana schrieb:
> So you mean if I provide a coercion for User, the User gets serialized 
> to an activation-context snippet in the URL, and after that the 
> snippets gets deserialized back to my User object?
>

I don't think that serialization is used. It's more that you pass those 
values necessary to construct the object in question.


> Maybe an out of the box coercion for custom types would be interesting 
> (to an ordered comma separated String list). Surely it will also show 
> up problems, especially if my User does not only include simple types 
> only (and object graph is more complicated).
>
>

I don't see the use case. In my opinion, it's not that often in real 
life that you have to provide your own type coercions. And this kind of 
"out of the box coercion for custom types" cries for too much problems.




> Andy Pahne schrieb:
>>
>>
>> That's possible. Have a look at
>>    http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/coerce.html
>> esp. the section "Contributing new Coercions"
>>
>>
>>
>


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by ningdh <ni...@gmail.com>.
General speaking when with Hibernate, only convert entity to primary key id, and then get back to entity, much like HibernateEntityValueEncoder class.

DH
----- Original Message ----- 
From: "manuel aldana" <al...@gmx.de>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Saturday, March 07, 2009 5:13 PM
Subject: Re: Page navigation passed value not displayed (@InjectPage style)


> So you mean if I provide a coercion for User, the User gets serialized 
> to an activation-context snippet in the URL, and after that the snippets 
> gets deserialized back to my User object?
> 
> Maybe an out of the box coercion for custom types would be interesting 
> (to an ordered comma separated String list). Surely it will also show up 
> problems, especially if my User does not only include simple types only 
> (and object graph is more complicated).
> 
> 
> Andy Pahne schrieb:
>>
>>
>> That's possible. Have a look at
>>    http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/coerce.html
>> esp. the section "Contributing new Coercions"
>>
>>
>>
>>
>>
>>>
>>> Example: I want to pass a User through activation context:
>>>
>>> class User { private String name; private String password;...}
>>>
>>> Registration{
>>> ...
>>> public void onActivate(User user){...}
>>> ....
>>> }
>>>
>>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> -- 
> manuel aldana
> aldana@gmx.de
> software-engineering blog: http://www.aldana-online.de
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>

Re: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
So you mean if I provide a coercion for User, the User gets serialized 
to an activation-context snippet in the URL, and after that the snippets 
gets deserialized back to my User object?

Maybe an out of the box coercion for custom types would be interesting 
(to an ordered comma separated String list). Surely it will also show up 
problems, especially if my User does not only include simple types only 
(and object graph is more complicated).


Andy Pahne schrieb:
>
>
> That's possible. Have a look at
>    http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/coerce.html
> esp. the section "Contributing new Coercions"
>
>
>
>
>
>>
>> Example: I want to pass a User through activation context:
>>
>> class User { private String name; private String password;...}
>>
>> Registration{
>> ...
>> public void onActivate(User user){...}
>> ....
>> }
>>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by Andy Pahne <an...@googlemail.com>.

That's possible. Have a look at
    http://tapestry.formos.com/nightly/tapestry5/tapestry-ioc/coerce.html
esp. the section "Contributing new Coercions"





>
> Example: I want to pass a User through activation context:
>
> class User { private String name; private String password;...}
>
> Registration{
> ...
> public void onActivate(User user){...}
> ....
> }
>






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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
manuel aldana schrieb:
> manuel aldana schrieb:
>>>  
>>>  [...]
>> Thanks. Adding @Persist made the trick. But I think I will go for the 
>> activation context,[...]
> But I wonder, how to overcome the HttpSession, if I want to pass 
> multiple values and want to use activation context for that. So far I 
> have only seen onActivation() methods with one parameter of the simple 
> types (int, long, String etc.).
> Is it possible to pass multiple values through activation context?
>
>
It seems that such a similar thing is possible with 
http://code.google.com/p/t5-restful-webservices/wiki/GettingStarted, but 
I think it would be really cool if such a thing would be included in 
tapestry out of the box.

Example: I want to pass a User through activation context:

class User { private String name; private String password;...}

Registration{
...
public void onActivate(User user){...}
....
}

as URL it could be serialized by tapestry as something like: 
http://domain/targetPage/paul<separator>paulAtdomain

 

-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
manuel aldana schrieb:
>>  
>>  [...]
> Thanks. Adding @Persist made the trick. But I think I will go for the 
> activation context,[...]
But I wonder, how to overcome the HttpSession, if I want to pass multiple values and want to use activation context for that. So far I have only seen onActivation() methods with one parameter of the simple types (int, long, String etc.). 

Is it possible to pass multiple values through activation context?


-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by manuel aldana <al...@gmx.de>.
Thiago H. de Paula Figueiredo schrieb:
> On Thu, Mar 5, 2009 at 10:24 PM, Luther Baker <lu...@gmail.com> wrote:
>   
>> Try adding @Persist to the destination class ... otherwise, I'm not sure
>> you're guaranteed which page instance will get rendered.
>>     
>
> I would suggest @Persist("flash"): the field is put in the session and
> then removed after it's read the first time. ;)
>
> Manuel, please post you updated code here because the one in the first
> message should work when you add @Persist or @Persist("flash") to
> SendingActivationEmail.email.
Thanks. Adding @Persist made the trick. But I think I will go for the 
activation context, because I want to avoid HttpSession, even if it is 
for one call. This way I make my webapp-server stateless completely and 
am avoiding sticky-server problems.

public class SendingActivationEmail
{

    @Persist("flash")
    private String email;

    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }
}


-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, Mar 5, 2009 at 10:24 PM, Luther Baker <lu...@gmail.com> wrote:
> Try adding @Persist to the destination class ... otherwise, I'm not sure
> you're guaranteed which page instance will get rendered.

I would suggest @Persist("flash"): the field is put in the session and
then removed after it's read the first time. ;)

Manuel, please post you updated code here because the one in the first
message should work when you add @Persist or @Persist("flash") to
SendingActivationEmail.email.

-- 
Thiago

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


Re: Page navigation passed value not displayed (@InjectPage style)

Posted by Luther Baker <lu...@gmail.com>.
Try adding @Persist to the destination class ... otherwise, I'm not sure
you're guaranteed which page instance will get rendered.

public class SendingActivationEmail
{

  @Persist
  private String email;


-Luther


On Thu, Mar 5, 2009 at 7:10 PM, manuel aldana <al...@gmx.de> wrote:

> Hi,
>
> I want to pass one value to one page with the InjectPage pattern (
> http://tapestry.apache.org/tapestry5/guide/pagenav.html). But below code
> does not work (email does not get displayed on other page).
>
>
> public class Registration
> {
>   @Property
>   private String email;
>     @InjectPage
>   private SendingActivationEmail sendingActivationEmail;
>
>   @OnEvent(value = "submit", component = "newUser")
>   Object newUser()
>   {
>      //WHEN DEBUGGING VALUE GETS PASSED CORRECTLY
>       sendingActivationEmail.setEmail(email);
>       return sendingActivationEmail;
>   }
> }
> -------
> public class SendingActivationEmail
> {
>
>   private String email;
>
>   public String getEmail()
>   {
>       return email;
>   }
>
>   public void setEmail(String email)
>   {
>       this.email = email;
>   }
> }
> -------
> SendingActivationMail.tml (I would not see email printed here):
> <t:layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>  We send an email to your registrated email ${email}. check it out.
> </t:layout>
> --------
>
> --
> manuel aldana
> aldana@gmx.de
> software-engineering blog: http://www.aldana-online.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>