You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by wesley <we...@yahoo.co.uk> on 2008/09/30 07:22:23 UTC
pass list of string/object between Tapestry pages
hi all,
is there any way to pass a list of string or user defined objects between
pages in tapestry 5? currently like CRUD operation, the only way to pass
parameter around is only string through onActivate() and onPassivate().
please advise, thanks
regards,
wesley
--
View this message in context: http://n2.nabble.com/pass-list-of-string-object-between-Tapestry-pages-tp1128055p1128055.html
Sent from the Tapestry Users 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: pass list of string/object between Tapestry pages
Posted by wesley <we...@yahoo.co.uk>.
hi there thiago,
thanks very much for the reply. the appstatemanager sure comes in handy,
thanks again for the advise.
wesley
Thiago H. de Paula Figueiredo wrote:
>
> Em Wed, 01 Oct 2008 11:51:47 -0300, wesley <we...@yahoo.co.uk>
> escreveu:
>
>> from the alternative ways of passing data around, can i say that using
>> flash option; the data only lived on until the next page? after that any
>> link to other page the flashed data will invalidated unless you set it
>> again?
>
> Yes. Flash persistence was created exactly to handle the
> redirect-after-post technique.
> And don't forget Tapestry's application context: it is the best way to
> pass a small amount of information from one page to another. ;)
>
>> on another side using Application State, there's no other way to kill the
>> session unless to invalidate it. but the again, to invalidate the ASO,
>> other objects which also bound to ASO will be wiped out as well am i
>> correct?
>
> If you invalidate the session, all ASO and @Persist'ed values will be
> wiped out.
> On the other hand, you have ApplicationStateManager (a Tapestry service
> that can be @Inject'ed in your page) and its set method
> (http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/ApplicationStateManager.html#set(java.lang.Class,
> T)). It gives you the option of clearing a single ASO without wiping the
> whole session.
>
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://n2.nabble.com/pass-list-of-string-object-between-Tapestry-pages-tp1128055p1132203.html
Sent from the Tapestry Users 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: pass list of string/object between Tapestry pages
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Wed, 01 Oct 2008 11:51:47 -0300, wesley <we...@yahoo.co.uk>
escreveu:
> from the alternative ways of passing data around, can i say that using
> flash option; the data only lived on until the next page? after that any
> link to other page the flashed data will invalidated unless you set it
> again?
Yes. Flash persistence was created exactly to handle the
redirect-after-post technique.
And don't forget Tapestry's application context: it is the best way to
pass a small amount of information from one page to another. ;)
> on another side using Application State, there's no other way to kill the
> session unless to invalidate it. but the again, to invalidate the ASO,
> other objects which also bound to ASO will be wiped out as well am i
> correct?
If you invalidate the session, all ASO and @Persist'ed values will be
wiped out.
On the other hand, you have ApplicationStateManager (a Tapestry service
that can be @Inject'ed in your page) and its set method
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/services/ApplicationStateManager.html#set(java.lang.Class,
T)). It gives you the option of clearing a single ASO without wiping the
whole session.
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: pass list of string/object between Tapestry pages
Posted by wesley <we...@yahoo.co.uk>.
from the alternative ways of passing data around, can i say that using flash
option; the data only lived on until the next page? after that any link to
other page the flashed data will invalidated unless you set it again? on
another side using Application State, there's no other way to kill the
session unless to invalidate it. but the again, to invalidate the ASO, other
objects which also bound to ASO will be wiped out as well am i correct?
wesley
Thiago H. de Paula Figueiredo wrote:
>
> Em Tue, 30 Sep 2008 14:58:03 -0300, Alex Kotchnev <ak...@gmail.com>
> escreveu:
>
>> I didn't quite realize that a value in a page persisted in flash scope
>> was not accessible to other pages ( although now that you mention it, it
>> seems to make sense) .
>
> It makes sense when you remember the mess that the use of HttpSession
> attributes was . . . It was always difficult to figure out who set a given
> attribute, and you had to be careful to not reuse the same attribute name
> in different pages . . . Argh. I love @Persist. :)
>
>> That's an interesting fact that seems to significantly
>> reduce the usefulness of flash scope, as in a "traditional" web app,
>> this is the perfect way to pass short lived data between two different
>> pages.
>
> Don't forget that Tapestry uses redirect-after-post by default, so many
> times you @Persist("flash") something because you do not want that
> something to remain in the user session.
>
> My applications tend to have a lot of @Persist("flash") and a few @Persist
> (almost all them storing search parameters used to fill a Grid).
>
>> However, it appears that using a combination of setters and flash scope
>> should still work, correct ? e.g.
>>
>> @Persist(value="flash")
>> User user
>>
>> public void setUser(User u) {
>> this.user = u
>> }
>
> Yes, it would. ;) That's exactly one of its uses:
>
> class Page2 {
> @Persist("flash")
> private YourData data;
> // getters and setters
> }
>
> class Page1 {
> @Inject
> private Page2 page2;
>
> public Object onActionFromSomething() {
> ...
> page2.setData(data);
> return page2;
> }
> }
>
> Thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
--
View this message in context: http://n2.nabble.com/pass-list-of-string-object-between-Tapestry-pages-tp1128055p1131583.html
Sent from the Tapestry Users 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: pass list of string/object between Tapestry pages
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 30 Sep 2008 14:58:03 -0300, Alex Kotchnev <ak...@gmail.com>
escreveu:
> I didn't quite realize that a value in a page persisted in flash scope
> was not accessible to other pages ( although now that you mention it, it
> seems to make sense) .
It makes sense when you remember the mess that the use of HttpSession
attributes was . . . It was always difficult to figure out who set a given
attribute, and you had to be careful to not reuse the same attribute name
in different pages . . . Argh. I love @Persist. :)
> That's an interesting fact that seems to significantly
> reduce the usefulness of flash scope, as in a "traditional" web app,
> this is the perfect way to pass short lived data between two different
> pages.
Don't forget that Tapestry uses redirect-after-post by default, so many
times you @Persist("flash") something because you do not want that
something to remain in the user session.
My applications tend to have a lot of @Persist("flash") and a few @Persist
(almost all them storing search parameters used to fill a Grid).
> However, it appears that using a combination of setters and flash scope
> should still work, correct ? e.g.
>
> @Persist(value="flash")
> User user
>
> public void setUser(User u) {
> this.user = u
> }
Yes, it would. ;) That's exactly one of its uses:
class Page2 {
@Persist("flash")
private YourData data;
// getters and setters
}
class Page1 {
@Inject
private Page2 page2;
public Object onActionFromSomething() {
...
page2.setData(data);
return page2;
}
}
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: pass list of string/object between Tapestry pages
Posted by Alex Kotchnev <ak...@gmail.com>.
I didn't quite realize that a value in a page persisted in flash scope was
not accessible to other pages ( although now that you mention it, it seems
to make sense) . That's an interesting fact that seems to significantly
reduce the usefulness of flash scope, as in a "traditional" web app, this is
the perfect way to pass short lived data between two different pages.
However, it appears that using a combination of setters and flash scope
should still work, correct ? e.g.
@Persist(value="flash")
User user
public void setUser(User u) {
this.user = u
}
Cheers,
Alex Kotchnev
On Tue, Sep 30, 2008 at 7:45 AM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> Em Tue, 30 Sep 2008 06:16:05 -0300, Tuan <mr...@gmail.com> escreveu:
>
> Beside activate & passivate way, you can pass parameters (objects or
>> string) between pages by using Persit data with Flash option.
>> Ex:
>> @persist (value="flash")
>> User user;
>>
>
> @Persist field values are local to a given page and are *not* shared
> between pages.
> To share session information between pages, @ApplicationState is used. ;)
>
> Thiago
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: pass list of string/object between Tapestry pages
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 30 Sep 2008 06:16:05 -0300, Tuan <mr...@gmail.com> escreveu:
> Beside activate & passivate way, you can pass parameters (objects or
> string) between pages by using Persit data with Flash option.
> Ex:
> @persist (value="flash")
> User user;
@Persist field values are local to a given page and are *not* shared
between pages.
To share session information between pages, @ApplicationState is used. ;)
Thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: pass list of string/object between Tapestry pages
Posted by Tuan <mr...@gmail.com>.
Hi wesley,
Beside activate & passivate way, you can pass parameters (objects or
string) between pages by using Persit data with Flash option.
Ex:
@persist (value="flash")
User user;
Reference link:
http://tapestry.apache.org/tapestry5/tapestry-core/guide/persist.html
Regards
Tuan
wesley wrote:
> hi all,
>
> is there any way to pass a list of string or user defined objects between
> pages in tapestry 5? currently like CRUD operation, the only way to pass
> parameter around is only string through onActivate() and onPassivate().
>
> please advise, thanks
>
> regards,
> wesley
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: pass list of string/object between Tapestry pages
Posted by José Paumard <Jo...@orange.fr>.
Wesley,
I think you have 3 ways of doing that :
1) if the data you pass from one page to another is simple (a short
string, of an integer for instance), you can get a ref on that page, put
this value in it, and use the onPassivate / onActivate mecanism to store
it, something like that :
Page 1 :
@InjectPage
private Page2 page2 ;
somewhere in your code :
page2.setValue(32) ;
Page 2 :
private int value ; // with setter and getter
int onPassivate() { return value ; }
void onActivate(int value) { this.value = value } ;
Now if value is a more complex object, you have to make it a string, and
to rebuild it from that string... not always very handy, but the T5 JSON
support might help you.
2) Use @Persist
Code for page 1 is the same
Page 2 :
@Persist
private MyClass value ; // with getter and setter
// dont use onActivate / onPassivate
3) Use @ApplicationState
Page 1 :
@ApplicationState
private MyClass value ;
somewhere in your code :
this.value = value ;
Page 2
@ApplicationState
private MyClass value ;
and value will have the value you set in page 1. Note that this is bound
to the class name, and it doesnt support templates (because of the way
templates are supported in Java 5).
>
>
> hi all,
>
> is there any way to pass a list of string or user defined objects between
> pages in tapestry 5? currently like CRUD operation, the only way to pass
> parameter around is only string through onActivate() and onPassivate().
>
> please advise, thanks
>
> regards,
> wesley
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: pass list of string/object between Tapestry pages
Posted by Kristian Marinkovic <kr...@porsche.co.at>.
there are multiple ways to share data betweeen pages:
here the two most important (IMHO)
page injection:
public class Page1 {
@InjectPage
private Page2 page2;
@Component
private ActionLink gotoPage2;
Object onActionFromGotoPage2() {
page2.setData(....);
return page2;
}
}
public class Page2 {
public void setData(List<String> data) {
....
}
}
ApplicationStateObjects
public class Page1 {
@ApplicationState
private SomeStateObject o;
}
public class Page2 {
@ApplicationState
private SomeStateObject o; // same instane as in page1
}
see documentation for more details
g,
kris
wesley <we...@yahoo.co.uk>
30.09.2008 07:22
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>
An
users@tapestry.apache.org
Kopie
Thema
pass list of string/object between Tapestry pages
hi all,
is there any way to pass a list of string or user defined objects between
pages in tapestry 5? currently like CRUD operation, the only way to pass
parameter around is only string through onActivate() and onPassivate().
please advise, thanks
regards,
wesley
--
View this message in context:
http://n2.nabble.com/pass-list-of-string-object-between-Tapestry-pages-tp1128055p1128055.html
Sent from the Tapestry Users 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