Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB does marshall everything but it does not marshal an ArrayList WHY ??

843834Feb 19 2008 — edited Jan 24 2009
Hello,

I already asked this on other forum without luck, the thread is dead so i try it here.

this is the class containing the data:
@XmlRootElement()
public class SettingsData implements Serializable
{

	private static final long serialVersionUID = 1L;

	
	private ArrayList<String> bezeichnungAL = new ArrayList<String>();
	
	
	public SettingsData()
	{		
	}

        // setXX()
        public void setBezeichnungAL(String bezeichnungAL)
       {
                // String an bezeichnungAL anh�ngen...
		this.bezeichnungAL.add(bezeichnungAL);
	}

}
this is an outline of the code where i marshall the java data to .xml file:

IN this code i read the strings in the combobox into the ArrayList by using the setBezeichnungAL(xxx) method. to make sure that the data was written properly into the ArrayList of the SettingsData.class i output the data in the next code lines with the 2nd for loop and yes the data contained in the JCombobox is in the ArrayList so everything i did was ok but when i open my .xml file after marshalling the java data i can see everything except any information about my ArrayList in the .xml file ??? What DO I WRONG ? please help me.
try
{ 
	JAXBContext jc = JAXBContext.newInstance(SettingsData.class);			
	Marshaller m = jc.createMarshaller();
	 m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);			    
	
	 OutputStream os = new FileOutputStream("settings.xml");
	  SettingsData object = new SettingsData();	
		    
		    for(int i = 0 ; i < bezeichnungCB.getItemCount() ; i++ )
		    {
		    	object.setBezeichnungAL(bezeichnungCB.getItemAt(i).toString());
		    }	
		    
		    for(int i = 0; i < object.getBezeichnungAL().size(); i++)
		    {
		        System.out.println(object.getBezeichnungAL().get(i));
		 }
		    
		    m.marshal(object, os);			 	
		   os.close();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 21 2009
Added on Feb 19 2008
1 comment
373 views