struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ashokd" <ash...@visualsoft-tech.com>
Subject Re: Iterating ValueObjects by using logic:iterate - Urgent
Date Wed, 30 Jan 2002 12:11:58 GMT
Hi Bernhard,

Thanks for your mail.

The below example is worked by using Hastable and logic:iterate combination.

<%

  java.util.Hashtable bunchList = new java.util.Hashtable();
  com.km.struts.tutorial.TestBean test1 = new
com.km.struts.tutorial.TestBean();
    bunchList.put("0",test1);
    bunchList.put("1",test1);
    bunchList.put("2",test1);

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

 <logic:iterate id="testList" name="bunchList">
 <bean:define id="testBean" name="testList"
type="com.km.struts.tutorial.TestBean" property="value"/>
  <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>


I forwarding this, if any one faces same problem, they can use this.

Thanks & Regards,
Ashok.D


----- Original Message -----
From: "Hirschmann, Bernhard" <Bernhard.Hirschmann@t-systems.com>
To: "'Struts Users Mailing List'" <struts-user@jakarta.apache.org>
Sent: Wednesday, February 05, 2003 6:58 PM
Subject: AW: Iterating ValueObjects by using logic:iterate - Urgent


>
> 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:ashokd@visualsoft-tech.com]
> 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: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
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