You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Massimo Lusetti <ml...@gmail.com> on 2008/06/04 11:28:14 UTC

Contributing to BeanBlockSource and HibernateEntityValueEncoder

The HibernateEntityValueEncoder (very nice feature!) does not work
properly when needs to look up a property from a PropertyEditContext
from within a BeanBlock contributed to the main BeanBlockSource.

I mean i got an entity Customers which has a property Provinces which
is another entity. When it comes to BeanEditor it doesn't know how to
render a property of type Provinces so i contribute a BeanBlock to
instruments it how to deal with that data type.
The Provinces property is rendered as a Select so i expect the
HibernateEntytyValueEncoder to encode my Provinces as their own id but
it does not. Contrary if i put a <t:parameter> within the BeanEditor
with the same select as the one from the BeanBlock it does encode the
Provinces entity in the correct way.

So i guess this has something to do with the PropertyEditContext. Does
anyone have experienced the same behavior?

-- 
Massimo
http://meridio.blogspot.com

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


Re: Contributing to BeanBlockSource and HibernateEntityValueEncoder

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

I finally was able to make it work.
I cant' believe how simple it was, and how long it took me to figure it out.
The solutions is to provide a ValueEncoder to the BeanBlock (so simple!)
Here is my code:

       <t:select t:id="caetg" model="selectModel"
value="context.propertyValue" encoder="valueEncoderForProperty"/>

then:

	public ValueEncoder getValueEncoderForProperty()
	{
		return valueEncoderSource.getValueEncoder(context.getPropertyType());
	}


It works beautifully now!

Saludos.
Alejandro.


On Mon, Jun 9, 2008 at 9:44 AM, Massimo Lusetti <ml...@gmail.com> wrote:
> On Fri, Jun 6, 2008 at 10:58 PM, Alejandro Scandroli
> <al...@gmail.com> wrote:
>
>> Hi Massimo
>>
>> I'm experiencing the same thing. I'm trying to create an editor for
>> properties annotated with "@ManyToOne"
>> The BeanBlockContribution renders ok, but when I submit the form I get
>> an exception:
>>
>> org.apache.tapestry5.runtime.ComponentEventException
>> Failure writing parameter 'value' of component Editors:caetg: Could
>> not find a coercion from type java.lang.String to type
>> org.apache.tapestry.tutorial.model.Caetg. Available coercions: .....
>> (you know the rest)
>>
>>
>> As you said It works perfectly fine if I put the same code as a
>> <t:parameter> within the beaneditform
>> I haven't found a solution yet, but I'm looking.
>
> I've commented on a issue fired by Howard asking if that issue can
> cause influence in this behavior, we will see if we need to fire
> another issue.
>
> Regards
> --
> Massimo
> http://meridio.blogspot.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: Contributing to BeanBlockSource and HibernateEntityValueEncoder

Posted by Massimo Lusetti <ml...@gmail.com>.
On Fri, Jun 6, 2008 at 10:58 PM, Alejandro Scandroli
<al...@gmail.com> wrote:

> Hi Massimo
>
> I'm experiencing the same thing. I'm trying to create an editor for
> properties annotated with "@ManyToOne"
> The BeanBlockContribution renders ok, but when I submit the form I get
> an exception:
>
> org.apache.tapestry5.runtime.ComponentEventException
> Failure writing parameter 'value' of component Editors:caetg: Could
> not find a coercion from type java.lang.String to type
> org.apache.tapestry.tutorial.model.Caetg. Available coercions: .....
> (you know the rest)
>
>
> As you said It works perfectly fine if I put the same code as a
> <t:parameter> within the beaneditform
> I haven't found a solution yet, but I'm looking.

I've commented on a issue fired by Howard asking if that issue can
cause influence in this behavior, we will see if we need to fire
another issue.

Regards
-- 
Massimo
http://meridio.blogspot.com

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


Re: Contributing to BeanBlockSource and HibernateEntityValueEncoder

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

I'm experiencing the same thing. I'm trying to create an editor for
properties annotated with "@ManyToOne"
The BeanBlockContribution renders ok, but when I submit the form I get
an exception:

org.apache.tapestry5.runtime.ComponentEventException
Failure writing parameter 'value' of component Editors:caetg: Could
not find a coercion from type java.lang.String to type
org.apache.tapestry.tutorial.model.Caetg. Available coercions: .....
(you know the rest)


As you said It works perfectly fine if I put the same code as a
<t:parameter> within the beaneditform
I haven't found a solution yet, but I'm looking.

Salutti.
Alejandro.


On Wed, Jun 4, 2008 at 11:28 AM, Massimo Lusetti <ml...@gmail.com> wrote:
> The HibernateEntityValueEncoder (very nice feature!) does not work
> properly when needs to look up a property from a PropertyEditContext
> from within a BeanBlock contributed to the main BeanBlockSource.
>
> I mean i got an entity Customers which has a property Provinces which
> is another entity. When it comes to BeanEditor it doesn't know how to
> render a property of type Provinces so i contribute a BeanBlock to
> instruments it how to deal with that data type.
> The Provinces property is rendered as a Select so i expect the
> HibernateEntytyValueEncoder to encode my Provinces as their own id but
> it does not. Contrary if i put a <t:parameter> within the BeanEditor
> with the same select as the one from the BeanBlock it does encode the
> Provinces entity in the correct way.
>
> So i guess this has something to do with the PropertyEditContext. Does
> anyone have experienced the same behavior?
>
> --
> Massimo
> http://meridio.blogspot.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