You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thomas Cucchietti <th...@gmail.com> on 2012/10/19 12:09:05 UTC

[T5.3]Loop, Radiogroup, Coercion, again...

Hello everybody!

I'm slowly sinking into despair with my current problem, involving the use
of a loop containing forms, that contains a radiogroup for which a loop is
used to render the radio buttons.

As a scheme is always more explicative, my template structure is :

<t:loop source="entityList" value="currentEntity">

   <t:form t:id="entityForm" context="currentEntity.id">

      <t:radiogroup value="selectedSubEntity">

         <t:loop source="currentEntity.subEntityList"
value="currentSubEntity">

            <t:label for="radio">${currentSubEntityLabel}</label>
            <t:radio t:id="radio" value=${currentSubEntity}/>

         </t:loop>

      </t:radiogroup>

       <t:submit value="submit">Scanner</t:submit>

   </t:form>

</t:loop>

(For information, an Entity contains a list of SubEntity)

The point is, that when I submit one of the generated forms, I have
a TapestryException with message
"Could not find a coercion from type java.lang.String to type
my.package.SubEntity"
while the radiogroup line in template is highlighted.

I know this should not happen as I have contributed to valueEncoderSource
in order to have my Entity and SubEntity values encoded automatically.

I tried to define the "encoder" parameter of the loop manually, but this
has no effect.

Finally, searching through the mail archives, I found a similar problem
where the solution seemed to be related to the "formState" parameter of the
loops, but after many tries, this has no effect too.

Does someone have an idea to save me as my sanity is really getting tested
with this one...

Thanks in advance,
Thomas

Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thomas Cucchietti <th...@gmail.com>.
Ok I got it!

The SubEntity ValueEncoderFactory was contributed to the
valueEncoderSource, but for the wrong class... Real name of SubEntity is
pretty long and there was a confusion with another class (with a very close
name).

Thanks for your suggestions, they finally led me to the real error!

Regards,
Thomas

2012/10/19 Thomas Cucchietti <th...@gmail.com>

> This is precisely the problem :
>
> The ValueEncoder is already provided in the AppModule, but it isn't taken
> into account!
>
> Like I wrote before, I then tried to force the use of the encoder by
> setting explicitely the encoder parameter of my loop, but it doesn't work
> either...
>
> 2012/10/19 Thiago H de Paula Figueiredo <th...@gmail.com>
>
>> On Fri, 19 Oct 2012 09:42:08 -0300, Thomas Cucchietti <
>> thomas.cucchietti@gmail.com> wrote:
>>
>>  I'm not using tapestry-hibernate (tech. stack is
>>> Tapestry/Spring/Hibernate)
>>> but currentSubEntity is an hibernate entitiy (annotated by
>>> javax.persistence.Entity).
>>>
>>> PS: I didn't see your previous answer while typing my second mail.
>>> Obviously, I thank you too for trying to help :)
>>>
>>
>> Oops, I'm sorry for overlooking that. :P
>>
>> You'll need to provide a ValueEncoder for currentSubEntity's class
>> through the encoder parameter in RadioGroup or defining this ValueEncoder
>> in a global manner (so you don't need to specify it in each form field
>> component that uses it) through contributing it to the ValueEncoderSource
>> service. I believe JumpStart has at least one example of each. Anyway, all
>> you need to know is in the ValueEncoder JavaDoc. Or you can take a look at
>> how tapestry-hibernate is implemented and adapt it for your stack and have
>> ValueEncoders provided automatically for all your entities.
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thomas Cucchietti <th...@gmail.com>.
This is precisely the problem :

The ValueEncoder is already provided in the AppModule, but it isn't taken
into account!

Like I wrote before, I then tried to force the use of the encoder by
setting explicitely the encoder parameter of my loop, but it doesn't work
either...

2012/10/19 Thiago H de Paula Figueiredo <th...@gmail.com>

> On Fri, 19 Oct 2012 09:42:08 -0300, Thomas Cucchietti <
> thomas.cucchietti@gmail.com> wrote:
>
>  I'm not using tapestry-hibernate (tech. stack is
>> Tapestry/Spring/Hibernate)
>> but currentSubEntity is an hibernate entitiy (annotated by
>> javax.persistence.Entity).
>>
>> PS: I didn't see your previous answer while typing my second mail.
>> Obviously, I thank you too for trying to help :)
>>
>
> Oops, I'm sorry for overlooking that. :P
>
> You'll need to provide a ValueEncoder for currentSubEntity's class through
> the encoder parameter in RadioGroup or defining this ValueEncoder in a
> global manner (so you don't need to specify it in each form field component
> that uses it) through contributing it to the ValueEncoderSource service. I
> believe JumpStart has at least one example of each. Anyway, all you need to
> know is in the ValueEncoder JavaDoc. Or you can take a look at how
> tapestry-hibernate is implemented and adapt it for your stack and have
> ValueEncoders provided automatically for all your entities.
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 19 Oct 2012 09:42:08 -0300, Thomas Cucchietti  
<th...@gmail.com> wrote:

