You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nille hammer <ta...@winfonet.eu> on 2008/05/28 11:26:32 UTC

use final for BeanModel fields

Hi Guys,

just a little side note on FilipĀ“s suggesion. Instead of initializing the BeanModel in onActivate() you could do this:

private final BeanModel<User> model; {
  model = beanModelSource.create(User.class, false, componentResources);
  model.get("username").sortable(false);
}

Mind the final. This way the BeanModel is only created once. With onActivate() it is created every time the page is requested, which is less efficient. Of course this only works, if you do not want to change the BeanModel after creation.

Cheers nillehammer


----- original Nachricht --------

> Hi,
> 
> You're not disturbing - this is a mailing list, if you can't post to it, 
> what good is it? :)
> 
> Anyhow, YourGridRowClassType is User in your case. So if you want to 
> disable sorting on the username property, you would do it like this:
> 
>    @Inject
>    private BeanModelSource beanModelSource;
> 
>    @Inject
>    private ComponentResources componentResources;
> 
>    private BeanModel<User> model;
> 
>    void onActivate() {
>      model = beanModelSource.create(User.class, false, componentResources);
>      model.get("username").sortable(false);
>    }
> 
> Hope that helps.
> 
> -Filip

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