You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by cordenier christophe <ch...@gmail.com> on 2009/09/28 16:15:28 UTC

Re: Bean editor model for User already contains a property model for property 'account'

To add a synthetic property, you only have to call add(propertyName) on the
BeanModel.

By setting the datatype on the resulting PropertyModel or by using
t:parameter, you will be able to create the display for the corresponding
property in your beaneditform.

2009/9/28 neo anderson <ja...@yahoo.co.uk>

>
> It is the line where PropertyConduitSource (variable source.create() ... )
> create synthetic property account as the following code.
>
>                PropertyConduit accountProperty = source.create(User.class,
> "account");
>
> Is this the right way to create PropertyConduit? I tried to change it using
> String.class, but the error is the same (NullPointerException). I think
> there should have something I miss, but that's the method I found on the
> mailinglist. I am confused indeed.
>
>
> http://www.nabble.com/T5%3A-Working-with-BeanModel-td18231888.html#a18352011
>
>
>
>
> ccordenier wrote:
> >
> > What corresponds to line 92 in your code ?
> >
> > -----Message d'origine-----
> > De : neo anderson [mailto:javadeveloper999@yahoo.co.uk]
> > Envoyé : lundi 28 septembre 2009 14:23
> > À : users@tapestry.apache.org
> > Objet : Re: Bean editor model for User already contains a property model
> > for property 'account'
> >
> >
> >
> > Now I use the folloing method to create synthetic property
> >
> >                 PropertyConduit accountProperty =
> > source.create(User.class, "account");
> >                 ClassPropertyAdapter cpa = access.getAdapter(User.class);
> >                 PropertyAdapter pa = cpa.getPropertyAdapter("account");
> >                 String dt = analyzer.identifyDataType(pa);
> >
> >
> model.add("account",accountProperty).dataType(dt).label("Account").sortable(false);
> >
> > However, it throws NullPointerException without further detail.
> >
> > Caused by: java.lang.NullPointerException
> >         at
> > org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
> >         at
> > $PropertyConduit_12400839bf9.get($PropertyConduit_12400839bf9.java)
> >         at
> >
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
> >         ... 91 more
> >
> > What additional information I need to provide (or anything is missing) so
> > that it won't throw this error?
> >
> > Thanks for help.
> >
> >
> >
> > Thiago H. de Paula Figueiredo wrote:
> >>
> >> Em Wed, 23 Sep 2009 17:58:08 -0300, neo anderson
> >> <ja...@yahoo.co.uk> escreveu:
> >>
> >>
> >>> I have an domain object named User, in which it has a field called
> >>> `account'. However, the User object only provide method getAccount(),
> >>> but does not
> >>> provide method setAccount(String account).
> >>
> >> BeanModelSource (used when a BeanModel is needed and you don't provide
> >> one) ignores read-only properties. It doesn't care about fields, just
> >> about getters and setters.
> >>
> >>> In the page object e.g. Register, in which I build a BeanModel using
> >>> BeanModelSource.create(User.class, ...)
> >>
> >> This method is deprecated. use createDisplayModel() or createEditModel()
> >> instead.
> >>
> >>> 1.) in the Register page object, BeanModel does not use
> >>> `BeanModel.add("account",null).label("Account").sortable(false)' method
> >>> to create account field.
> >>>
> >>> Error:
> >>> aused by: java.lang.RuntimeException: Bean editor model for User does
> >>> not
> >>> contain a property named 'account'.  Available properties: address,
> >>> name,
> >>> password, sex.
> >>
> >> You can't reorder a model using some property that doesn't exist.
> >>
> >>> Caused by: java.lang.RuntimeException: Bean editor model for User
> >>> already
> >>> contains a property model for property 'account'.
> >>
> >> You can't add the same property twice in the same model.
> >>
> >>> What is the correct way to add a column that the User object doesn't
> >>> provide get/set method at the same time?
> >>
> >> For BeanEditForm or BeanEditor, you'll need to provide your own
> >> PropertyConduit to model.add(String property, PropertyConduit conduit).
> >>
> >> --
> >> Thiago H. de Paula Figueiredo
> >> Independent Java consultant, developer, and instructor
> >> http://www.arsmachina.com.br/thiago
> >>
> >> ---------------------------------------------------------------------
> >> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25644707.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
> >
> >
> >
> >
> > Ce message et les pièces jointes sont confidentiels et réservés à l'usage
> > exclusif de ses destinataires. Il peut également être protégé par le
> > secret professionnel. Si vous recevez ce message par erreur, merci d'en
> > avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
> > message ne pouvant être assurée sur Internet, la responsabilité du groupe
> > Atos Origin ne pourra être recherchée quant au contenu de ce message.
> Bien
> > que les meilleurs efforts soient faits pour maintenir cette transmission
> > exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard
> > et sa responsabilité ne saurait être recherchée pour tout dommage
> > résultant d'un virus transmis.
> >
> > This e-mail and the documents attached are confidential and intended
> > solely for the addressee; it may also be privileged. If you receive this
> > e-mail in error, please notify the sender immediately and destroy it. As
> > its integrity cannot be secured on the Internet, the Atos Origin group
> > liability cannot be triggered for the message content. Although the
> sender
> > endeavours to maintain a computer virus-free network, the sender does not
> > warrant that this transmission is virus-free and will not be liable for
> > any damages resulting from any virus transmitted.
> >
> >
> > ---------------------------------------------------------------------
> > 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25645385.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: Bean editor model for User already contains a property model for property 'account'

