- Dennis
Beet wrote:
oh...that might be an idea. I'll try that thanks.
I hope it works though, because otherwise this will be a tough nut to crack.
Dennis, do you consider this to be a bug? I read through the archives, and I noticed that someone else had a similar problem, except with him it was using ints, which weren't being marshalled when the value was '0'. One of his workarounds was to change the default to '-9999' but that caused some other headaches. With a boolean, even that workaround is off limits, since there are only 2 possible values :(.
On Fri, 18 Mar 2005 16:07:41 -0600, Darin Clark <[EMAIL PROTECTED]> wrote:
Random thought, and I don't know if it applies, but.. if you have control over the java code, changing the little-b-booleans to big-b-Booleans will both handle your problem and remove the need for any test methods..
On Fri, 2005-03-18 at 15:28, Dennis Sosnoski wrote:
This looks like an oversight in the JiBX definitions. If a value is labeled as usage="optional" JiBX makes the default value the same as the initial state of a value of that type, as defined by the Java language (for a boolean this is "false"), and JiBX only marshals an optional value if it differs from the default. The problem is that you'd like to have the marshalling controlled by the test-method and ignore the default. So everything is working as defined, but not as you'd like it to.
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
------------------------------------------------------- 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
------------------------------------------------------- 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
