You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ronaldlee <yi...@hotmail.com> on 2007/11/02 22:50:13 UTC

T5: passing values between layout component and page

Hi,

I am building a page using layout component so that the layout can be shared
among other pages.

The question I have is that I want my layout component (lets say
"/layout/Basic.tml) to have access to page params/variables. A simple
example would be that I have a UserProfile page which uses a layout to
display the menu. I want that layout to also display the user name as
greeting ("Hi ${username}!). But the "username" is initialized in the page's
function (onActivate if is passed from another page, or other lifecycle
functions, or a "Persist("flash") variable..). So how my Basic.java can get
the username info (to be displayed in its Basic.tml) from the UserProfile
page? Same question for the opposite way (page gets values from layout
component).

thx!

Ronald
-- 
View this message in context: http://www.nabble.com/T5%3A-passing-values-between-layout-component-and-page-tf4740907.html#a13556906
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: T5: passing values between layout component and page

Posted by Marcus <mv...@gmail.com>.
Hi Ronald,

You can declare same ASO(ApplicationStateObject) in both java classes,
passing any values between any components.

Basic.java and UserProfile.java
...
@ApplicationState
private Visit _visit;
... getters and setters

Basic.tml
... ${visit.username}


Marcus

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


Re: T5: passing values between layout component and page

Posted by ronaldlee <yi...@hotmail.com>.
Oh nevermind, it works now.. stupid browser still caching the old page. thx a
lot!


ronaldlee wrote:
> 
> Thx Angelo. This seems to make sense, but I cannot make it to work.. will
> try more.
> 
> Ronald
> 
> 
> Angelo Chen wrote:
>> 
>> hi ronaldlee,
>> 
>> you can pass the user name from the UserProfile page to the layout
>> component, something like this:
>> 
>> public class Layout {
>>   @parameter
>>   private String userName;
>>   // getter/setter here
>> }
>> 
>> in UserProfile.tml:
>> 
>> <t:layout userName ="literal:my name"
>> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>> <t:/layout>
>> 
>> not tested code.
>> 
>> a.c.
>> 
>> 
>> ronaldlee wrote:
>>> 
>>> Hi,
>>> 
>>> I am building a page using layout component so that the layout can be
>>> shared among other pages.
>>> 
>>> The question I have is that I want my layout component (lets say
>>> "/layout/Basic.tml) to have access to page params/variables. A simple
>>> example would be that I have a UserProfile page which uses a layout to
>>> display the menu. I want that layout to also display the user name as
>>> greeting ("Hi ${username}!). But the "username" is initialized in the
>>> page's function (onActivate if is passed from another page, or other
>>> lifecycle functions, or a "Persist("flash") variable..). So how my
>>> Basic.java can get the username info (to be displayed in its Basic.tml)
>>> from the UserProfile page? Same question for the opposite way (page gets
>>> values from layout component).
>>> 
>>> thx!
>>> 
>>> Ronald
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-passing-values-between-layout-component-and-page-tf4740907.html#a13558850
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: T5: passing values between layout component and page

Posted by ronaldlee <yi...@hotmail.com>.
Thx Angelo. This seems to make sense, but I cannot make it to work.. will try
more.

Ronald


Angelo Chen wrote:
> 
> hi ronaldlee,
> 
> you can pass the user name from the UserProfile page to the layout
> component, something like this:
> 
> public class Layout {
>   @parameter
>   private String userName;
>   // getter/setter here
> }
> 
> in UserProfile.tml:
> 
> <t:layout userName ="literal:my name"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <t:/layout>
> 
> not tested code.
> 
> a.c.
> 
> 
> ronaldlee wrote:
>> 
>> Hi,
>> 
>> I am building a page using layout component so that the layout can be
>> shared among other pages.
>> 
>> The question I have is that I want my layout component (lets say
>> "/layout/Basic.tml) to have access to page params/variables. A simple
>> example would be that I have a UserProfile page which uses a layout to
>> display the menu. I want that layout to also display the user name as
>> greeting ("Hi ${username}!). But the "username" is initialized in the
>> page's function (onActivate if is passed from another page, or other
>> lifecycle functions, or a "Persist("flash") variable..). So how my
>> Basic.java can get the username info (to be displayed in its Basic.tml)
>> from the UserProfile page? Same question for the opposite way (page gets
>> values from layout component).
>> 
>> thx!
>> 
>> Ronald
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-passing-values-between-layout-component-and-page-tf4740907.html#a13558794
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: T5: passing values between layout component and page

Posted by Angelo Chen <an...@yahoo.com.hk>.
hi ronaldlee,

you can pass the user name from the UserProfile page to the layout
component, something like this:

public class Layout {
  @parameter
  private String userName;
  // getter/setter here
}

in UserProfile.tml:

<t:layout userName ="literal:my name"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<t:/layout>

not tested code.

a.c.


ronaldlee wrote:
> 
> Hi,
> 
> I am building a page using layout component so that the layout can be
> shared among other pages.
> 
> The question I have is that I want my layout component (lets say
> "/layout/Basic.tml) to have access to page params/variables. A simple
> example would be that I have a UserProfile page which uses a layout to
> display the menu. I want that layout to also display the user name as
> greeting ("Hi ${username}!). But the "username" is initialized in the
> page's function (onActivate if is passed from another page, or other
> lifecycle functions, or a "Persist("flash") variable..). So how my
> Basic.java can get the username info (to be displayed in its Basic.tml)
> from the UserProfile page? Same question for the opposite way (page gets
> values from layout component).
> 
> thx!
> 
> Ronald
> 

-- 
View this message in context: http://www.nabble.com/T5%3A-passing-values-between-layout-component-and-page-tf4740907.html#a13557169
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