No getter method for property
Hello!I have ran into a strange problem. (To me it looks strange beacuse this should be easy to solve, but perhaps I'm blind)
This is a small app that I use for testing at home.
The error I get is:
javax.servlet.jsp.JspException: No getter method for property name of bean AddNameFormWebService
Usally this means that I refer to a member in the Form-class with wrong method-name. In this case getName I guess?
To me this there is no method named getName in class AddNameFormWebService.
First this part works with a similar structure:
<html:form action="/AddNameActionEJB" method="post" >
<html:errors/>
<table border="0">
<tr>
<td align="right">
<html:submit>Add Name</html:submit>
</td>
<td align="left">
<html:text property="name" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<textarea name="namestextarea" cols="35" rows="5">
<logic:empty name="AddNameFormEJB" property="names">AddNameFormEJB - No names available</logic:empty>
<logic:notEmpty name="AddNameFormEJB" property="names">
<logic:iterate name="AddNameFormEJB" property="names" id="AddNameFormEJB">
<bean:write name="AddNameFormEJB" property="name"/>
</logic:iterate>
</logic:notEmpty>
</textarea>
</td>
</tr>
</table>
</html:form>
The Form class looks like:
package nameswebapplication.controller.form;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public class AddNameFormEJB extends ActionForm
{
static final long serialVersionUID = 1l;
private String name = null;
private List names = null;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List getNames() {
return names;
}
public void setNames(List names) {
this.names = names;
}
}
The above works fine.
But this do not work:
<html:form action="/AddNameActionWebService" method="post" >
<html:errors/>
<table border="0">
<tr>
<td align="right">
<html:submit>Add Name</html:submit>
</td>
<td align="left">
<html:text property="name" size="30" maxlength="30"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
<textarea name="namestextarea" cols="35" rows="5">
<logic:empty name="AddNameFormWebService" property="names">AddNameFormWebService - No names available</logic:empty>
<logic:notEmpty name="AddNameFormWebService" property="names">
<logic:iterate name="AddNameFormWebService" property="names" id="AddNameFormWebService">
<bean:write name="AddNameFormWebService" property="name"/>
</logic:iterate>
</logic:notEmpty>
</textarea>
</td>
</tr>
</table>
</html:form>
This Form class looks like:
package nameswebapplication.controller.form;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public class AddNameFormWebService extends ActionForm
{
static final long serialVersionUID = 1l;
private String name = null;
private List names = null;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public List getNames()
{
return names;
}
public void setNames(List names)
{
this.names = names;
}
}
Pretty much the same.
The row where it goes wrong is:
<bean:write name="AddNameFormWebService" property="name"/>
If you can spot the reason please let me know!
Best regards
Fredrik