Posted by Martin Strand <do...@gmail.com>.
I didn't read the entire thread, but if this particular field has no setter you can add a synthetic property with model.add("account", null) and then provide a proper block override as outlined in the guide under "Property Editor Overrides":
http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html

On Wed, 30 Sep 2009 03:27:09 +0200, neo anderson <ja...@yahoo.co.uk> wrote:

>
> The reason to remove the setter method (setAccount(String)) is because the
> filed `account' is originally purposed to be created once only when e.g.
> user registers. Therefore, the account field would not be changed/ edited
> after User object created.
>
> But it looks like BeanModel can not add e.g. account value using non default
> constructor, setter method (setAccount(String)) seemingly is unavoidable.
>
> Thanks for your help.
>
> I really appreciate it.
>
>
>
>
> Thiago H. de Paula Figueiredo wrote:
>>
>> Em Tue, 29 Sep 2009 18:35:39 -0300, neo anderson
>> <ja...@yahoo.co.uk> escreveu:
>>
>>> 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
>>
>> You should use model.add("account", somePropertyConduitInstance) in this
>> case.
>>
>>> 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,
>>> ...)
>>
>> No. It's the same as saying that everytime you need to set a property in
>> an object, you need to create another object.
>>
>> Just add the setter for the account property. If you need to edit it after
>> you created an object, you can't avoid having a setter.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Independent Java consultant, developer, and instructor
>> http://www.arsmachina.com.br/thiago
>>
>> ---------------------------------------------------------------------
>> 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: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.
The reason to remove the setter method (setAccount(String)) is because the
filed `account' is originally purposed to be created once only when e.g.
user registers. Therefore, the account field would not be changed/ edited
after User object created. 

But it looks like BeanModel can not add e.g. account value using non default
constructor, setter method (setAccount(String)) seemingly is unavoidable. 

Thanks for your help. 

I really appreciate it. 




Thiago H. de Paula Figueiredo wrote:
> 
> Em Tue, 29 Sep 2009 18:35:39 -0300, neo anderson  
> <ja...@yahoo.co.uk> escreveu:
> 
>> 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
> 
> You should use model.add("account", somePropertyConduitInstance) in this  
> case.
> 
>> 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,  
>> ...)
> 
> No. It's the same as saying that everytime you need to set a property in  
> an object, you need to create another object.
> 
> Just add the setter for the account property. If you need to edit it after  
> you created an object, you can't avoid having a setter.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
> 
> ---------------------------------------------------------------------
> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25673590.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: Bean editor model for User already contains a property model for property 'account'

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 29 Sep 2009 18:35:39 -0300, neo anderson  
<ja...@yahoo.co.uk> escreveu:

> 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

You should use model.add("account", somePropertyConduitInstance) in this  
case.

> 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,  
> ...)

No. It's the same as saying that everytime you need to set a property in  
an object, you need to create another object.

Just add the setter for the account property. If you need to edit it after  
you created an object, you can't avoid having a setter.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.
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  
> <ja...@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Bean editor model for User already contains a property model for property 'account'

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 29 Sep 2009 15:17:39 -0300, neo anderson  
<ja...@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.

The reason why setAccount is removed is because account field is purposed to
be created only when user registers. It is not purposed to be altered once
the account is created. So the to remove setAccount(String) is to prevent
other class falsely calling setAccount(String) accidentally. 

In fact, if I enable setAccount(String), the beaneditform would work without
previous problem; however, I would like to know if beaneditform can work as
my original purpose. If it is impossible, I can enable setAccount(String),
but it's a bit pity that it can not work as expected. 

Thanks for your help.


Kalle Korhonen-2 wrote:
> 
> Why do you want to include the field then? For display purposes? Why
> don't you just simply:
>        public void setAccount(String account){
>                // do nothing
>        }
> 
> then override the property in the template just to output the value
> rather than render a field?
> 
> Kalle
> 
> On Tue, Sep 29, 2009 at 11:17 AM, neo anderson
> <ja...@yahoo.co.uk> wrote:
>>
>> 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).
>>
>> The User bean looks as below:
>>
>> @Entity
>> @Table(name="USERS")
>> public class User implements Serializable{
>>
>>        @Id
>>        private String id;
>>
>>        @Column(name="ACCOUNT")
>>        private String account;
>>
>>        ...
>>
>>        public User(String id, String account, String name, String
>> password){
>>                this.id = id;
>>                this.account = account;
>>                this.name = name;
>>                this.password = password;
>>        }
>>
>>
>>        public String getAccount(){
>>                return this.account;
>>        }
>>
>>        /*
>>        public void setAccount(String account){
>>                this.account = account;
>>        }
>>        */
>>        ...
>> }
>>
>>
>> cordenier christophe wrote:
>>>
>>> But i see in your code
>>>
>>> <t:textField t:id="account" t:model="user" t:value="user.account"
>>> t:validate="required,regexp"/>
>>>
>>> Does the User bean has an account property ?
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25668232.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
>>
>>
> 
> ---------------------------------------------------------------------
> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25671514.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: Bean editor model for User already contains a property model for property 'account'

