struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BlaineNewsletters\(@yahoo\)" <>
Subject Display nested information(xml tree) using logic:iterate tag
Date Tue, 28 Aug 2001 14:37:02 GMT
I want to parse a xml document using Jdom and then display the resulting tree . Below I have
a sample XML, the code in the jsp page, as well as what is outputted. The nested loop is not
working correctly. It's nesting over the parent <TestFamily> tag and displaying all
<Test#> tags. Any suggestions on the nested loops would be great. I've actually got
more nested elements under the <Test> tags, but left them out for now. 

Also, the JSP isn't very clean. Any suggestions on cleaning it up? 


------------------------------------------------Example XML :----------------------------------------------
   <Test1 />  
   <Test2 />  
   <Test3 />    
   <Test4 />  
   <Test5 />
------------------------------------------------Code in jsp page:----------------------------------------------

<% test.TestConfigBean testbean = new test.TestConfigBean();
  java.util.List testfamilylist = testbean.getTestFamily(testbean.getTestIndexElement());
  pageContext.setAttribute("j_tflist",testfamilylist, PageContext.PAGE_SCOPE);

<logic:iterate id="testfamily" name="j_tflist">
<bean:write name="testfamily"/><br>
  java.util.Iterator i_tf = testfamilylist.iterator();
  while (i_tf.hasNext()) {
        org.jdom.Element _testType = (Element);
        java.util.List ttype = testbean.getTestArgs (_testType);
        pageContext.setAttribute("j_ttlist",ttype, PageContext.PAGE_SCOPE);
 <logic:iterate id="testtype" name="j_ttlist">
        <bean:write name="testtype"/><br>
<% } %>

------------------------------------------------Resulting display:----------------------------------------------
[Element: <TestFamily1/>]
           [Element: <Test1/>]
           [Element: <Test2/>]
           [Element: <Test3/>]
           [Element: <Test4/>]
           [Element: <Test5/>]
[Element: <TestFamily2/>]
           [Element: <Test1/>]
           [Element: <Test2/>]
           [Element: <Test3/>]
           [Element: <Test4/>]
           [Element: <Test5/>]


Blaine Kendall

View raw message