DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=31500>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=31500 Problem in Reading the Bean containing another bean Summary: Problem in Reading the Bean containing another bean Product: Commons Version: 1.0 Alpha Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Critical Priority: Other Component: Betwixt AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I am having trouble reading the contained bean using the example. Not much information is available online. This simple example is not working. PersonBean is the main class and contains Person class. Following is the code that I am using. Could you please help me resolve this problem. I have put all three class for your ease. ***************************** import java.util.*; import java.io.*; public class PersonBean implements Serializable{ private String name; private int age; private String lname; private String placeName; private List personList = new ArrayList(); /** Need to allow bean to be created via reflection */ public PersonBean() {} public PersonBean(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public List getPersonList(){ return this.personList; } public void addPerson(Person person){ System.out.println("Adding the person"); this.personList.add(person); } public void setPlaceName(String placeName){ this.placeName = placeName; } public String getPlaceName(){ return this.placeName; } public String getLname() { return lname; } public void setLname(String lname) { this.lname = lname; } public String toString() { return "PersonBean[name='" + name + "',age='" + age + "',lname='" + lname + "',placeName='" + placeName + "']" + getValues(); } public String getValues(){ StringBuffer buf = new StringBuffer("Temp String "); Iterator iit = personList.iterator(); while (iit.hasNext()){ System.out.println(iit.next()); } for (Iterator it = personList.iterator(); it.hasNext();){ Person person = (Person)it.next(); buf.append("First Value " + person.getCompany() + " \n" ); } return buf.toString(); } } ************************************************************ import java.util.*; import java.io.*; public class Person implements Serializable { private String company = new String(); public Person() { System.out.println("Constructor of Person "); } public String getCompany() { return company; } public void setCompany(String company) { this.company = company; } public String toString() { return "Company " + company; } } *************************************************************** package com.vzw.registration.ecpdxmltrans.test; import java.io.StringReader; import org.apache.commons.betwixt.io.BeanReader; import org.apache.commons.betwixt.BindingConfiguration; public class ReadExampleApp { public static final void main(String args[]) throws Exception{ // First construct the xml which will be read in // For this example, read in from a hard coded string StringReader xmlReader = new StringReader( "<?xml version='1.0' ?>" +"<person>" +"<age>25</age>" +"<name>James Smith</name>" +"<person>" +"<company>98007</company>" +"</person>" +"<person>" +"<company>98008</company>" +"</person>" +"<placeName>London</placeName>" +"<lname>appleton</lname>" +"</person>"); // Now convert this to a bean using betwixt // Create BeanReader BeanReader beanReader = new BeanReader(); // Configure the reader // If you're round-tripping, make sure that the configurations are compatible! beanReader.getXMLIntrospector().setAttributesForPrimitives(false); (beanReader.getBindingConfiguration()).setMapIDs(false); // Register beans so that betwixt knows what the xml is to be converted to // Since the element mapped to a PersonBean isn't called the same, // need to register the path as well beanReader.registerBeanClass("person", PersonBean.class); // Now we parse the xml PersonBean person = (PersonBean) beanReader.parse(xmlReader); // send bean to system out System.out.println(person); } } Thanking you in advance. John. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]