You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by jaques robert <mo...@yahoo.fr> on 2010/03/24 13:20:43 UTC
Could not find a coercion (T5)
Hi,
I've got a simple T5 file with the following loop :
<<
<form t:type="form" t:id="inputs">
<t:Loop t:source="processTypes" t:value="processType">
<div id="div_processus_${processType.processTypeDN}" style="display: block">
<a href="#" onclick="javascript:foldOrUnfold('div_processus_${processType.processTypeDN}')">${processType.processType} (${processType.processTypeDN})</a>
<t:Loop t:source="processType.documentTypes" t:value="documentType">
<div id="div_documenttype_${documentType.documentTypeDn}" style="display: block">
<a href="#" onclick="javascript:foldOrUnfold('div_documenttype_${documentType.documentTypeDn}')">
${documentType.documentType} (${documentType.documentTypeDn})
</a>
...
..
</t:Loop>
...
</t:Loop>
<t:submit t:id="save" value="Sauvegarder"/>
<t:submit t:id="retour" value="Retour"/>
</form>
>>
When accessing this page with a simple get via the browser it works well however when I click on the submit button included in this page, I've got the following error of Type coercion.
<<
org.apache.tapestry5.ioc.internal.util.TapestryException
Could not find a coercion from type java.lang.String to type com.wizard.data.model.ExportProcessType.
Available coercions: Double --> Float, Float --> Double, Long --> Boolean, Long --> Byte, Long --> Double, Long --> Integer,
Long --> Short, Number --> Long, Object --> Object[], Object --> String, Object --> java.util.List, Object[] --> java.util.List, String --> Boolean,
String --> Double, String --> Long, String --> java.io.File, String --> java.math.BigDecimal, String --> java.math.BigInteger, String --> java.text.DateFormat,
String --> java.util.regex.Pattern, String --> org.apache.tapestry5.Renderable, String --> org.apache.tapestry5.SelectModel, String --> org.apache.tapestry5.corelib.LoopFormState,
String --> org.apache.tapestry5.corelib.data.BlankOption, String --> org.apache.tapestry5.corelib.data.GridPagerPosition, String --> org.apache.tapestry5.corelib.data.InsertPosition,
String --> org.apache.tapestry5.ioc.Resource, String --> org.apache.tapestry5.ioc.util.TimeInterval, boolean[] --> java.util.List, byte[] --> java.util.List,
char[] --> java.util.List, double[] --> java.util.List, float[] --> java.util.List, int[] --> java.util.List, java.math.BigDecimal --> Double, java.util.Collection --> Boolean,
java.util.Collection --> Object[], java.util.Collection --> org.apache.tapestry5.grid.GridDataSource, java.util.List --> org.apache.tapestry5.SelectModel, java.util.Map --> org.apache.tapestry5.SelectModel,
long[] --> java.util.List, null --> Boolean, null --> org.apache.tapestry5.grid.GridDataSource, org.apache.tapestry5.ComponentResources --> org.apache.tapestry5.PropertyOverrides,
org.apache.tapestry5.PrimaryKeyEncoder --> org.apache.tapestry5.ValueEncoder, org.apache.tapestry5.Renderable --> org.apache.tapestry5.Block,
org.apache.tapestry5.Renderable --> org.apache.tapestry5.runtime.RenderCommand, org.apache.tapestry5.ioc.util.TimeInterval --> Long,
org.apache.tapestry5.runtime.ComponentResourcesAware --> org.apache.tapestry5.ComponentResources, short[] --> java.util.List.
>>
I cannot understand why this error occurs. Have you got any pointers which could guide me toward this error ?
Regards,
Mondes_engloutis.
Re: Could not find a coercion (T5)
Posted by Michael Gentry <mg...@masslight.net>.
Here is one from our code (I made no attempt to map it to yours, but
hopefully it'll give you an idea):
@Property
private final ValueEncoder<SurveyAnswer> answerEncoder = new
ValueEncoder<SurveyAnswer>() {
@Override
public String toClient(SurveyAnswer answer) {
int in = question.getAnswers().indexOf(answer);
return String.valueOf(in);
}
@Override
public SurveyAnswer toValue(String str) {
if(StringUtils.isNotBlank(str)){
return question.getAnswers().get(Integer.parseInt(str));
}else{
return null;
}
}
};
This one basically uses the integer index into a list to be passed
in/out of the ValueEncoder.
mrg
On Wed, Mar 24, 2010 at 9:16 AM, jaques robert
<mo...@yahoo.fr> wrote:
> Thanks a lot.
>
> <<
> If you're editing ExportProcessType instances, implement a ValueEncoder
> for that type and use pass it to the encoder parameter of Loop.
> If
> you're not, try formState="none" in the Loop.
>>>
>
> Have you got some samples about using ValueEncoder ?
>
> Regards,
> Mondes_engloutis.
>
> --- En date de : Mer 24.3.10, Thiago H. de Paula Figueiredo <th...@gmail.com> a écrit :
>
> De: Thiago H. de Paula Figueiredo <th...@gmail.com>
> Objet: Re: Could not find a coercion (T5)
> À: "Tapestry users" <us...@tapestry.apache.org>
> Date: Mercredi 24 mars 2010, 13h40
>
> On Wed, 24 Mar 2010 09:20:43 -0300, jaques robert <mo...@yahoo.fr> wrote:
>
>> Hi,
>
> Hi!
>
>> org.apache.tapestry5.ioc.internal.util.TapestryException
>> Could not find a coercion from type java.lang.String to type com.wizard.data.model.ExportProcessType.
>
> If you're editing ExportProcessType instances, implement a ValueEncoder for that type and use pass it to the encoder parameter of Loop.
> If you're not, try formState="none" in the Loop.
>
> --Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
> Owner, software architect and developer, 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
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Could not find a coercion (T5)
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 24 Mar 2010 10:56:00 -0300, jaques robert
<mo...@yahoo.fr> wrote:
> So it works for the display, however it
> seems that it isn't sufficiant for update ... Why ?
Because Tapestry needs to keep information about the looped objects so
they can be correctly updated when the form is submitted.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, 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: Could not find a coercion (T5)
Posted by jaques robert <mo...@yahoo.fr>.
I don't understand the need of use of coercion inside loop. Indeed
in my loop I define :
<<
<t:Loop t:source="processTypes"
t:value="processType" formState="none">
<div
id="div_processus_${processType.processTypeDN}" style="display:
block">
<a href="#"
onclick="javascript:foldOrUnfold('div_processus_${processType.processTypeDN}')">${processType.processType}
(${processType.processTypeDN})</a>
<t:Loop t:source="processType.documentTypes" t:value="documentType"
formState="none">
<div
id="div_documenttype_${documentType.documentTypeDn}" style="display:
block">
>>
So it works for the display, however it
seems that it isn't sufficiant for update ... Why ? The samples from jumpstart don't make use of such kind of valueencoder
Regards,
Mondes_engloutis.
--- En date de : Mer 24.3.10, Thiago H. de Paula Figueiredo <th...@gmail.com> a écrit :
De: Thiago H. de Paula Figueiredo <th...@gmail.com>
Objet: Re: Could not find a coercion (T5)
À: "Tapestry users" <us...@tapestry.apache.org>
Date: Mercredi 24 mars 2010, 14h22
On Wed, 24 Mar 2010 10:16:10 -0300, jaques robert <mo...@yahoo.fr> wrote:
> Have you got some samples about using ValueEncoder ?
It's quite easy. toClient() should return the id of the received object. toValue() should return the object that has a given id. This last method is usually implemented using a database lookup (using a DAO or otherwise). Just do what the Javadoc tells you to do.
--Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, software architect and developer, 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: Could not find a coercion (T5)
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 24 Mar 2010 10:16:10 -0300, jaques robert
<mo...@yahoo.fr> wrote:
> Have you got some samples about using ValueEncoder ?
It's quite easy. toClient() should return the id of the received object.
toValue() should return the object that has a given id. This last method
is usually implemented using a database lookup (using a DAO or otherwise).
Just do what the Javadoc tells you to do.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, 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: Could not find a coercion (T5)
Posted by jaques robert <mo...@yahoo.fr>.
Thanks a lot.
<<
If you're editing ExportProcessType instances, implement a ValueEncoder
for that type and use pass it to the encoder parameter of Loop.
If
you're not, try formState="none" in the Loop.
>>
Have you got some samples about using ValueEncoder ?
Regards,
Mondes_engloutis.
--- En date de : Mer 24.3.10, Thiago H. de Paula Figueiredo <th...@gmail.com> a écrit :
De: Thiago H. de Paula Figueiredo <th...@gmail.com>
Objet: Re: Could not find a coercion (T5)
À: "Tapestry users" <us...@tapestry.apache.org>
Date: Mercredi 24 mars 2010, 13h40
On Wed, 24 Mar 2010 09:20:43 -0300, jaques robert <mo...@yahoo.fr> wrote:
> Hi,
Hi!
> org.apache.tapestry5.ioc.internal.util.TapestryException
> Could not find a coercion from type java.lang.String to type com.wizard.data.model.ExportProcessType.
If you're editing ExportProcessType instances, implement a ValueEncoder for that type and use pass it to the encoder parameter of Loop.
If you're not, try formState="none" in the Loop.
--Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, software architect and developer, 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: Could not find a coercion (T5)
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 24 Mar 2010 09:20:43 -0300, jaques robert
<mo...@yahoo.fr> wrote:
> Hi,
Hi!
> org.apache.tapestry5.ioc.internal.util.TapestryException
> Could not find a coercion from type java.lang.String to type
> com.wizard.data.model.ExportProcessType.
If you're editing ExportProcessType instances, implement a ValueEncoder
for that type and use pass it to the encoder parameter of Loop.
If you're not, try formState="none" in the Loop.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, 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