Title: RE: [displaytag-user] Problem to display Collection with Display tag

I progress gently but surely.
I succeeded in displaying a table in a page JSP while passing by DynActionForm
and the tag struts logic:iterate.
But unfortunately the same example doesn't wotk with the tag display.

The example that works:

I have created a plain java bean

public class ItemBean {
  public ItemBean() {
  }
  public void setId(int id) {
    this.id = id;
  }
  public int getId() {
    return this.itemId;
  }
  public void setName(String name) {
    this.name = name;
  }
  public String getName() {
    return this.name;
  }
  public void setPrice(double price) {
    this.price = price;
  }
  public double getPrice() {
    return this.price;
  }
}

I have created a DynaActionForm bean as follows:

<form-bean name="orderForm" dynamic="true"  
  type="org.apache.struts.action.DynaActionForm">
  <form-property name="itemBeans"
    type="java.util.ArrayList"/>
</form-bean>

And I have a jsp like shown below:

<html:form action="">

<table>

<tr>
        <td>Id:</td>
        <td>Name:</td>
        <td>Price:</td>
</tr>

<logic:iterate id="itemBeans" indexId="idx"
  name="orderForm" property="itemBeans"
  type="com.xyz.ItemBean">

<tr>
<td><bean:write name="itemBeans" property="id"
  indexed="true"/></td>
<td><bean:write name="itemBeans" property="name"
  size="50" indexed="true"/></td>
<td><bean:write name="itemBeans" property="price"
  indexed="true"/></td>
</tr>

</logic:iterate>
</table>
</html:form>

The action that populates the form is the following:

public ActionForward executeAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception

{
    Collection beans = new ArrayList();
    ItemBean bean1 = new ItemBean();
    beans.add(bean1);
    bean1.setId(1);
    bean1.setName("Toto");

    ItemBean bean2 = new ItemBean();
    beans.add(bean2);
    bean1.setId(2);
    bean1.setName("Tata");
  
    // Populate the form from the business data values
    BeanUtils.setProperty(form, "itemBeans", beans);
}

Now If I try to use display tag, I modify only the JSP page.
I replace

<logic:iterate id="itemBeans" indexId="idx"
  name="orderForm" property="itemBeans"
  type="com.xyz.ItemBean">

by the following code

<display:table border="0" pagesize="3" cellspacing="0" cellpadding="0" name="transmissionMonitoringForm" property="calls" scope="request">

  <display:column property="id" title="ID" />
  <display:column property="service" title="Service"/>
</display:table>

But when I run the application I have the following message:
I do not know how to iterate over 'class java.lang.String'.'

How can I indicate as in the logic tag, the type of the object in the array ?

Thanks a lot in advance
Sandra

----------------------------------------------------------------------------
As of February 12th, 2003 Thomson unifies its email addresses on a worldwide basis.
Please note my new email address: [EMAIL PROTECTED]

http://www.thomson.net/

Reply via email to