Posted by Kalle Korhonen <ka...@gmail.com>.
Why do you want to include the field then? For display purposes? Why
don't you just simply:
       public void setAccount(String account){
               // do nothing
       }

then override the property in the template just to output the value
rather than render a field?

Kalle

On Tue, Sep 29, 2009 at 11:17 AM, neo anderson
<ja...@yahoo.co.uk> wrote:
>
> 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).
>
> The User bean looks as below:
>
> @Entity
> @Table(name="USERS")
> public class User implements Serializable{
>
>        @Id
>        private String id;
>
>        @Column(name="ACCOUNT")
>        private String account;
>
>        ...
>
>        public User(String id, String account, String name, String password){
>                this.id = id;
>                this.account = account;
>                this.name = name;
>                this.password = password;
>        }
>
>
>        public String getAccount(){
>                return this.account;
>        }
>
>        /*
>        public void setAccount(String account){
>                this.account = account;
>        }
>        */
>        ...
> }
>
>
> cordenier christophe wrote:
>>
>> But i see in your code
>>
>> <t:textField t:id="account" t:model="user" t:value="user.account"
>> t:validate="required,regexp"/>
>>
>> Does the User bean has an account property ?
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25668232.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
>
>

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


Re: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.
You are right. I think this is the scenario issue. I should use other way
(e.g. intermediate bean) for gethering User information. 

Thanks for all your help. That helps me have better understanding on related
Tapestry mechanism. 

I appreacite it. : )


cordenier christophe wrote:
> 
> If your purpose is to secure your bean property, i think you should create
> an intermediate bean for your User creation.
> Tapestry Form properties are mapped to bean properties, and properties are
> set simply via accessors.
> Tapestry requires an empty constructor to your bean, and this is how
> Tapestry instantiate an object for the form.
> 
> I might be wrong, but i think that if you do not want to modify your user
> 'model' (and add an setter) then you should use a specific bean for form
> interaction and create the complete User Entity (using constructor) in the
> success phase.
> 
> 

-- 
View this message in context: http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25712083.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: Bean editor model for User already contains a property model for property 'account'

Posted by cordenier christophe <ch...@gmail.com>.
If your purpose is to secure your bean property, i think you should create
an intermediate bean for your User creation.
Tapestry Form properties are mapped to bean properties, and properties are
set simply via accessors.
Tapestry requires an empty constructor to your bean, and this is how
Tapestry instantiate an object for the form.

I might be wrong, but i think that if you do not want to modify your user
'model' (and add an setter) then you should use a specific bean for form
interaction and create the complete User Entity (using constructor) in the
success phase.

Re: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.
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). 

The User bean looks as below:

@Entity
@Table(name="USERS")
public class User implements Serializable{

	@Id
	private String id;

	@Column(name="ACCOUNT")
	private String account;
	
	...
	
	public User(String id, String account, String name, String password){
		this.id = id;
		this.account = account;
		this.name = name;
		this.password = password;
	}


	public String getAccount(){
		return this.account;
	}

	/*
	public void setAccount(String account){
		this.account = account;
	}
	*/
	...
}


cordenier christophe wrote:
> 
> But i see in your code
> 
> <t:textField t:id="account" t:model="user" t:value="user.account"
> t:validate="required,regexp"/>
> 
> Does the User bean has an account property ?
> 
> 

-- 
View this message in context: http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25668232.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: Bean editor model for User already contains a property model for property 'account'

Posted by cordenier christophe <ch...@gmail.com>.
But i see in your code

<t:textField t:id="account" t:model="user" t:value="user.account"
t:validate="required,regexp"/>

Does the User bean has an account property ?

Re: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.

model.add() method is added after BeanModel (variable model) is created
(inside the getRegisteredModel method). The display of the bean edit form at
the beginning is ok because I can see the Register html shown navigating to
the Register html page. However, the error occurs after clicking the submit
button (t:submitlabel="Register" ). The result throws 

Caused by: java.lang.RuntimeException: Bean editor model for
example.domain.User already contains a property model for property
'account'.
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.validateNewPropertyName(BeanModelImpl.java:87)
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:128)
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:79)
	at org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
	at $PropertyConduit_12405b70484.get($PropertyConduit_12405b70484.java)
	at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
	... 74 more

