In the mapping from the example in the message you posted:

  <binding>
    <mapping class="Test" name="test">
      <value name="value" field="value" usage="optional" style="attribute"/>
    </mapping>
</binding>

        In the example, the expected text in the Test.value string should be 
"default value", but is coming up as null because of the mapping. If you 
change the mapping to be as follows, you will get the results desired.

  <binding>
    <mapping class="Test" name="test">
      <value name="value" field="value" usage="optional" 
style="attribute" default="default value"/>
    </mapping>
</binding>

        As Alexander notes in the follow up message:

 > This works, but is somewhat awkward as i have
 > to duplicate the default value in the binding.xml
 > and in the Java class given that I want to have
 > objects created directly (i.e. "new MyClass()")
 > also initialized with proper default values.

-- 
        Thomas Jones-Low            Softstart Services Inc.
        [EMAIL PROTECTED]      JobScheduler for Oracle
        Ph: 802-398-1012            http://www.softstart.com

Tudor Olteanu wrote:
> I found another thread which describes the issue in more detail 
> (http://www.mail-archive.com/[email protected]/msg01249.html)
> 
> Anyway, I managed to get a list with the fields that were received but I 
> have the names of the tags. What I will need for each tag name, is the 
> name of its corresponding property from the mapping class.
> Please let me know how can I do this.
> 
> Thanks,
> Tudor
> 
> Thomas Jones-Low wrote:
>>      Use a default. The Jibx <value> tag takes an default= attribute. This 
>> is only allowed on optional values (like you have) and if the optional 
>> value is missing, the corresponding set-method is called with the 
>> default. If you have the default attribute set to "missing" or some 
>> other out of bounds value, the Set-method now knows when to leave the 
>> value alone, and when to update it.
>>
>> Tudor Olteanu wrote:
>>   
>>> Since "null" is also a possible value for some fields, I can't assume 
>>> that null values are corresponding to missing fields.
>>>
>>> So what I need is a way to know if an optional field was/wasn't present 
>>> in xml.
>>>
>>> Thomas Jones-Low wrote:
>>>     
>>>>    Using a existing object will require the use of the Factory attribute 
>>>> for the binding. This is a static method which returns the instance to 
>>>> be worked on.
>>>>
>>>>    The original values to be kept will need a set-method rather than the 
>>>> default setter, to check for the null value and not update them.
>>>>
>>>>   



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to