Hi Martin,
I am not 100% sure, but this could be a potential regression with the
globally declared FieldHandler. As such, can I please ask you to create
a new Jira issue at
http://jira.codehaus.org/browse/CASTOR
and attach a fully working test case ?
Regards
Werner
On 01.06.2010 16:12, Martin Bristow wrote:
Hi,
I'm trying to marshall the following class:
public class AirAvailRequest {
private NSTimestamp departureDate;
private NSTimestamp returnDate;
[get and set methods]
}
Using this mapping file:
<?xml version="1.0"?>
<mapping>
<field-handler name="timestampHandler"
class="com.clicktravel.castor.NSTimestampHandler">
<param name="date-format" value="%Y%m%d"/>
</field-handler>
<class name="com.clicktravel.controllers.channel.air.AirAvailRequest">
<map-to xml="AirAvailRequest"/>
<field name="departureDate"
type="com.webobjects.foundation.NSTimestamp"
handler="timestampHandler">
<bind-xml name="DepartureDate" node="element"/>
</field>
<field name="returnDate"
type="com.webobjects.foundation.NSTimestamp"
handler="timestampHandler">
<bind-xml name="ReturnDate" node="element"/>
</field>
</class>
</mapping>
Everything works fine, except that the value in the XML output
<DepartureDate> node is always the same as<ReturnDate>.
I've checked that I'm not accidentally storing the same value in both
dates in the AirAvailRequest class.
NSTimestampHandler is almost identical to the example
ConfigurableFieldHandler
(http://www.castor.org/xml-fieldhandlers.html#Use-ConfigurableFieldHandler-for-more-flexibility),
only it converts WebObjects NSTimestamps
(http://webobjects.mdimension.com/javadoc/WebObjects/5.3/com/webobjects/foundation/NSTimestamp.html)
instead of java.util.Date - it doesn't seem to be the source of the
problem either.
It appears that the convertUponGet method in the handler is being
passed the value of returnDate for BOTH date nodes, somewhere in the
marshaller.
If I use two different instances of NSTimestampHandler in the mapping
file, like so:
...
<field-handler name="timestampHandler1"
class="com.clicktravel.castor.NSTimestampHandler">
<param name="date-format" value="%Y%m%d"/>
</field-handler>
<field-handler name="timestampHandler2"
class="com.clicktravel.castor.NSTimestampHandler">
<param name="date-format" value="%Y%m%d"/>
</field-handler>
...
and apply one to each date field, it works perfectly. Am I doing
something wrong here?
Thanks,
Martin
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email