I'm not sure how to handle this. Changing the code to ignore the default value when a test-method is supplied would work for you, but might break other users' code. I'll try to find a work-around over the weekend, since this relates to some other issues I'd like to get fixed for the 1.0 RC.
- Dennis
Beet wrote:
I'm having a problem marshalling some elements, and I can't figure out the problem. The elements are defined as optional, and map back to boolean fields. I have a test-method that checks to see if the I should marshal the element, but the problem is that even though the test-method returns true, the element doesn't get marshalled unless the actual field value is true as well. In other words, when the java field to marshal is set to false, no marshalling! If it's set to true, then the element is marshalled ok... I don't understand why this is. I've checked and debugged, and I'm positive that my test-method is right.
Here's the JiBX binding code:
<structure name="Questions" field="questions" usage="optional" test-method="hasQuestions"> <value name="Q1" get-method="getQ1" set-method="setQ1" usage="optional" test-method="hasQ1"/> <value name="Q2" get-method="getQ2" set-method="setQ2" usage="optional" test-method="hasQ2"/> <value name="Q3" get-method="getQ3" set-method="setQ3" usage="optional" test-method="hasQ3"/> <value name="Q4" get-method="getQ4" set-method="setQ4" usage="optional" test-method="hasQ4"/> </structure>
So when methods hasQ1-hasQ4 all return true, I expect something like <Questions> <Q1>true</Q1> <Q2>true</Q2> <Q3>false</Q3> <Q4>true</Q4> </Questions>
Unfortunately, it only does the above if all the fields are true. If q3 is false, then it is omitted and the result is: <Questions> <Q1>true</Q1> <Q2>true</Q2> <Q4>true</Q4> </Questions>
Even though the hasQ3 set-method returns true. Instead of using get and set methods, I've also tried just using the field name, but same result. Please help!
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ jibx-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jibx-users
