You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kai Weber <ka...@glorybox.de> on 2009/08/21 12:41:27 UTC

Grid: Composed property

Hi,

I have a Bean and want to display a combination of two fields in my Grid.

public class User {
  String getFirstname(){...}
  String getLastname(){...}
}

I use BeanModel in my Page class and tried to find a way to do it programmatically, but failed. This way works:

myModel = beanModelSource.createDisplayModel(User.class, componentResources.getMessages());

...

<table t:type="grid" t:model="mymodel" t:source="users" row="user">
    <t:parameter name="nameCell">
        ${user.firstname} ${user.lastname}
    </t:parameter>
</table> 

But, is this the really the only way? I wanted to customize the display of the name cell in Java.

Kai


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


Re: Grid: Composed property

Posted by Ulrich Stärk <ul...@spielviel.de>.
Give your bean a field called displayname, combining firstname and lastname there. If you use 
persistence, mark it as volatile. Then exclude firstname and lastname from displaying using grid's 
exclude parameter.

HTH,

Uli

On 21.08.2009 12:41 schrieb Kai Weber:
> Hi,
> 
> I have a Bean and want to display a combination of two fields in my Grid.
> 
> public class User {
>   String getFirstname(){...}
>   String getLastname(){...}
> }
> 
> I use BeanModel in my Page class and tried to find a way to do it programmatically, but failed. This way works:
> 
> myModel = beanModelSource.createDisplayModel(User.class, componentResources.getMessages());
> 
> ...
> 
> <table t:type="grid" t:model="mymodel" t:source="users" row="user">
>     <t:parameter name="nameCell">
>         ${user.firstname} ${user.lastname}
>     </t:parameter>
> </table> 
> 
> But, is this the really the only way? I wanted to customize the display of the name cell in Java.
> 
> Kai
> 
> 
> ---------------------------------------------------------------------
> 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: Grid: Composed property

Posted by Felix Gonschorek <fe...@ggmedia.net>.
make a getter in the page:

public String getName() {
     return String.format("%s %s", user.getFirstname(), user.gestLastname());
}

and in the tml:

<table t:type="grid" t:model="mymodel" t:source="users" row="user" 
xmlns:p="tapestry:parameter">
     <p:nameCell>
         ${name}
     </p:nameCell>
</table>



Kai Weber schrieb:
> I have a Bean and want to display a combination of two fields in my Grid.
> 
> public class User {
>   String getFirstname(){...}
>   String getLastname(){...}
> }
> 
> I use BeanModel in my Page class and tried to find a way to do it programmatically, but failed. This way works:
> 
> myModel = beanModelSource.createDisplayModel(User.class, componentResources.getMessages());
> 
> ...
> 
> <table t:type="grid" t:model="mymodel" t:source="users" row="user">
>     <t:parameter name="nameCell">
>         ${user.firstname} ${user.lastname}
>     </t:parameter>
> </table> 
> 
> But, is this the really the only way? I wanted to customize the display of the name cell in Java.

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