> I'm not using tapestry-hibernate (tech. stack is  
> Tapestry/Spring/Hibernate)
> but currentSubEntity is an hibernate entitiy (annotated by
> javax.persistence.Entity).
>
> PS: I didn't see your previous answer while typing my second mail.
> Obviously, I thank you too for trying to help :)

Oops, I'm sorry for overlooking that. :P

You'll need to provide a ValueEncoder for currentSubEntity's class through  
the encoder parameter in RadioGroup or defining this ValueEncoder in a  
global manner (so you don't need to specify it in each form field  
component that uses it) through contributing it to the ValueEncoderSource  
service. I believe JumpStart has at least one example of each. Anyway, all  
you need to know is in the ValueEncoder JavaDoc. Or you can take a look at  
how tapestry-hibernate is implemented and adapt it for your stack and have  
ValueEncoders provided automatically for all your entities.

-- 
Thiago H. de Paula Figueiredo

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


Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thomas Cucchietti <th...@gmail.com>.
I'm not using tapestry-hibernate (tech. stack is Tapestry/Spring/Hibernate)
but currentSubEntity is an hibernate entitiy (annotated by
javax.persistence.Entity).

PS: I didn't see your previous answer while typing my second mail.
Obviously, I thank you too for trying to help :)

2012/10/19 Thiago H de Paula Figueiredo <th...@gmail.com>

> On Fri, 19 Oct 2012 09:15:40 -0300, Thomas Cucchietti <
> thomas.cucchietti@gmail.com> wrote:
>
>  Thanks for the 3 first answers, but this was just a typing error when
>> preparing this mail : i didn't copy/paste my code.
>> <t:radio t:id="radio" value="currentSubEntity"/>
>>
>
> Are you using tapestry-hibernate? Is the type of currentSubEntity a
> Hibernate entity?
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 19 Oct 2012 09:15:40 -0300, Thomas Cucchietti  
<th...@gmail.com> wrote:

> Thanks for the 3 first answers, but this was just a typing error when
> preparing this mail : i didn't copy/paste my code.
> <t:radio t:id="radio" value="currentSubEntity"/>

Are you using tapestry-hibernate? Is the type of currentSubEntity a  
Hibernate entity?

-- 
Thiago H. de Paula Figueiredo

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


Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thomas Cucchietti <th...@gmail.com>.
Thanks for the 3 first answers, but this was just a typing error when
preparing this mail : i didn't copy/paste my code.

I checked and, indeed, in my page I wrote :

<t:radio t:id="radio" value="currentSubEntity"/>

Sorry for this!

However, my problem isn't solved yet :/

2012/10/19 Thiago H de Paula Figueiredo <th...@gmail.com>

> On Fri, 19 Oct 2012 07:38:44 -0300, Lance Java <la...@googlemail.com>
> wrote:
>
>  I disagree, I think that the root of the problem is ${...}. Tapestry will
>> convert the entity to a string before passing it to the radio component.
>>
>
> Yep. It seems that I haven't repeated this enough times: never, never,
> never ever use ${} expansions when passing values to parameters. :P
>
> --
> Thiago H. de Paula Figueiredo
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 19 Oct 2012 07:38:44 -0300, Lance Java <la...@googlemail.com>  
wrote:

> I disagree, I think that the root of the problem is ${...}. Tapestry will
> convert the entity to a string before passing it to the radio component.

Yep. It seems that I haven't repeated this enough times: never, never,  
never ever use ${} expansions when passing values to parameters. :P

-- 
Thiago H. de Paula Figueiredo

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


Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Lance Java <la...@googlemail.com>.
I disagree, I think that the root of the problem is ${...}. Tapestry will
convert the entity to a string before passing it to the radio component.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-3-Loop-Radiogroup-Coercion-again-tp5717055p5717058.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: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Peter Wendorff <we...@uni-paderborn.de>.
Am 19.10.2012 12:09, schrieb Thomas Cucchietti:
> Hello everybody!
Hi Thomas.
> <t:radio t:id="radio" value=${currentSubEntity}/>
> The point is, that when I submit one of the generated forms, I have
> a TapestryException with message
> "Could not find a coercion from type java.lang.String to type
> my.package.SubEntity"
> while the radiogroup line in template is highlighted.
surround the extension by quotation marks, as for every other parameter:
<t:radio t:id="radio" value="${currentSubEntity}"/>
That should solve your problem.

regards
Peter

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


Re: [T5.3]Loop, Radiogroup, Coercion, again...

Posted by Lance Java <la...@googlemail.com>.
This line is wrong
<t:radio t:id="radio" value=${currentSubEntity}/> 

It should be
<t:radio t:id="radio" value="currentSubEntity" /> 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-3-Loop-Radiogroup-Coercion-again-tp5717055p5717056.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