m!ga
2009-06-12 15:23:58 UTC
Hi everyone. We just started migration from tapestry 5.0 to 5.1 and found a
lot of strange exeptions. Here is one of them.
page class:
public class Test {
@SuppressWarnings({"unused", "UnusedDeclaration"})
@Component(id = "form")
private Form form;
@Property
private SomeClass someClass;
@Property
private SomeClass[] someClasses = {new SomeClass("1"),new
SomeClass("2"),new SomeClass("3"),new SomeClass("4"),new SomeClass("5")};
public class SomeClass
{
private String s = "SomeClass ";
public SomeClass(String s)
{
this.s += s;
}
public String toString()
{
return s;
}
}
}
tml file:
<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<form t:id="form">
<t:loop source="someClasses" value="someClass">
<div>${someClass}</div>
</t:loop>
<input t:type="submit" value="Push me" />
</form>
</div>
Works fine unless you try to submit form. It throws something like that:
Caused by: java.lang.IllegalArgumentException: Could not find a coercion
from type java.lang.String to type ru.kupivip.pages.shop.Test$SomeClass.
Available coe
rcions: Double --> Float, Float --> Double...bla bla bla...
It can be solved by not-so-good-looking-code like this:
private SomeClass someClass;
public Object getSomeClass()
{
return someClass;
}
public void setSomeClass(Object maybeSomeClass)
{
someClass = maybeSomeClass != null && maybeSomeClass instanceof SomeClass
? (SomeClass) maybeSomeClass : null;
}
I've debugged the setter ant it seems that it is called 2 times:
1st time after onActivate phase
2nd time after onSubmit/onActivate
and 1st time the argument maybeSomeClass is not instance of SomeClass but
its toString() value!
lot of strange exeptions. Here is one of them.
page class:
public class Test {
@SuppressWarnings({"unused", "UnusedDeclaration"})
@Component(id = "form")
private Form form;
@Property
private SomeClass someClass;
@Property
private SomeClass[] someClasses = {new SomeClass("1"),new
SomeClass("2"),new SomeClass("3"),new SomeClass("4"),new SomeClass("5")};
public class SomeClass
{
private String s = "SomeClass ";
public SomeClass(String s)
{
this.s += s;
}
public String toString()
{
return s;
}
}
}
tml file:
<div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
<form t:id="form">
<t:loop source="someClasses" value="someClass">
<div>${someClass}</div>
</t:loop>
<input t:type="submit" value="Push me" />
</form>
</div>
Works fine unless you try to submit form. It throws something like that:
Caused by: java.lang.IllegalArgumentException: Could not find a coercion
from type java.lang.String to type ru.kupivip.pages.shop.Test$SomeClass.
Available coe
rcions: Double --> Float, Float --> Double...bla bla bla...
It can be solved by not-so-good-looking-code like this:
private SomeClass someClass;
public Object getSomeClass()
{
return someClass;
}
public void setSomeClass(Object maybeSomeClass)
{
someClass = maybeSomeClass != null && maybeSomeClass instanceof SomeClass
? (SomeClass) maybeSomeClass : null;
}
I've debugged the setter ant it seems that it is called 2 times:
1st time after onActivate phase
2nd time after onSubmit/onActivate
and 1st time the argument maybeSomeClass is not instance of SomeClass but
its toString() value!
--
View this message in context: http://www.nabble.com/Tapestry-5.1-exception--%22Could-not-find-a-coercion-from-type-...%22-on-form-submit-tp24001080p24001080.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tapestry.apache.org
For additional commands, e-mail: users-***@tapestry.apache.org
View this message in context: http://www.nabble.com/Tapestry-5.1-exception--%22Could-not-find-a-coercion-from-type-...%22-on-form-submit-tp24001080p24001080.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tapestry.apache.org
For additional commands, e-mail: users-***@tapestry.apache.org