Ashok, you're right, the Map interface is also valid. (see the user guide
link below in one of the previous mails).

Regards,
Bernhard

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


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" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
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:[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]
>


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