Following is the code used

Register.java (Page class)

public class Register {

	@Inject
	private BeanModelSource beanModelSource;

	@Property
	private User user;

	@InjectPage
	private Index index;

	@InjectPage
	private Login login;

	public BeanModel getRegisterModel(){
		BeanModel model = beanModelSource.create(User.class, ...);
		model.exclude("page");
		model.add("account").label("Account").sortable(false);
		model.reorder("account", "password", "name", "sex", "address");
		return model;
	}
	Object onSuccess(){
		...
		return login;
	}
}

Register.tml (View class)
	<t:beaneditform t:submitlabel="Register" t:object="user" t:remove="page"
t:model="registerModel">
		<t:parameter name="account">
			<t:label for="Account"/> 
			<t:textField t:id="account" t:model="user" t:value="user.account"
t:validate="required,regexp"/> 
		</t:parameter>
		<t:parameter name="name">
			<t:label for="Name"/> 
			<t:textField t:id="name" t:model="user" t:value="user.name"
t:validate="required,minlength=5"/> 
		</t:parameter>
		<t:parameter name="password">
			<t:label for="Password"/> 
			<t:passwordField t:id="password" t:model="user" t:value="user.password"
t:validate="required,minlength=2"/> 
		</t:parameter> 
		<t:parameter name="sex">
			<t:label for="Sex"/> 
			<t:select t:id="sex" t:model="genders" t:value="user.sex"
t:blankOption="never"/> 
		</t:parameter> 
		
	</t:beaneditform>




