You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Captain Cid <ca...@indiatimes.com> on 2009/06/28 12:40:07 UTC

access component variable

hi,

i have page with 2 components A and B...i want to access 1st components
variable say "foo" (A.foo) after it is invoked in component B..how can i do
so ?
-- 
View this message in context: http://www.nabble.com/access-component-variable-tp24240467p24240467.html
Sent from the Tapestry - User 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: Re: Re: access component variable

Posted by Captain Cid <ca...@indiatimes.com>.
I tried using Environment and it works..but i have a doubt

A and B both are defined as component in my page...

code snippet is like :

page.java
--------
@Component
private A a;

@Component 
private B b;

void beforeRender() {
   envoronment.push(A.class,a);
}

void afterRender() {
  environment.pop(A.class);
}

so does this ensure that when component B is called and i try to peek A from
environment...A would already have been initialized and executed, so that i
get valid ID ?


nille hammer wrote:
> 
> Hi Cid,
> 
> I have just been to the toilett and have thought about your question.
> Maybe you could nest component B in component A directly rather than in
> the page? Example follows:
> 
> in page.tml
> ...
> <t:a .../>
> ...
> 
> in a.tml
> ...
> <render the stuff from a>
> <t:b parameter="valueFromA">
> ...
> 
> Would that be an option?
> 
> Regards, nillehammer
> 
> ==
> http://www.winfonet.eu
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/access-component-variable-tp24240467p24269099.html
Sent from the Tapestry - User 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: access component variable

Posted by Captain Cid <ca...@indiatimes.com>.
i have one component..which tries to get a ID (primary key) and some other
info from database and renders it...
another component needs this ID to query DB and render some other
information...other way is that it has to make unnecessary same query to
first get ID and then use it ! So what do you suggest ?




nille hammer wrote:
> 
> Hi Cid,
> 
> You could use Tapestry's Envronment feature. Look here for documentation:
> http://tapestry.apache.org/tapestry5.1/guide/env.html
> 
> Although I think you should design your components a bit differently, so
> that you don't need to do this. Maybe you could give us some more details
> on your special use case and we can find another solution.
> 
> Regards, nillehammer
> 
> ==
> http://www.winfonet.eu 
> 
> -----------------------------------------------
> Betreff: access component variable
> Gesendet: So, 28. Jun 2009
> Von: Captain Cid<ca...@indiatimes.com>
> 
>> 
>> hi,
>> 
>> i have page with 2 components A and B...i want to access 1st components
>> variable say "foo" (A.foo) after it is invoked in component B..how can i
>> do
>> so ?
>> -- 
>> View this message in context:
>> http://www.nabble.com/access-component-variable-tp24240467p24240467.html
>> Sent from the Tapestry - User 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
>> 
>> 
> 
> --- original Nachricht Ende ----
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/access-component-variable-tp24240467p24252626.html
Sent from the Tapestry - User 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: Re: Re: access component variable

Posted by Captain Cid <ca...@indiatimes.com>.

nille hammer wrote:
> 
> Hi Cid,
> 
> I have just been to the toilett and have thought about your question.
> Maybe you could nest component B in component A directly rather than in
> the page? Example follows:
> 
> in page.tml
> ...
> <t:a .../>
> ...
> 
> in a.tml
> ...
> <render the stuff from a>
> <t:b parameter="valueFromA">
> ^^^^^^^^^^^^^^^^^^^^
> how can i get value from A ?
> suppose A has variable 
> private String ID;
> 
> public String getId() {
>     return ID;
> }
> 
> can i use <t:b ID="Id"> ?
> ...
> 
> Would that be an option?
> 
> Regards, nillehammer
> 
> ==
> http://www.winfonet.eu
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/access-component-variable-tp24240467p24269162.html
Sent from the Tapestry - User 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