Hi Dave,

The basic problem here is that you're defining the ClientAccountNumber mapping without any actual values, so JiBX will just merrily process the start and end tag while ignoring any text in between. In your case, you want the text to be treated as a value that goes into the created object (and is passed in the constructor). This is what you're already doing in the later example. To make this work in the first case, you just need to add a type="xxx" attribute to override the field type stated in the code:

        <!-- Account -->
        <mapping class="domain.Account" name="account"
                ordered="true">
                <value name="number" field="number" 
type="domain.ClientAccountNumber"/>
        </mapping>

and delete the other <mappings> completely. That's really the easiest way to handle this, since you want to use the value for the constructor of the object.

 - Dennis

[EMAIL PROTECTED] wrote:

Hi,
I have the following (abbreviated) mappings

        <!-- Account -->
        <mapping class="domain.Account" name="account"
                ordered="true">
                <structure name="number" field="number" 
map-as="clientAccountNumber"/>
        </mapping>

        <!-- Client Account Number -->
        <mapping abstract="true"
                class="domain.ClientAccountNumber"
                type-name="clientAccountNumber"
                extends="domain.AccountNumber">
        </mapping>

        <!-- Account Number -->
        <mapping abstract="true"
                class="domain.AccountNumber">
        </mapping>

Account contains an AccountNumber of subtype ClientAccountNumber.
AccountNumber contains only abstract methods.

The incoming xml looks like this:

<account><number>123456789012345</number></account>

After unmarshalling the Account the AccountNumber property is null.



The ClientAccountNumber mapping works elsewhere, where the containing object has
an ClientAccountNumber property (not an AccountNumber type).

        <mapping class="domain.TransactionSummary"
                name="transactionSummary" ordered="false">
                <value name="clientAccountNumber" field="clientAccountNumber"
                        usage="optional" />



The ClientAccountNumber class has a single arg contructor that takes the account
number property value.

If I extend the ClientAccountNumber mapping to include the account number
property I get a binding compiler error:

java.lang.IllegalStateException: Internal error: Expected
domain.ClientAccountNumber on stack, found domain.AccountNumber

Any ideas?

cheers

Dave


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to