Avi,
It might not be the ideal solution, but you could implement a custom
FieldHandler that simply returns null from the FieldHandler#getValue()
method if the boolean value is false.
It would be nice if Castor had a simple property that can be set to
indicate that default values should be filtered out during marshalling,
unfortunately we don't have such a feature at this time.
Please see here for more information on handlers:
http://castor.codehaus.org/xml-fieldhandlers.html
--Keith
Wiesenfeld, Avi wrote:
Avi Wiesenfeld, CISSP
IDm Business unit, bmcsoftware
Phone: +972-3-6451-295
Mobile: +972-52-428-6295
E-mail: [EMAIL PROTECTED]
Hi ALL,
When I unmarshall an XML file, where the castor map file contains the
following description:
<field name="MyBool" type="boolean" required="false">
<bind-xml name="MyBool" node="element"/>
</field>
The target class boolean "MyBool" will contain the value "false" if the
original XML file did not contain the element "MyBool" (line
"<MyBool>false</MyBool>" did not appear in the XML file).
Now I want exactly the opposite to happen when I marshall a class with
boolean field "MyBool" with false value to an XML file - I would like
the
File NOT to include the line "<MyBool>false</MyBool>". It is somewhat
hard to do that as one must have a true or false value in boolean
variable (unlike String that can have the value null).
Is there a way to do that?
Regards,
Avi Wiesenfeld
BMC Software
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------