You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Florent Goalabré <fl...@aliacom.fr> on 2001/03/06 13:13:49 UTC

Iterate tag : bean property

Hello,

I try  to use iterate tag,
<bean:write property="xxx"> tag works fine for several property of a
bean but it does not 
work for a few ones.

The JSP looks like :

<logic:iterate id="filedescription" name="consForm"
property="fileDescriptions" scope="request"
type="edu.bv.portedoc.view.FileDescription">
  <tr bgcolor="<bean:write name="filedescription" property="color" />">
   <td><bean:write name="filedescription" property="name" /></td>
   <td><bean:write name="filedescription" property="icon" /></td>
   <td><bean:write name="filedescription" property="link" /></td>
  </tr>
</logic:iterate>

An error occurs :
javax.servlet.jsp.JspException:
  No getter method for property icon of bean filedescription

If i delete the line with icon property, link name and color properties
display well.
Though the icon getter method exist, this code works:

<jsp:useBean id="consForm" scope="request"
type="edu.bv.portedoc.model.ConsultForm"/>
<%
       FileDescription[] al = consForm.getFileDescriptions();
       for (int i = 0; i<al.length; i++) {
        FileDescription fd = (FileDescription) al[i];
%>
  <tr bgcolor="fd.getColor()">
   <td><%= fd.getName() %></td>
   <td><%= fd.getIcon() %></td>
   <td><%= fd.getLink() %></td>
  </tr>
<% } %>

I try to look at the Intropector Utils class
org.apache.struts.util.PropertyUtils.
In the method getSimpleProperty(Object bean, String name), 
the property descriptor is retrieved but it fails to retrieve the
property getter method for the specified property.

Any idea

-- 
Florent Goalabré - florent.goalabre@aliacom.fr
ALIACOM - tel: 05 62 19 24 91 - fax: 05 62 19 24 91 - www.aliacom.fr

Re: Iterate tag : bean property

Posted by Florent Goalabré <fl...@aliacom.fr>.
"Craig R. McClanahan" wrote:
> 
> Florent Goalabré wrote:
> 
> > I try  to use iterate tag,
> > <bean:write property="xxx"> tag works fine for several property of a
> > bean but it does not work for a few ones.
> >
> > The JSP looks like :
> >
> > <logic:iterate id="filedescription" name="consForm"
> > property="fileDescriptions" scope="request"
> > type="edu.bv.portedoc.view.FileDescription">
> >   <tr bgcolor="<bean:write name="filedescription" property="color" />">
> >    <td><bean:write name="filedescription" property="name" /></td>
> >    <td><bean:write name="filedescription" property="icon" /></td>
> >    <td><bean:write name="filedescription" property="link" /></td>
> >   </tr>
> > </logic:iterate>
> >
> > An error occurs :
> > javax.servlet.jsp.JspException:
> >   No getter method for property icon of bean filedescription
> >
> 
> Florent, what are the method signatures of your getIcon() and setIcon()
> methods?  If the data types are different, the JDK's bean introspection
> logic will conclude that you do not have a property with the specified
> name.  This would be because your method names are not conforming to the
> JavaBeans spec requirements.
> 
> A (contrived) example of different data types would be something like this:
> 
>     public String getIcon();
>     public void setIcon(StringBuffer icon);
> 

=>  the methods were not conforming to JavaBeans spec: 
     public String getIcon();
     public void setIcon(File icon);

One strange behaviour is that it works for others properties which
method signatures
are the same than icon: 
     public String getName();
     public void setName(File name);
or 
     public String getLink();
     public void setLink(File link);

For Property icon : 
by tracing getSimpleProperty(Object bean, String name) in
org.apache.struts.util.PropertyUtils,
the PropertyDescripor is retrieved but a exception is thrown when trying
to retrieve
the readMethod.

--
Florent Goalabré - florent.goalabre@aliacom.fr
ALIACOM - tel: 05 62 19 24 91 - fax: 05 62 19 24 91 - www.aliacom.fr

Re: Iterate tag : bean property

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Florent Goalabré wrote:

> Hello,
>
> I try  to use iterate tag,
> <bean:write property="xxx"> tag works fine for several property of a
> bean but it does not
> work for a few ones.
>
> The JSP looks like :
>
> <logic:iterate id="filedescription" name="consForm"
> property="fileDescriptions" scope="request"
> type="edu.bv.portedoc.view.FileDescription">
>   <tr bgcolor="<bean:write name="filedescription" property="color" />">
>    <td><bean:write name="filedescription" property="name" /></td>
>    <td><bean:write name="filedescription" property="icon" /></td>
>    <td><bean:write name="filedescription" property="link" /></td>
>   </tr>
> </logic:iterate>
>
> An error occurs :
> javax.servlet.jsp.JspException:
>   No getter method for property icon of bean filedescription
>

Florent, what are the method signatures of your getIcon() and setIcon()
methods?  If the data types are different, the JDK's bean introspection
logic will conclude that you do not have a property with the specified
name.  This would be because your method names are not conforming to the
JavaBeans spec requirements.

A (contrived) example of different data types would be something like this:

    public String getIcon();
    public void setIcon(StringBuffer icon);

Craig McClanahan