You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Stavrinides <P....@albourne.com> on 2008/11/04 13:31:36 UTC
Best practice for onActivate and onPassivate without persistence
Hi everyone,
I was wandering about best practice for passing multiple parameters to a page without using persist in the mix. Take the following example:
void onActivate(Integer companyId, Integer siteId) throws SQLException {
_site = getSite(companyId,siteId);
}
CompanySite onPassivate(){
return _site;
}
This works okay for my purposes... I like it because its stateless, however is CompanySite being serialized underneath? how expensive could that potentially be (we use some extreme objects)... If so then an uglier way could be better? perhaps:
String onPassivate(){
return _site.getCId() + "/" + _site.getSiteId();
}
thanks for your help,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Best practice for onActivate and onPassivate without persistence
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 04 Nov 2008 09:31:36 -0300, Peter Stavrinides
<P....@albourne.com> escreveu:
> Hi everyone,
Hi!
> I was wandering about best practice for passing multiple parameters to a
> page without using persist in the mix. Take the following example:
>
> void onActivate(Integer companyId, Integer siteId) throws SQLException {
> _site = getSite(companyId,siteId);
> }
>
> CompanySite onPassivate(){
> return _site;
> }
>
> This works okay for my purposes... I like it because its stateless,
> however is CompanySite being serialized underneath?
AFAIK, no.
> String onPassivate(){
> return _site.getCId() + "/" + _site.getSiteId();
> }
It wouldn't work. Tapestry would handle it as a single String and scape
the / character. Then, your onActivate method, as written above, wouldn't
work. You should return an Object[] or List instead:
Object onPassivate(){
return new Object[] {_site.getCId(), + _site.getSiteId()};
}
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org