If I tried to delete the account property first (e.g. exclude("account"). Is
this correct?), then adding using model.add("account"). The error becomes 

Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
Expression 'user.account' for class org.jecommerce.pages.Register is
read-only. [at context:Register.tml, line 10]
        at
org.apache.tapestry5.internal.bindings.PropBinding.set(PropBinding.java:75)
        at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.write(InternalComponentResourcesImpl.java:540)
        ... 73 more
Caused by: java.lang.RuntimeException: Expression 'user.account' for class
org.jecommerce.pages.Register is read-only.
        at
$PropertyConduit_12407a6a317.set($PropertyConduit_12407a6a317.java)
        at
org.apache.tapestry5.internal.bindings.PropBinding.set(PropBinding.java:71)
        ... 74 more

Now it looks like the problem is because account is a read only field
(because I remove setAccount(String) method). Is there any chance to let it
automatically call e.g. constructor such as new User(account, name, ...)
(Though I think it is unlikely) ?  

The bean model source used to create BeanModel is as below:

        public BeanModel createBeanModel(Class clazz, String lang, String 
country){
                if(null == this.beanModelSource) throw new 
NullPointerException("No
BeanModelSource configured!");

                if(null == cache.get(BeanModel.class)){
                        ClassLoader loader = 
Thread.currentThread().getContextClassLoader();
                        URL url = 
loader.getResource("messages_en_US.properties");
                        String path = url.getPath();
                        BeanModel model = null;
                        try{
                                ResourceBundle bundle = new 
PropertyResourceBundle(new
FileInputStream(path));
                                model = beanModelSource.create( clazz, true, 
new MessagesImpl(new
Locale(lang, country), bundle) );
                                //
                        }catch(IOException ioe){
                                ioe.printStackTrace();
                        }
                        cache.put(BeanModel.class, model);
                }
                return (BeanModel)cache.get(BeanModel.class);
        }

Thanks for the help.



Thiago H. de Paula Figueiredo wrote:
> 
> Em Tue, 29 Sep 2009 15:17:39 -0300, neo anderson  
> <javadeveloper...@yahoo.co.uk> escreveu:
> 
>> Yes, the User bean contains property named account. But inside the bean  
>> it does not provide setter method because it is purposed to setup when  
>> the bean is created e.g. new User(id, account).
> 
> Have you tried to delete the property from the model before adding it?
> By the way, what BeanModelSource method are you using?
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25671379.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to