Ashokd, a Hashtable is not a Collection, so this can't work. You may use a
HashSet or something.

See http://jakarta.apache.org/struts/userGuide/struts-logic.html#iterate for
the syntax.

Regards,
Bernhard


-----Ursprüngliche Nachricht-----
Von: ashokd [mailto:[EMAIL PROTECTED]]
Gesendet: Mittwoch, 30. Januar 2002 11:42
An: Struts Users Mailing List
Betreff: Iterating ValueObjects by using logic:iterate - Urgent


Hi,

I tested a sample example to display list of ValueObjects.
If i setted these VOs to ArrayList the following code is working fine.

<%
   java.util.ArrayList bunchList = new java.util.ArrayList();
    bunchList.add(new com.km.struts.tutorial.TestBean());
    bunchList.add(new com.km.struts.tutorial.TestBean());
    bunchList.add(new com.km.struts.tutorial.TestBean());

    request.setAttribute("bunchList",bunchList);
%>


 <logic:iterate id="testList" name="bunchList">
  <bean:define id="testBean" name="testList"
type="com.km.struts.tutorial.TestBean" />
  <tr bgcolor="#f7faff">
   <td valign="top" align="left" height="20"><bean:write name="testBean"
property="testSize" />&nbsp;</td>
   <td valign="top" align="left" height="20"><bean:write name="testBean"
property="testWeight" />&nbsp;</td>
   <td valign="top" align="left" height="20"><bean:write name="testBean"
property="testTaste" />&nbsp;</td>
  </tr>
 </logic:iterate>


But I want to display Hashtable (which contains some keys and values are
ValueObjects). I tried like this it is giving follwing error.

WebGroup      X Servlet Error: java.util.Hashtable$Entry:
java.lang.ClassCastException: java.util.Hashtable$Entry

Code for Above Error is:

<%
   java.util.Hashtbale bunchList = new java.util.Hashtable();
    bunchList.put("1",new com.km.struts.tutorial.TestBean());
    bunchList.put("2",new com.km.struts.tutorial.TestBean());
    bunchList.put("3",new com.km.struts.tutorial.TestBean());

    request.setAttribute("bunchList",bunchList);
%>

Any Suggestions on this please.

Thanks in Advance,
Ashok.D


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to