-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5055670
By: gekkio
Hello!
I'm trying to bind an entity bean attribute to a Datebox, but the entity bean uses Joda time which is not supported by Datebox.
It's obvious that I need a TypeConverter to manage the Date<->DateTime object conversion.
I created one but it doesn't seem to work at all. Binding other bean attributes work perfectly, so I think my binding configuration is fine.
Here's my TypeConverter:
public class JodaTimeZkConverter implements TypeConverter {
public DateTime coerceToBean(Object val, Component comp) {
if (val instanceof Date) {
return new DateTime(val);
}
throw new UiException("Converter expects a Date/DateTime object");
}
public Object coerceToUi(Object val, Component comp) {
return null;
}
}
Here's the ZUL fragment:
<datebox value="@{bean.startDate, converter='mypackage.JodaTimeZkConverter'}"
constraint="no empty" />
I did some debugging and confirmed that the converter gets called with proper parameters (val is the Date object I selected in the Datebox).
coerceToBean() returns the relevant DateTime, so it should work and set the bean attribute (?).
However, the entity attribute is never set.
Some facts:
- I'm using public fields in the entity bean instead of getters and setters
- The ZK version is 3.0.5
- I'm using annotation binding (but as I said, binding other attributes such as String values works perfectly).
- There are no error messages that would reveal any mistakes
- coerceToUi is a stub implementation because it's not needed at this point
- I'm upgrading to 3.0.6 as soon as it hits the maven repository (I didn't find any bug fixes that could be related to this, so it probably doesn't matter
anyway)
Am I missing something or doing something completely wrong?
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=5055759
By: gekkio
I finally solved the problem.
After 2 hours of banging my head against the wall I found the typo which caused the problem :) I'll release later some of my useful ZK classes under GPL.
Please forget this post.
Asked: 2008-06-26 12:53:06 +0800
Seen: 331 times
Last updated: Jun 26 '08