You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by rosecorp <ro...@gmail.com> on 2012/10/19 22:36:53 UTC

Coercion exception in loop for Map

Hi Guys, 

I am trying to sort out problem with coercion exception when I send a form
using GenericSelectModel but I'm not getting anywhere I'm afraid. Could you
give me a hand with that?

This is my Java code:

private Map<Filter, GenericSelectModel&lt;? extends Filter>> fieldMap;
   
@Property
private Filter key;
    
public Set<Filter> getKeys() {
   return fieldMap.keySet();
}
public GenericSelectModel<? extends Filter> getValue(){ 
   return fieldMap.get(key); 
}

where fieldMap is being initialized in @SetupRender with subtypes of Filter
interface and base on Filter type I choose genericSelectModel for it.

tml code:

<t:loop source="keys" value="key">
      <t:select model="value" encoder="value" value="key" formState="none"/>
</t:loop> 


I am getting following exception:

Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could not
find a coercion from type java.lang.String to type zeepp.fieldfilter.Filter.
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:276)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.access$000(TypeCoercerImpl.java:38)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.getCoercion(TypeCoercerImpl.java:94)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:71)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:147)
	at $TypeCoercer_289900c49f8.coerce(Unknown Source)
	at
org.apache.tapestry5.internal.services.TypeCoercedValueEncoderFactory$1.toValue(TypeCoercedValueEncoderFactory.java:45)
	at
org.apache.tapestry5.corelib.components.Loop.restoreStateFromStoredClientValue(Loop.java:470)
	at org.apache.tapestry5.corelib.components.Loop.access$500(Loop.java:64)
	at
org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:185)
	at
org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:174)
	at
org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:661)
 

Thanks!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Coercion-exception-in-loop-for-Map-tp5717072.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: Coercion exception in loop for Map

Posted by "Athneria, Mahendra" <ma...@atos.net>.
With loop use formState property to get rid of below exception.

<t:loop source="keys" value="key" formState ="none">
      <t:select model="value" encoder="value" value="key" formState="none"/>
</t:loop>

Hope it will solve your issue.

Regards,
Mahendra

-----Original Message-----
From: rosecorp [mailto:rosecorp.solutions@gmail.com] 
Sent: Saturday, October 20, 2012 2:07 AM
To: users@tapestry.apache.org
Subject: Coercion exception in loop for Map


Hi Guys, 

I am trying to sort out problem with coercion exception when I send a form
using GenericSelectModel but I'm not getting anywhere I'm afraid. Could you
give me a hand with that?

This is my Java code:

private Map<Filter, GenericSelectModel&lt;? extends Filter>> fieldMap;
   
@Property
private Filter key;
    
public Set<Filter> getKeys() {
   return fieldMap.keySet();
}
public GenericSelectModel<? extends Filter> getValue(){ 
   return fieldMap.get(key); 
}

where fieldMap is being initialized in @SetupRender with subtypes of Filter
interface and base on Filter type I choose genericSelectModel for it.

tml code:

<t:loop source="keys" value="key">
      <t:select model="value" encoder="value" value="key" formState="none"/>
</t:loop> 


I am getting following exception:

Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could not
find a coercion from type java.lang.String to type zeepp.fieldfilter.Filter.
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.findOrCreateCoercion(TypeCoercerImpl.java:276)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.access$000(TypeCoercerImpl.java:38)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.getCoercion(TypeCoercerImpl.java:94)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl$TargetCoercion.coerce(TypeCoercerImpl.java:71)
	at
org.apache.tapestry5.ioc.internal.services.TypeCoercerImpl.coerce(TypeCoercerImpl.java:147)
	at $TypeCoercer_289900c49f8.coerce(Unknown Source)
	at
org.apache.tapestry5.internal.services.TypeCoercedValueEncoderFactory$1.toValue(TypeCoercedValueEncoderFactory.java:45)
	at
org.apache.tapestry5.corelib.components.Loop.restoreStateFromStoredClientValue(Loop.java:470)
	at org.apache.tapestry5.corelib.components.Loop.access$500(Loop.java:64)
	at
org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:185)
	at
org.apache.tapestry5.corelib.components.Loop$RestoreStateFromStoredClientValue.execute(Loop.java:174)
	at
org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:661)
 

Thanks!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Coercion-exception-in-loop-for-Map-tp5717072.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: Coercion exception in loop for Map

Posted by rosecorp <ro...@gmail.com>.
I found a solution for future reference. I was using formState in wrong
place:

<t:loop source="keys" value="key" formState="iteration">
      <t:select model="value" encoder="value" value="key" />
</t:loop>  



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Coercion-exception-in-loop-for-Map-tp5717072p5717073.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