   | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Struts - A MVC web framework | | Tomcat - JSP/Servlet container | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | | JSP - A mailing list about Java Server Pages specification and reference | |
Struts & Hibernate
|
|
|
  | |  | Adding an element with unbounded maxOcc | Adding an element with unbounded maxOcc 2003-12-22 - By Benjamin Kopic
Back The code you have here seems fine. Here is the test that I tried earlier and it passed:
public void testAddJDOMElements() throws Exception { String[] act = {"one", "two", "three", "four"}; Element element= new Element("ActivitySummary"); for (int j = 0; j <act.length; j++) { Element element1= new Element("ActivityType").setText(act[j]); element.addContent(element1); } List element1s = element.getChildren(); assertEquals(4, element1s.size()); for(int i=0; i<element1s.size(); i++) { System.out.println(((Element) element1s.get(i)).getText()); } }
Could it be something you do when you retrieve the elements? When does the problem manifest itself? Are you sure that "act" array is populated correctly?
Best regards
Ben
On Wed, 2003-12-10 at 13:10, Moipone Mocoancoeng wrote:
> How do I create an element that has an unbounded maximum occurences. > for examples I've created an element that I need to set text to an > object that can be 1 0r more.When I do element.addContent only the > first object is added to the one element and other object aren't > added. > > Element element= new Element("ActivitySummary"); > for (int j = 0; j <act.length; j++){ > Element element1= new > Element("ActivityType").setText(act[j]); > element.addContent(element1); > } > Please Advise on how best can I resolve this problem. > Best Regards > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ > Do you Yahoo!? > New Yahoo! Photos - easier uploading and sharing
-- benjamin kopic m: +44 (0)780 154 7643 t: +44 (0)20 7794 3090 e: benjamin.kopic@(protected) w: http://www.panContext.com/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"> <META NAME="GENERATOR" CONTENT="GtkHTML/3.0.9"> </HEAD> <BODY> The code you have here seems fine. Here is the test that I tried earlier and it passed:<BR> <BR> <TT>public void testAddJDOMElements() throws Exception {<BR> String[] act = {"one", "two", "three", " ;four"};<BR> Element element= new Element("ActivitySummary");<BR> for (int j = 0; j <act.length; j++) {<BR> Element element1= new Element("ActivityType").setText(act[j]);<BR> element.addContent(element1);<BR> }<BR> <BR> List element1s = element.getChildren();<BR> assertEquals(4, element1s.size());<BR> <BR> for(int i=0; i<element1s.size(); i++) {<BR> System.out.println(((Element) element1s.get(i)).getText());<BR> }<BR> }</TT><BR> <BR> Could it be something you do when you retrieve the elements? When does the problem manifest itself? Are you sure that "act" array is populated correctly?<BR> <BR> Best regards<BR> <BR> Ben<BR> <BR> <BR> On Wed, 2003-12-10 at 13:10, Moipone Mocoancoeng wrote: <BLOCKQUOTE TYPE=CITE> <FONT COLOR="#737373"><I>How do I create an element that has an unbounded maximum occurences.<BR> for examples I've created an element that I need to set text to an object that can be 1 0r more.When I do element.addContent only the first object is added to the one element and other object aren't added.<BR> <BR> Element element= new Element(" ;ActivitySummary");<BR> for (int j = 0; j <act.length; j++){<BR> Element element1= new Element("ActivityType").setText(act[j]);<BR> element.addContent (element1);<BR> }<BR> Please Advise on how best can I resolve this problem.<BR> Best Regards<BR> <BR> <BR> <HR SIZE="1"> Do you Yahoo!?</FONT><BR> <A HREF="http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=21260/*http:/ /photos.yahoo.com"><U>New Yahoo! Photos - easier uploading and sharing</U></I>< /A> </BLOCKQUOTE> <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%"> <TR> <TD> <PRE>-- benjamin kopic m: +44 (0)780 154 7643 t: +44 (0)20 7794 3090 e: benjamin.kopic@(protected) w: http://www.panContext.com/</PRE> </TD> </TR> </TABLE>
</BODY> </HTML>
Earn $52 per hosting referral at Lunarpages.
|
|
 |