> In 2005, the issue of default values for primitives not working > correctly was discussed. Has any progress been made on this? I have > doubles and ints that are set to optional that do not marshall if they > equal 0. I'm setting them as optional because I want to reuse the > same mappings for marshalling and unmarshalling. (We may have > thousands of mappings, so they have to be as tight as possible). > > I'd rather not have to add a default value to these bindings or change > my pojos to using Doubles. Is there some parameter that we can set at > marshalling time or compile time that can make JiBX act as expected, > that if a double is equal to zero, <tag>0</tag> gets marshalled? > > I even tried using custom serializer, but the even the custom > serializer is not called in this case. Or is there a config where I > can say 'always call custom serializer'. > > ---------------------------------------------------------------------- > ------------- > > 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! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. -------- IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users