You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nquirynen <na...@pensionarchitects.be> on 2011/03/28 14:03:20 UTC

Generic beaneditorform

I have a page where i can edit 1 object that has been selected to edit. This
object can be a different datatype everytime depending on some properties
set in the page.


//Here i get the right object
public Object getObject() {
	return dao.getDaoForEntityType(entityType).get(objectId);
}
//the beaneditform
t:beaneditform object="object" include="${fields}" /


Ofcourse this results in "Bean editor model for java.lang.Object does not
contain a property named ..."

Any tutorials or examples on this done before, or hints on how to achieve
this are really appreciated. 

Thanks!

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Generic-beaneditorform-tp4267477p4267477.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: Generic beaneditorform

Posted by Taha Hafeez <ta...@gmail.com>.
1) You must return the correct type e.g

public SomeObject getObject(){
    return (SomeObject)dao.getDaoForEntityType(entityType).get(objectId);
}

2) Or you could create your own model and specify it using 'model' parameter

3) (AFAIK) Or wait for 5.3 as it will have this kind of support

regards
Taha



On Mon, Mar 28, 2011 at 5:33 PM, nquirynen <na...@pensionarchitects.be>wrote:

> I have a page where i can edit 1 object that has been selected to edit.
> This
> object can be a different datatype everytime depending on some properties
> set in the page.
>
>
> //Here i get the right object
> public Object getObject() {
>        return dao.getDaoForEntityType(entityType).get(objectId);
> }
> //the beaneditform
> t:beaneditform object="object" include="${fields}" /
>
>
> Ofcourse this results in "Bean editor model for java.lang.Object does not
> contain a property named ..."
>
> Any tutorials or examples on this done before, or hints on how to achieve
> this are really appreciated.
>
> Thanks!
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Generic-beaneditorform-tp4267477p4267477.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: Generic beaneditorform

Posted by Alejandro Scandroli <al...@gmail.com>.
On Mon, Mar 28, 2011 at 4:40 PM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Mon, 28 Mar 2011 11:30:29 -0300, Alejandro Scandroli
> <al...@gmail.com> wrote:
>
>> Hi
>>
>> * The first (and simpler) options is to provide the beanModel via the
>> model parameter.
>> beanModel = beanModelSource.createEditModel(entityType, messages);
>>
>> With this option you can't use the "add", "exclude" or "include"
>> parameters in the template, if you need to change something you will
>> have to modify the beanModel in your Java code.
>
> I can't test it now, but providing your own BeanModel doesn't prevent you
> from using the add, exclude and include parameters at all. It may not make
> much sense, but I'm sure you can use them.
>

Hmmm, maybe I'm doing something wrong, but I wasn't able to make it
work and believe me I've tried.
Also, if you look at the code both methods
BeanEditForm.onPrepareFromForm and BeanEditor.doPrepare will check for
model==null before applying BeanModelUtils.modify. Maybe it's an
unwanted behavior or a side effect, but it looks like you can't mix
them.
Please let me know if you think there is another way.

Saludos.
Alejandro.

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


Re: Generic beaneditorform

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 28 Mar 2011 11:30:29 -0300, Alejandro Scandroli  
<al...@gmail.com> wrote:

> Hi
>
> * The first (and simpler) options is to provide the beanModel via the
> model parameter.
> beanModel = beanModelSource.createEditModel(entityType, messages);
>
> With this option you can't use the "add", "exclude" or "include"
> parameters in the template, if you need to change something you will
> have to modify the beanModel in your Java code.

I can't test it now, but providing your own BeanModel doesn't prevent you  
 from using the add, exclude and include parameters at all. It may not make  
much sense, but I'm sure you can use them.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Generic beaneditorform

Posted by Alejandro Scandroli <al...@gmail.com>.
Hi

* The first (and simpler) options is to provide the beanModel via the
model parameter.
beanModel = beanModelSource.createEditModel(entityType, messages);

With this option you can't use the "add", "exclude" or "include"
parameters in the template, if you need to change something you will
have to modify the beanModel in your Java code.

* Another option (how Tynamo is doing it) is to have a specific
Binding to compute the bindingType on the fly.
Check it out: http://svn.codehaus.org/tynamo/trunk/tapestry-model/tapestry-model-core/src/main/java/org/tynamo/bindings/
If you use this option your component could look something like this:
<t:beaneditform object="mb:object" include="${fields}" ....

Of course in this case the "object" property can't be null (never ever).

I hope it helps.
Cheers.
Alejandro.


On Mon, Mar 28, 2011 at 2:03 PM, nquirynen <na...@pensionarchitects.be> wrote:
> I have a page where i can edit 1 object that has been selected to edit. This
> object can be a different datatype everytime depending on some properties
> set in the page.
>
>
> //Here i get the right object
> public Object getObject() {
>        return dao.getDaoForEntityType(entityType).get(objectId);
> }
> //the beaneditform
> t:beaneditform object="object" include="${fields}" /
>
>
> Ofcourse this results in "Bean editor model for java.lang.Object does not
> contain a property named ..."
>
> Any tutorials or examples on this done before, or hints on how to achieve
> this are really appreciated.
>
> Thanks!
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Generic-beaneditorform-tp4267477p4267477.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