cordenier christophe wrote:
> 
> When are you doing this add ?
> 
> You error can be due for exemple to a multiple call to add() on a
> persistent
> variable.
> 
> 2009/9/28 neo anderson <ja...@yahoo.co.uk>
> 
>>
>>
>> Thanks for your reply. But when adding the method
>>
>>    model.add("account").label("Account").sortable(false);
>>
>> The error occurrs after clicking the beaneditform button, the log shows
>> the
>> following exception:
>>
>> [ERROR] TapestryModule.RequestExceptionHandler Processing of request
>> failed
>> with uncaught exception: Failure reading parameter 'model' of component
>> Register:beaneditform: Bean editor model for example.domain.User already
>> contains a property model for property 'account'.
>> ...
>> ...
>> Caused by: java.lang.RuntimeException: Bean editor model for
>> example.domain.User already contains a property model for property
>> 'account'.
>>        at
>>
>> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.validateNewPropertyName(BeanModelImpl.java:87)
>>        at
>>
>> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:128)
>>        at
>>
>> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:79)
>>        at
>> org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
>>        at
>> $PropertyConduit_1240259d749.get($PropertyConduit_1240259d749.java)
>>        at
>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
>>        ... 74 more
>>
>>
>> It looks like the BeanModel already contains the proerty account. I am
>> really confused because no matter I add or do not add a new property, the
>> exception will always be thrown. What place may I go wrong? Or is there
>> any
>> example I can check if anything I miss?
>>
>> Thank you very much.
>>
>>
>>
>> cordenier christophe wrote:
>> >
>> > To add a synthetic property, you only have to call add(propertyName) on
>> > the
>> > BeanModel.
>> >
>> > By setting the datatype on the resulting PropertyModel or by using
>> > t:parameter, you will be able to create the display for the
>> corresponding
>> > property in your beaneditform.
>> >
>> > 2009/9/28 neo anderson <ja...@yahoo.co.uk>
>> >
>> >>
>> >> It is the line where PropertyConduitSource (variable source.create()
>> ...
>> >> )
>> >> create synthetic property account as the following code.
>> >>
>> >>                PropertyConduit accountProperty =
>> >> source.create(User.class,
>> >> "account");
>> >>
>> >> Is this the right way to create PropertyConduit? I tried to change it
>> >> using
>> >> String.class, but the error is the same (NullPointerException). I
>> think
>> >> there should have something I miss, but that's the method I found on
>> the
>> >> mailinglist. I am confused indeed.
>> >>
>> >>
>> >>
>> http://www.nabble.com/T5%3A-Working-with-BeanModel-td18231888.html#a18352011
>> >>
>> >>
>> >>
>> >>
>> >> ccordenier wrote:
>> >> >
>> >> > What corresponds to line 92 in your code ?
>> >> >
>> >> > -----Message d'origine-----
>> >> > De : neo anderson [mailto:javadeveloper999@yahoo.co.uk]
>> >> > Envoyé : lundi 28 septembre 2009 14:23
>> >> > À : users@tapestry.apache.org
>> >> > Objet : Re: Bean editor model for User already contains a property
>> >> model
>> >> > for property 'account'
>> >> >
>> >> >
>> >> >
>> >> > Now I use the folloing method to create synthetic property
>> >> >
>> >> >                 PropertyConduit accountProperty =
>> >> > source.create(User.class, "account");
>> >> >                 ClassPropertyAdapter cpa =
>> >> access.getAdapter(User.class);
>> >> >                 PropertyAdapter pa =
>> cpa.getPropertyAdapter("account");
>> >> >                 String dt = analyzer.identifyDataType(pa);
>> >> >
>> >> >
>> >>
>> model.add("account",accountProperty).dataType(dt).label("Account").sortable(false);
>> >> >
>> >> > However, it throws NullPointerException without further detail.
>> >> >
>> >> > Caused by: java.lang.NullPointerException
>> >> >         at
>> >> > org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
>> >> >         at
>> >> > $PropertyConduit_12400839bf9.get($PropertyConduit_12400839bf9.java)
>> >> >         at
>> >> >
>> >>
>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
>> >> >         ... 91 more
>> >> >
>> >> > What additional information I need to provide (or anything is
>> missing)
>> >> so
>> >> > that it won't throw this error?
>> >> >
>> >> > Thanks for help.
>> >> >
>> >> >
>> >> >
>> >> > Thiago H. de Paula Figueiredo wrote:
>> >> >>
>> >> >> Em Wed, 23 Sep 2009 17:58:08 -0300, neo anderson
>> >> >> <ja...@yahoo.co.uk> escreveu:
>> >> >>
>> >> >>
>> >> >>> I have an domain object named User, in which it has a field called
>> >> >>> `account'. However, the User object only provide method
>> getAccount(),
>> >> >>> but does not
>> >> >>> provide method setAccount(String account).
>> >> >>
>> >> >> BeanModelSource (used when a BeanModel is needed and you don't
>> provide
>> >> >> one) ignores read-only properties. It doesn't care about fields,
>> just
>> >> >> about getters and setters.
>> >> >>
>> >> >>> In the page object e.g. Register, in which I build a BeanModel
>> using
>> >> >>> BeanModelSource.create(User.class, ...)
>> >> >>
>> >> >> This method is deprecated. use createDisplayModel() or
>> >> createEditModel()
>> >> >> instead.
>> >> >>
>> >> >>> 1.) in the Register page object, BeanModel does not use
>> >> >>> `BeanModel.add("account",null).label("Account").sortable(false)'
>> >> method
>> >> >>> to create account field.
>> >> >>>
>> >> >>> Error:
>> >> >>> aused by: java.lang.RuntimeException: Bean editor model for User
>> does
>> >> >>> not
>> >> >>> contain a property named 'account'.  Available properties:
>> address,
>> >> >>> name,
>> >> >>> password, sex.
>> >> >>
>> >> >> You can't reorder a model using some property that doesn't exist.
>> >> >>
>> >> >>> Caused by: java.lang.RuntimeException: Bean editor model for User
>> >> >>> already
>> >> >>> contains a property model for property 'account'.
>> >> >>
>> >> >> You can't add the same property twice in the same model.
>> >> >>
>> >> >>> What is the correct way to add a column that the User object
>> doesn't
>> >> >>> provide get/set method at the same time?
>> >> >>
>> >> >> For BeanEditForm or BeanEditor, you'll need to provide your own
>> >> >> PropertyConduit to model.add(String property, PropertyConduit
>> >> conduit).
>> >> >>
>> >> >> --
>> >> >> Thiago H. de Paula Figueiredo
>> >> >> Independent Java consultant, developer, and instructor
>> >> >> http://www.arsmachina.com.br/thiago
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25644707.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
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > Ce message et les pièces jointes sont confidentiels et réservés à
>> >> l'usage
>> >> > exclusif de ses destinataires. Il peut également être protégé par le
>> >> > secret professionnel. Si vous recevez ce message par erreur, merci
>> d'en
>> >> > avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
>> >> > message ne pouvant être assurée sur Internet, la responsabilité du
>> >> groupe
>> >> > Atos Origin ne pourra être recherchée quant au contenu de ce
>> message.
>> >> Bien
>> >> > que les meilleurs efforts soient faits pour maintenir cette
>> >> transmission
>> >> > exempte de tout virus, l'expéditeur ne donne aucune garantie à cet
>> >> égard
>> >> > et sa responsabilité ne saurait être recherchée pour tout dommage
>> >> > résultant d'un virus transmis.
>> >> >
>> >> > This e-mail and the documents attached are confidential and intended
>> >> > solely for the addressee; it may also be privileged. If you receive
>> >> this
>> >> > e-mail in error, please notify the sender immediately and destroy
>> it.
>> >> As
>> >> > its integrity cannot be secured on the Internet, the Atos Origin
>> group
>> >> > liability cannot be triggered for the message content. Although the
>> >> sender
>> >> > endeavours to maintain a computer virus-free network, the sender
>> does
>> >> not
>> >> > warrant that this transmission is virus-free and will not be liable
>> for
>> >> > any damages resulting from any virus transmitted.
>> >> >
>> >> >
>> >> >
>> ---------------------------------------------------------------------
>> >> > 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25645385.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
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25652604.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25662082.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: Bean editor model for User already contains a property model for property 'account'

