Java Mailing List Archive

http://www.junlu.com/

Google Search
Google


Google
Google
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
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Adding an element with unbounded maxOcc

Adding an element with unbounded maxOcc

2003-12-22       - By Benjamin Kopic

 Back
Reply:     1     2  

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 = {&quot;one&quot;, &quot;two&quot;, &quot;three&quot;, &quot
;four&quot;};<BR>
    Element element= new Element(&quot;ActivitySummary&quot;);<BR>
    for (int j = 0; j &lt;act.length; j++) {<BR>
      Element element1= new Element(&quot;ActivityType&quot;).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&lt;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 &quot;act&quot; 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&nbsp;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>
   &nbsp;<BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element element= new Element(&quot
;ActivitySummary&quot;);<BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int j = 0; j &lt;act.length; j++){<BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element element1= new
Element(&quot;ActivityType&quot;).setText(act[j]);<BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; element.addContent
(element1);<BR>
   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
   Please Advise on how best can I resolve this problem.<BR>
   Best Regards<BR>
   &nbsp;<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.
©2008 junlu.com - Jax Systems, LLC, U.S.A.