It should really be an error to specify post-set on a <structure> that doesn't define an object. I'll add a check for this in the beta 4 code, which has much better error checking and handling in general.
- Dennis
Beet wrote:
Here's the fragment from the mapping file:
... <structure name="Batch" usage="optional" test-method="hasBatch" post-set="postset"> <value name="TS" style="attribute" field="ts"/> <value name="MaxKG" field="maxKGPerBatch"/> </structure> ...
it doesn't matter what I put into "postset" because it doesn't ever get called. I've run a debugger and it never stops in that method.
On Fri, 12 Nov 2004 10:58:50 -0800, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
It's probably best if you can show an example of what you're trying to do, with the fragment of the binding definition and the actual post-set method code.
- Dennis
Beet wrote:
The problem is that I'm using the default attribute to set each element value to the empty string if it doesn't exist, so nothing is ever null. Right now I've had to settle for doing similar to what you suggested as your second option, but I don't really like it because, since nothing is ever null, I use the empty string for comparison. So if all the subelements in my optional structure are empty, then the boolean never gets set.
I'm just curious as to why post-set doesn't work in this instance. Is there a reason for this?
On Thu, 11 Nov 2004 19:59:00 -0800, Dennis Sosnoski <[EMAIL PROTECTED]> wrote:
Beet wrote:
I have a XML element, 'Worksheet,' which consists entirely of optional structures.
In my java file, I have a bunch of booleans that denote the existence of the optional structures. However, after marshalling, I cannot get JiBX to set these booleans to true if the optional element exists. The default constructor sets these values to false. I tried putting post-set hooks on the optional elements, but they seem to be ignored. I assume the correct thing to do is to set a post-set on the main parent, 'Worksheet'. However, I don't know how to check for the existence of optional sub-elements at that level.
There are several ways you could handle this. One would be to use set-methods for the optional structures, and have the set-methods set the corresponding boolean as well as storing the actual object if the value passed in is non-null. Another would be to do basically the same thing in the post-set method, and look for the values that are associated with the optional elements. If the optional element is not present in the document JiBX will set a null value for the corresponding object.
Does that help, or is there something I'm not understanding about your requirements?
- Dennis
------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users