Posted by cordenier christophe <ch...@gmail.com>.
When are you doing this add ?

You error can be due for exemple to a multiple call to add() on a persistent
variable.

2009/9/28 neo anderson <ja...@yahoo.co.uk>

>
>
> Thanks for your reply. But when adding the method
>
>    model.add("account").label("Account").sortable(false);
>
> The error occurrs after clicking the beaneditform button, the log shows the
> following exception:
>
> [ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
> with uncaught exception: Failure reading parameter 'model' of component
> Register:beaneditform: Bean editor model for example.domain.User already
> contains a property model for property 'account'.
> ...
> ...
> Caused by: java.lang.RuntimeException: Bean editor model for
> example.domain.User already contains a property model for property
> 'account'.
>        at
>
> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.validateNewPropertyName(BeanModelImpl.java:87)
>        at
>
> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:128)
>        at
>
> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:79)
>        at org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
>        at
> $PropertyConduit_1240259d749.get($PropertyConduit_1240259d749.java)
>        at
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
>        ... 74 more
>
>
> It looks like the BeanModel already contains the proerty account. I am
> really confused because no matter I add or do not add a new property, the
> exception will always be thrown. What place may I go wrong? Or is there any
> example I can check if anything I miss?
>
> Thank you very much.
>
>
>
> cordenier christophe wrote:
> >
> > To add a synthetic property, you only have to call add(propertyName) on
> > the
> > BeanModel.
> >
> > By setting the datatype on the resulting PropertyModel or by using
> > t:parameter, you will be able to create the display for the corresponding
> > property in your beaneditform.
> >
> > 2009/9/28 neo anderson <ja...@yahoo.co.uk>
> >
> >>
> >> It is the line where PropertyConduitSource (variable source.create() ...
> >> )
> >> create synthetic property account as the following code.
> >>
> >>                PropertyConduit accountProperty =
> >> source.create(User.class,
> >> "account");
> >>
> >> Is this the right way to create PropertyConduit? I tried to change it
> >> using
> >> String.class, but the error is the same (NullPointerException). I think
> >> there should have something I miss, but that's the method I found on the
> >> mailinglist. I am confused indeed.
> >>
> >>
> >>
> http://www.nabble.com/T5%3A-Working-with-BeanModel-td18231888.html#a18352011
> >>
> >>
> >>
> >>
> >> ccordenier wrote:
> >> >
> >> > What corresponds to line 92 in your code ?
> >> >
> >> > -----Message d'origine-----
> >> > De : neo anderson [mailto:javadeveloper999@yahoo.co.uk]
> >> > Envoyé : lundi 28 septembre 2009 14:23
> >> > À : users@tapestry.apache.org
> >> > Objet : Re: Bean editor model for User already contains a property
> >> model
> >> > for property 'account'
> >> >
> >> >
> >> >
> >> > Now I use the folloing method to create synthetic property
> >> >
> >> >                 PropertyConduit accountProperty =
> >> > source.create(User.class, "account");
> >> >                 ClassPropertyAdapter cpa =
> >> access.getAdapter(User.class);
> >> >                 PropertyAdapter pa =
> cpa.getPropertyAdapter("account");
> >> >                 String dt = analyzer.identifyDataType(pa);
> >> >
> >> >
> >>
> model.add("account",accountProperty).dataType(dt).label("Account").sortable(false);
> >> >
> >> > However, it throws NullPointerException without further detail.
> >> >
> >> > Caused by: java.lang.NullPointerException
> >> >         at
> >> > org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
> >> >         at
> >> > $PropertyConduit_12400839bf9.get($PropertyConduit_12400839bf9.java)
> >> >         at
> >> >
> >>
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
> >> >         ... 91 more
> >> >
> >> > What additional information I need to provide (or anything is missing)
> >> so
> >> > that it won't throw this error?
> >> >
> >> > Thanks for help.
> >> >
> >> >
> >> >
> >> > Thiago H. de Paula Figueiredo wrote:
> >> >>
> >> >> Em Wed, 23 Sep 2009 17:58:08 -0300, neo anderson
> >> >> <ja...@yahoo.co.uk> escreveu:
> >> >>
> >> >>
> >> >>> I have an domain object named User, in which it has a field called
> >> >>> `account'. However, the User object only provide method
> getAccount(),
> >> >>> but does not
> >> >>> provide method setAccount(String account).
> >> >>
> >> >> BeanModelSource (used when a BeanModel is needed and you don't
> provide
> >> >> one) ignores read-only properties. It doesn't care about fields, just
> >> >> about getters and setters.
> >> >>
> >> >>> In the page object e.g. Register, in which I build a BeanModel using
> >> >>> BeanModelSource.create(User.class, ...)
> >> >>
> >> >> This method is deprecated. use createDisplayModel() or
> >> createEditModel()
> >> >> instead.
> >> >>
> >> >>> 1.) in the Register page object, BeanModel does not use
> >> >>> `BeanModel.add("account",null).label("Account").sortable(false)'
> >> method
> >> >>> to create account field.
> >> >>>
> >> >>> Error:
> >> >>> aused by: java.lang.RuntimeException: Bean editor model for User
> does
> >> >>> not
> >> >>> contain a property named 'account'.  Available properties: address,
> >> >>> name,
> >> >>> password, sex.
> >> >>
> >> >> You can't reorder a model using some property that doesn't exist.
> >> >>
> >> >>> Caused by: java.lang.RuntimeException: Bean editor model for User
> >> >>> already
> >> >>> contains a property model for property 'account'.
> >> >>
> >> >> You can't add the same property twice in the same model.
> >> >>
> >> >>> What is the correct way to add a column that the User object doesn't
> >> >>> provide get/set method at the same time?
> >> >>
> >> >> For BeanEditForm or BeanEditor, you'll need to provide your own
> >> >> PropertyConduit to model.add(String property, PropertyConduit
> >> conduit).
> >> >>
> >> >> --
> >> >> Thiago H. de Paula Figueiredo
> >> >> Independent Java consultant, developer, and instructor
> >> >> http://www.arsmachina.com.br/thiago
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25644707.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
> >> >
> >> >
> >> >
> >> >
> >> > Ce message et les pièces jointes sont confidentiels et réservés à
> >> l'usage
> >> > exclusif de ses destinataires. Il peut également être protégé par le
> >> > secret professionnel. Si vous recevez ce message par erreur, merci
> d'en
> >> > avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
> >> > message ne pouvant être assurée sur Internet, la responsabilité du
> >> groupe
> >> > Atos Origin ne pourra être recherchée quant au contenu de ce message.
> >> Bien
> >> > que les meilleurs efforts soient faits pour maintenir cette
> >> transmission
> >> > exempte de tout virus, l'expéditeur ne donne aucune garantie à cet
> >> égard
> >> > et sa responsabilité ne saurait être recherchée pour tout dommage
> >> > résultant d'un virus transmis.
> >> >
> >> > This e-mail and the documents attached are confidential and intended
> >> > solely for the addressee; it may also be privileged. If you receive
> >> this
> >> > e-mail in error, please notify the sender immediately and destroy it.
> >> As
> >> > its integrity cannot be secured on the Internet, the Atos Origin group
> >> > liability cannot be triggered for the message content. Although the
> >> sender
> >> > endeavours to maintain a computer virus-free network, the sender does
> >> not
> >> > warrant that this transmission is virus-free and will not be liable
> for
> >> > any damages resulting from any virus transmitted.
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25645385.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
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25652604.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: Bean editor model for User already contains a property model for property 'account'

