You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Alfonso Quiroga <al...@gmail.com> on 2009/09/17 21:07:47 UTC

correct place for component-initialization?

Hi, if I have a Box component, and I have 10 boxes in the same page...
and all of them must share data...
1) I must keep the data in the Session?
2) Which method should I use to initialize that data? If I use
onActivate() in the Box Component, I think it will be called 10 times
(because I have 10 boxes in the same page)

thanks!

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


Re: correct place for component-initialization?

Posted by Alfonso Quiroga <al...@gmail.com>.
Thanks Thiago, I appreciate your help

On Fri, Sep 18, 2009 at 12:16 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Thu, 17 Sep 2009 22:46:33 -0300, Alfonso Quiroga <al...@gmail.com>
> escreveu:
>
>> Thanks, in my case I have services injected, but I must store a data
>> in the web layer, session could be. My question is if... it exists a
>> kind of "request scope" (like in struts2) :
>
> Yes it does:
>
> @Inject
> private Request request;
>
> request.setAttribute("name", value);
>
> --
> 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
>
>

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


Re: correct place for component-initialization?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 17 Sep 2009 22:46:33 -0300, Alfonso Quiroga  
<al...@gmail.com> escreveu:

> Thanks, in my case I have services injected, but I must store a data
> in the web layer, session could be. My question is if... it exists a
> kind of "request scope" (like in struts2) :

Yes it does:

@Inject
private Request request;

request.setAttribute("name", value);

-- 
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


Re: correct place for component-initialization?

Posted by Alfonso Quiroga <al...@gmail.com>.
Thanks, in my case I have services injected, but I must store a data
in the web layer, session could be. My question is if... it exists a
kind of "request scope" (like in struts2) so in my page I have:

void onActivate() {
   myData = "hi there!"
}

...and then, in every component I can access myData... ¿the only
solution is using session? Thanks

On Thu, Sep 17, 2009 at 8:41 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> Em Thu, 17 Sep 2009 16:07:47 -0300, Alfonso Quiroga <al...@gmail.com>
> escreveu:
>
>> Hi, if I have a Box component, and I have 10 boxes in the same page...
>> and all of them must share data...
>
> Hi!
>
>> 1) I must keep the data in the Session?
>
> That's one option. Another one is to have this data store inside a
> Tapestry-IoC service.
>
>> 2) Which method should I use to initialize that data? If I use
>> onActivate() in the Box Component, I think it will be called 10 times
>> (because I have 10 boxes in the same page)
>
> onActivate doesn't work in components. You can use setupRender() inside a
> component.
>
> --
> Thiago H. de Paula Figueiredo
> Consultor, desenvolvedor e instrutor em Java
> Coordenador e professor da Especialização em Engenharia de Software com
> Ênfase em Java da Faculdade Pitágoras
> 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
>
>

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


Re: correct place for component-initialization?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 17 Sep 2009 16:07:47 -0300, Alfonso Quiroga  
<al...@gmail.com> escreveu:

> Hi, if I have a Box component, and I have 10 boxes in the same page...
> and all of them must share data...

Hi!

> 1) I must keep the data in the Session?

That's one option. Another one is to have this data store inside a  
Tapestry-IoC service.

> 2) Which method should I use to initialize that data? If I use
> onActivate() in the Box Component, I think it will be called 10 times
> (because I have 10 boxes in the same page)

onActivate doesn't work in components. You can use setupRender() inside a  
component.

-- 
Thiago H. de Paula Figueiredo
Consultor, desenvolvedor e instrutor em Java
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
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