[Sorry, posted this also in the dev-list, while it is here that my question
belongs. My mistake]
Hello,
I am having the following problem with a Castor XML->bean mapping. I don't
manage to group a series of xml fields
into a bean. Let me explain.
The bean to be filled: TestDataBean.java
public class TestDataBean extends BaseBean {
private int id;
private InputBean inputBean;
private int comuneEsito;
private int comuneElaborazione;
private int localitaEsito;
private int localitaElaborazione;
private int indirizzoEsito;
private int indirizzoElaborazione;
/* getter + setter */
}
where InputBean.java:
public class InputBean extends
it.aci.tabelleComuni.normalizzatoreResidenze.utils.BaseBean {
private java.lang.String cap;
private java.lang.String civico;
private java.lang.String descrizioneComune;
private java.lang.String descrizioneDug;
private java.lang.String descrizioneLocalita;
private java.lang.String indirizzoString;
private java.lang.String codiceProvincia;
private int comuneTipoCodifica;
private int indirizzoTipoCodifica;
/* getter + setter*/
}
My input file xml:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
<test>
<id>1</id>
<comuneElaborazione>101</comuneElaborazione>
<comuneEsito>100</comuneEsito>
<localitaElaborazione>980</localitaElaborazione>
<localitaEsito>900</localitaEsito>
<indirizzoElaborazione>980</indirizzoElaborazione>
<indirizzoEsito>900</indirizzoEsito>
<codiceProvincia>AR</codiceProvincia>
<descrizioneComune>CIVITELLA IN VAL DI CHIANA</descrizioneComune>
<comuneTipoCodifica>999</comuneTipoCodifica>
<indirizzoTipoCodifica>999</indirizzoTipoCodifica>
</test>
<!-- more tests -->
</dataroot>
I want the fields that are not *Esito or *Elaborazione (such as
codiceProvincia or descrizioneComune) to fill the InputBean, inside the
TestDataBean, but whatever I try, I get a (correct) "unable to find
FieldDescriptor for 'codiceProvincia' in ClassDescriptor of test-data-bean"
error.
My current mapping file is this one:
<mapping>
<description>Mapping per il file dei dati di test verso una lista di
TestDatabean</description>
<class
name="it.aci.tabelleComuni.normalizzatoreResidenze.junit.bean.TestDataList">
<field name="list" collection="arraylist"
type="it.aci.tabelleComuni.normalizzatoreResidenze.junit.bean.TestDataBean">
<bind-xml name="test"/>
</field>
</class>
<class
name="it.aci.tabelleComuni.normalizzatoreResidenze.junit.bean.TestDataBean">
<field name="id" type="int">
<bind-xml name="id" node="element"/>
</field>
<field name="comuneEsito" type="int">
<bind-xml name="comuneEsito" node="element"/>
</field>
<field name="comuneElaborazione" type="int">
<bind-xml name="comuneElaborazione" node="element"/>
</field>
<field name="localitaEsito" type="int">
<bind-xml name="localitaEsito" node="element"/>
</field>
<field name="localitaElaborazione" type="int">
<bind-xml name="localitaElaborazione" node="element"/>
</field>
<field name="indirizzoEsito" type="int">
<bind-xml name="indirizzoEsito" node="element"/>
</field>
<field name="indirizzoElaborazione" type="int">
<bind-xml name="indirizzoElaborazione" node="element"/>
</field>
</class>
<class name="it.aci.tabelleComuni.normalizzatoreResidenze.bean.InputBean">
<field name="codiceProvincia" type="string"/>
<field name="descrizioneComune" type="string"/>
<field name="descrizioneLocalita" type="string"/>
<field name="cap" type="string"/>
<field name="descrizioneDug" type="string"/>
<field name="indirizzoString" type="string"/>
<field name="civico" type="string"/>
<field name="comuneTipoCodifica" type="integer"/>
<field name="indirizzoTipoCodifica" type="integer"/>
</class>
</mapping>
It seems in need some inverse "collection" atribute somewhere inside my
mapping, but I don't know how to indicate that several root fields have to
be grouped into a sub-bean.
Any help is appreciated! Thanks in advance.
Joris
--
View this message in context:
http://www.nabble.com/Group-several-root-fields-into-a-sub-bean-tf3362109.html#a9352985
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email