Posted by neo anderson <ja...@yahoo.co.uk>.

Thanks for your reply. But when adding the method

    model.add("account").label("Account").sortable(false);

The error occurrs after clicking the beaneditform button, the log shows the
following exception:

[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed
with uncaught exception: Failure reading parameter 'model' of component
Register:beaneditform: Bean editor model for example.domain.User already
contains a property model for property 'account'.
...
...
Caused by: java.lang.RuntimeException: Bean editor model for
example.domain.User already contains a property model for property
'account'.
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.validateNewPropertyName(BeanModelImpl.java:87)
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:128)
	at
org.apache.tapestry5.internal.beaneditor.BeanModelImpl.add(BeanModelImpl.java:79)
	at org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
	at $PropertyConduit_1240259d749.get($PropertyConduit_1240259d749.java)
	at
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
	... 74 more


It looks like the BeanModel already contains the proerty account. I am
really confused because no matter I add or do not add a new property, the
exception will always be thrown. What place may I go wrong? Or is there any
example I can check if anything I miss?

Thank you very much. 



cordenier christophe wrote:
> 
> To add a synthetic property, you only have to call add(propertyName) on
> the
> BeanModel.
> 
> By setting the datatype on the resulting PropertyModel or by using
> t:parameter, you will be able to create the display for the corresponding
> property in your beaneditform.
> 
> 2009/9/28 neo anderson <ja...@yahoo.co.uk>
> 
>>
>> It is the line where PropertyConduitSource (variable source.create() ...
>> )
>> create synthetic property account as the following code.
>>
>>                PropertyConduit accountProperty =
>> source.create(User.class,
>> "account");
>>
>> Is this the right way to create PropertyConduit? I tried to change it
>> using
>> String.class, but the error is the same (NullPointerException). I think
>> there should have something I miss, but that's the method I found on the
>> mailinglist. I am confused indeed.
>>
>>
>> http://www.nabble.com/T5%3A-Working-with-BeanModel-td18231888.html#a18352011
>>
>>
>>
>>
>> ccordenier wrote:
>> >
>> > What corresponds to line 92 in your code ?
>> >
>> > -----Message d'origine-----
>> > De : neo anderson [mailto:javadeveloper999@yahoo.co.uk]
>> > Envoyé : lundi 28 septembre 2009 14:23
>> > À : users@tapestry.apache.org
>> > Objet : Re: Bean editor model for User already contains a property
>> model
>> > for property 'account'
>> >
>> >
>> >
>> > Now I use the folloing method to create synthetic property
>> >
>> >                 PropertyConduit accountProperty =
>> > source.create(User.class, "account");
>> >                 ClassPropertyAdapter cpa =
>> access.getAdapter(User.class);
>> >                 PropertyAdapter pa = cpa.getPropertyAdapter("account");
>> >                 String dt = analyzer.identifyDataType(pa);
>> >
>> >
>> model.add("account",accountProperty).dataType(dt).label("Account").sortable(false);
>> >
>> > However, it throws NullPointerException without further detail.
>> >
>> > Caused by: java.lang.NullPointerException
>> >         at
>> > org.jecommerce.pages.Register.getRegisterModel(Register.java:92)
>> >         at
>> > $PropertyConduit_12400839bf9.get($PropertyConduit_12400839bf9.java)
>> >         at
>> >
>> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
>> >         ... 91 more
>> >
>> > What additional information I need to provide (or anything is missing)
>> so
>> > that it won't throw this error?
>> >
>> > Thanks for help.
>> >
>> >
>> >
>> > Thiago H. de Paula Figueiredo wrote:
>> >>
>> >> Em Wed, 23 Sep 2009 17:58:08 -0300, neo anderson
>> >> <ja...@yahoo.co.uk> escreveu:
>> >>
>> >>
>> >>> I have an domain object named User, in which it has a field called
>> >>> `account'. However, the User object only provide method getAccount(),
>> >>> but does not
>> >>> provide method setAccount(String account).
>> >>
>> >> BeanModelSource (used when a BeanModel is needed and you don't provide
>> >> one) ignores read-only properties. It doesn't care about fields, just
>> >> about getters and setters.
>> >>
>> >>> In the page object e.g. Register, in which I build a BeanModel using
>> >>> BeanModelSource.create(User.class, ...)
>> >>
>> >> This method is deprecated. use createDisplayModel() or
>> createEditModel()
>> >> instead.
>> >>
>> >>> 1.) in the Register page object, BeanModel does not use
>> >>> `BeanModel.add("account",null).label("Account").sortable(false)'
>> method
>> >>> to create account field.
>> >>>
>> >>> Error:
>> >>> aused by: java.lang.RuntimeException: Bean editor model for User does
>> >>> not
>> >>> contain a property named 'account'.  Available properties: address,
>> >>> name,
>> >>> password, sex.
>> >>
>> >> You can't reorder a model using some property that doesn't exist.
>> >>
>> >>> Caused by: java.lang.RuntimeException: Bean editor model for User
>> >>> already
>> >>> contains a property model for property 'account'.
>> >>
>> >> You can't add the same property twice in the same model.
>> >>
>> >>> What is the correct way to add a column that the User object doesn't
>> >>> provide get/set method at the same time?
>> >>
>> >> For BeanEditForm or BeanEditor, you'll need to provide your own
>> >> PropertyConduit to model.add(String property, PropertyConduit
>> conduit).
>> >>
>> >> --
>> >> Thiago H. de Paula Figueiredo
>> >> Independent Java consultant, developer, and instructor
>> >> http://www.arsmachina.com.br/thiago
>> >>
>> >> ---------------------------------------------------------------------
>> >> 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25644707.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
>> >
>> >
>> >
>> >
>> > Ce message et les pièces jointes sont confidentiels et réservés à
>> l'usage
>> > exclusif de ses destinataires. Il peut également être protégé par le
>> > secret professionnel. Si vous recevez ce message par erreur, merci d'en
>> > avertir immédiatement l'expéditeur et de le détruire. L'intégrité du
>> > message ne pouvant être assurée sur Internet, la responsabilité du
>> groupe
>> > Atos Origin ne pourra être recherchée quant au contenu de ce message.
>> Bien
>> > que les meilleurs efforts soient faits pour maintenir cette
>> transmission
>> > exempte de tout virus, l'expéditeur ne donne aucune garantie à cet
>> égard
>> > et sa responsabilité ne saurait être recherchée pour tout dommage
>> > résultant d'un virus transmis.
>> >
>> > This e-mail and the documents attached are confidential and intended
>> > solely for the addressee; it may also be privileged. If you receive
>> this
>> > e-mail in error, please notify the sender immediately and destroy it.
>> As
>> > its integrity cannot be secured on the Internet, the Atos Origin group
>> > liability cannot be triggered for the message content. Although the
>> sender
>> > endeavours to maintain a computer virus-free network, the sender does
>> not
>> > warrant that this transmission is virus-free and will not be liable for
>> > any damages resulting from any virus transmitted.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25645385.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Bean-editor-model-for-User-already-contains-a-property-model-for-property-%27account%27-tp25531292p25652604.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