You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alessandro Bottoni <al...@gmail.com> on 2009/12/18 10:23:03 UTC
Passing a value from a page to another
I'm trying to pass a value from a page called "Register" to a page
called "UserProfile" following the instruction supplied by A. Kolesnikov
in his Tapestry 5 book (pages 59 - 62).
The value I want to pass is just a simple String Id. Here is (a
simplified version of) my code:
public class Register {
// this class is used by a BeanEditor-based page template
private String id = "Id From Register";
@InjectPage
private UserProfile userProfile;
Object onSuccess(){
// this call does not work...
userProfile.setUserId(id);
return userProfile;
}
}
public class UserProfile {
private String UserId = "Id from UserProfile";
// this method is not invoked as expected..
public void setUserId(String MyUserId){
this.UserId = "Id received form Register";
}
// later used in a ${UserId} expansion on the target page
public String getUserId() {
return this.UserId;
}
}
The Id Value is not passed from the first page to the second one (that
is: I always get the default string "Id from UserProfile" as the Id
rendered on the UserProfile page).
What can be wrong in such trivial code?
--
Alessandro Bottoni
Website: http://www.alessandrobottoni.it/
"Life is a sexually transmitted disease, and it's 100% fatal."
-- Unknown
Re: Passing a value from a page to another
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 18.12.2009 12:46, schrieb Ashwanth Kumar:
> Well, did u try using @Persist for UserProfile page's UserID value?
This is going to break tabbed browsing.
- Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing a value from a page to another
Posted by Ashwanth Kumar <as...@gmail.com>.
Well, did u try using @Persist for UserProfile page's UserID value?
HTH
- Ashwanth
On Fri, Dec 18, 2009 at 2:53 PM, Alessandro Bottoni
<al...@gmail.com>wrote:
> I'm trying to pass a value from a page called "Register" to a page
> called "UserProfile" following the instruction supplied by A. Kolesnikov
> in his Tapestry 5 book (pages 59 - 62).
>
> The value I want to pass is just a simple String Id. Here is (a
> simplified version of) my code:
>
> public class Register {
> // this class is used by a BeanEditor-based page template
>
> private String id = "Id From Register";
>
> @InjectPage
> private UserProfile userProfile;
>
> Object onSuccess(){
> // this call does not work...
> userProfile.setUserId(id);
> return userProfile;
> }
> }
>
> public class UserProfile {
>
> private String UserId = "Id from UserProfile";
>
> // this method is not invoked as expected..
> public void setUserId(String MyUserId){
> this.UserId = "Id received form Register";
> }
>
> // later used in a ${UserId} expansion on the target page
> public String getUserId() {
> return this.UserId;
> }
> }
>
> The Id Value is not passed from the first page to the second one (that
> is: I always get the default string "Id from UserProfile" as the Id
> rendered on the UserProfile page).
>
> What can be wrong in such trivial code?
>
> --
>
> Alessandro Bottoni
> Website: http://www.alessandrobottoni.it/
>
> "Life is a sexually transmitted disease, and it's 100% fatal."
> -- Unknown
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Passing a value from a page to another
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 18 Dec 2009 07:23:03 -0200, Alessandro Bottoni
<al...@gmail.com> escreveu:
> public class Register {
> // this class is used by a BeanEditor-based page template
>
> private String id = "Id From Register";
Never initialize a page class field in its declaration. It can lead to
very nasty bugs because of Tapestry's page pooling.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Passing a value from a page to another
Posted by Inge Solvoll <in...@gmail.com>.
http://202.177.217.122:8080/jumpstart/examples/state/passingdatabetweenpages1
On Fri, Dec 18, 2009 at 10:23 AM, Alessandro Bottoni
<al...@gmail.com>wrote:
> I'm trying to pass a value from a page called "Register" to a page
> called "UserProfile" following the instruction supplied by A. Kolesnikov
> in his Tapestry 5 book (pages 59 - 62).
>
> The value I want to pass is just a simple String Id. Here is (a
> simplified version of) my code:
>
> public class Register {
> // this class is used by a BeanEditor-based page template
>
> private String id = "Id From Register";
>
> @InjectPage
> private UserProfile userProfile;
>
> Object onSuccess(){
> // this call does not work...
> userProfile.setUserId(id);
> return userProfile;
> }
> }
>
> public class UserProfile {
>
> private String UserId = "Id from UserProfile";
>
> // this method is not invoked as expected..
> public void setUserId(String MyUserId){
> this.UserId = "Id received form Register";
> }
>
> // later used in a ${UserId} expansion on the target page
> public String getUserId() {
> return this.UserId;
> }
> }
>
> The Id Value is not passed from the first page to the second one (that
> is: I always get the default string "Id from UserProfile" as the Id
> rendered on the UserProfile page).
>
> What can be wrong in such trivial code?
>
> --
>
> Alessandro Bottoni
> Website: http://www.alessandrobottoni.it/
>
> "Life is a sexually transmitted disease, and it's 100% fatal."
> -- Unknown
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Passing a value from a page to another
Posted by Olle Hallin <ol...@hit.se>.
A long-shot in the dark...
Try to rename UserId to userId to comply with JavaBean naming conventions.
Olle Hallin
Senior Java Developer and Architect
olle.hallin@crisp.se
www.crisp.se
http://www.linkedin.com/in/ollehallin
2009/12/18 Alessandro Bottoni <al...@gmail.com>
> I'm trying to pass a value from a page called "Register" to a page
> called "UserProfile" following the instruction supplied by A. Kolesnikov
> in his Tapestry 5 book (pages 59 - 62).
>
> The value I want to pass is just a simple String Id. Here is (a
> simplified version of) my code:
>
> public class Register {
> // this class is used by a BeanEditor-based page template
>
> private String id = "Id From Register";
>
> @InjectPage
> private UserProfile userProfile;
>
> Object onSuccess(){
> // this call does not work...
> userProfile.setUserId(id);
> return userProfile;
> }
> }
>
> public class UserProfile {
>
> private String UserId = "Id from UserProfile";
>
> // this method is not invoked as expected..
> public void setUserId(String MyUserId){
> this.UserId = "Id received form Register";
> }
>
> // later used in a ${UserId} expansion on the target page
> public String getUserId() {
> return this.UserId;
> }
> }
>
> The Id Value is not passed from the first page to the second one (that
> is: I always get the default string "Id from UserProfile" as the Id
> rendered on the UserProfile page).
>
> What can be wrong in such trivial code?
>
> --
>
> Alessandro Bottoni
> Website: http://www.alessandrobottoni.it/
>
> "Life is a sexually transmitted disease, and it's 100% fatal."
> -- Unknown
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
Re: Passing a value from a page to another
Posted by Geoff Callender <ge...@gmail.com>.
On 18/12/2009, at 9:29 PM, Alessandro Bottoni wrote:
> Il 18/12/2009 10:33, Stephan Windmüller ha scritto:
>> It is passed to the second page, but after that the page is being
>> passivated. You need to implement onActive(String) and onPassivate().
>> Please have a look at page 66 of your book.
>
> Thanks Stephan, thanks Inge and thanks Olle. Now it works.
>
> From this statement:
>
> "Tapestry's policy of doing Redirect-After-Post makes it a bit tricky to
> pass data between pages."
>
> (See:
> http://202.177.217.122:8080/jumpstart/examples/state/passingdatabetweenpages1)
>
> I infer that Tapestry implements the POST/Redirect/GET design pattern
> (see: http://en.wikipedia.org/wiki/Post/Redirect/Get) so there isn't any
> need to worry about duplicated form submissions and similar problems. Am
> I right?
That's exactly right. There's more here: http://202.177.217.122:8080/jumpstart/examples/input/forms1
> Thanks again for your attention.
>
> --
>
> Alessandro Bottoni
> Website: http://www.alessandrobottoni.it/
>
> "When future stopped to be a promise and started to be a threat?"
> -- Street wall graffiti, Bologna, 1999
>
>
> ---------------------------------------------------------------------
> 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: Passing a value from a page to another
Posted by Alessandro Bottoni <al...@gmail.com>.
Il 18/12/2009 10:33, Stephan Windmüller ha scritto:
> It is passed to the second page, but after that the page is being
> passivated. You need to implement onActive(String) and onPassivate().
> Please have a look at page 66 of your book.
Thanks Stephan, thanks Inge and thanks Olle. Now it works.
>From this statement:
"Tapestry's policy of doing Redirect-After-Post makes it a bit tricky to
pass data between pages."
(See:
http://202.177.217.122:8080/jumpstart/examples/state/passingdatabetweenpages1)
I infer that Tapestry implements the POST/Redirect/GET design pattern
(see: http://en.wikipedia.org/wiki/Post/Redirect/Get) so there isn't any
need to worry about duplicated form submissions and similar problems. Am
I right?
Thanks again for your attention.
--
Alessandro Bottoni
Website: http://www.alessandrobottoni.it/
"When future stopped to be a promise and started to be a threat?"
-- Street wall graffiti, Bologna, 1999
Re: Passing a value from a page to another
Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Am 18.12.2009 10:23, schrieb Alessandro Bottoni:
> The Id Value is not passed from the first page to the second one (that
> is: I always get the default string "Id from UserProfile" as the Id
> rendered on the UserProfile page).
It is passed to the second page, but after that the page is being
passivated. You need to implement onActive(String) and onPassivate().
Please have a look at page 66 of your book.
-----
void onActivate(String context) {
this.UserId = context;
}
String onPassivate() {
return this.UserId;
}
-----
HTH
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org