Java Mailing List Archive

http://www.junlu.com/

Home » user.castor »

[castor-user] How can I configure a FieldHandler for a single nested element in my xml file

seper016

2010-03-06

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi,
I am using castor 1.3.
How can I configure a FieldHandler for a single nested element in my xml file.
I already have a bunch of descriptor classes for my xml file. These were generated from
an xml schema.
However one of the nested elements is a date field which sometimes has a value that cannot be
handled by Castor. It contains a single digit for day or for month. See below example.
Therefore I created a mapping file for the element containing the field and configured it to use
a FieldHandler.
Strongly simplified the xml looks like:
<root>
 
 <inner1>
   <field1>
     ...
   </field1>
   <datefield>
  2010-03-1T09:57:01+01:00
   </datefield>
   ...
 </inner1>
 
 <inner2>
   <field1>
   </field1>
   ...
 </inner2>
<root>
and the mapping looks like:
<mapping>
  <class name="nl.foo.Inner1">
    <field name="datefield" type="string" handler="MyDateHandler">
      <bind-xml name="inner1" node="element" />
    </field>
  </class>
</mapping>
The thing is: This works in an container environment (application running in OC4J application server on windows).
However when I run the same code outside the container it does not work; Handler is not called.
Also it does not work under a different application server (Oracle AS/Linux)
Question:
Am I using the right solution? Or should I make a mapping for the entire xml. But that would mean making
a complex mapping while I only want a fieldhandler for a single field. I already have the descriptors.
Greetings,
Huub
©2008 junlu.com - Jax Systems, LLC, U.S.A.