struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ashokd" <ash...@visualsoft-tech.com>
Subject Iterating ValueObjects by using logic:iterate - Urgent
Date Wed, 30 Jan 2002 10:41:36 GMT
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message