[Betwixt] Removing id attributes and conditional

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Betwixt] Removing id attributes and conditional

Ricardo Gladwell
Hi All,

I'm writing some Java beans to XML and getting some odd results.
Firstly, Betwixt is adding an "id" attribute to all my objects (see
sample payment.xml below). How do I configure Betwixt stop this behaviour?

I also would like to switch tags based on the type of an object
returned. For example, I have a Customer object that returns a BankAccount:

//BankAccount.java
public abstract class BankAccount {}

//Customer.java
public class Customer {
   BankAccount bankAccount;
   public BankAccount getBankAccount() { return bankAccount; }
}

//AustrianBankAccount.java
public class AustrianBankAccount extends BankAccount {
}

I have the following betwixt file which specifies that the root tag for
an AustrianBankAccount is "bankAccount-AT":

//AustrianBankAccount.betwixt
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
   <element name="bankAccount-AT">
     <addDefaults />
   </element>
</info>

But, in my results it still returns a "bankAccount" tag. How do I
enforce this behaviour?

// payment.xml
<?xml version="1.0"?>
<!DOCTYPE paymentService PUBLIC "-//Bibit//DTD Bibit PaymentService v1//EN"
        "http://dtd.bibit.com/paymentService_v1.dtd">

<paymentService id="1" merchantCode="OPODOPAYOUTEUR" version="1.3">
<submit>
<shopper id="2">
<bankAccount id="3">
<accountHolderName>com.opodo.backoffice.db.dao.mock.MockCustomerDAO</accountHolderName>
<branchCode>25267</branchCode>
<bankAccountNumber>85584111755</bankAccountNumber>
</bankAccount>
<authenticatedShopperID>0656125732</authenticatedShopperID>
</shopper>
</submit>
</paymentService>

Kind regards...

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Betwixt] Removing id attributes and conditional

Thomas Dudziak
> I'm writing some Java beans to XML and getting some odd results.
> Firstly, Betwixt is adding an "id" attribute to all my objects (see
> sample payment.xml below). How do I configure Betwixt stop this behaviour?

There is a configuration property for this which you'll set like this:

beanWriter.getBindingConfiguration().setMapIDs(false);

> I also would like to switch tags based on the type of an object
> returned. For example, I have a Customer object that returns a BankAccount:
>
> //BankAccount.java
> public abstract class BankAccount {}
>
> //Customer.java
> public class Customer {
>    BankAccount bankAccount;
>    public BankAccount getBankAccount() { return bankAccount; }
> }
>
> //AustrianBankAccount.java
> public class AustrianBankAccount extends BankAccount {
> }
>
> I have the following betwixt file which specifies that the root tag for
> an AustrianBankAccount is "bankAccount-AT":
>
> //AustrianBankAccount.betwixt
> <?xml version="1.0" encoding="UTF-8" ?>
> <info primitiveTypes="element">
>    <element name="bankAccount-AT">
>      <addDefaults />
>    </element>
> </info>
>
> But, in my results it still returns a "bankAccount" tag. How do I
> enforce this behaviour?

Handling of polymorphic references and collections has been added in
the current SVN Head (0.61-dev). Have a lokk e.g. at the this unit
test:

ttp://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestReferenceMapping.java?view=markup

regards,
Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]