• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception while binding an array. Missing []

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am getting below error

org.springframework.beans.NotReadablePropertyException: Invalid property 'sourceLocation0' of bean class [demo.form]: Bean property 'sourceLocation0' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


Can you please suggest. Following is the jsp code

<c:forEach items="${form.sourceLocation}" var="source"
varStatus="status">
<tr>
<td align="center">${status.count}</td>
<td><form:input path="sourceLocation[${status.index}].selectedLocation"/></td>
</tr>
</c:forEach>

Following is the form class

public class form {
private List<Location> sourceLocation;
public List<Location> getSourceLocation() {
return sourceLocation;
}
public void setSourceLocation(List<Location> sourceLocation) {
this.sourceLocation = sourceLocation;
}
}

followign the Location class
public class Location {
private String selectedLocation;
public Location() {
}
public Location(String selectedLocation) {
this.selectedLocation = selectedLocation;
}
public String getSelectedLocation() {
return selectedLocation;
}
public void setSelectedLocation(String selectedLocation) {
this.selectedLocation = selectedLocation;
}

}


As per my analysis the property should be sourceLocation[0] instead on sourceLocation0. I went ahead and did a view source of page following is the content to which jstl form:input tag as converted to html

<td><input id="sourceLocation0.selectedLocation" name="sourceLocation0.selectedLocation" type="text" value=""/></td>

if i replace jsp with regular html input tag as below every thing works fine

<td><input name="sourceLocation[${status.index}].selectedLocation" value="${source.selectedLocation}" /></td>

Can you please suggest.

Thanks & Regards,
Smruti Ranjan

 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi welcome to the Ranch!! Please UseCodeTags <-- click it makes things much easier to read

Have a look at this post and see if it helps you at all

http://forum.springsource.org/showthread.php?92033-Not-able-to-specify-path-for-form-select-tag-with-list-of-objects

I cant tell from your snipped what you form is bound to.
 
Smruti Ranjan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your response. The example link you have provided is what i am trying to achieve but with only difference is in example form:select option is used but i am using form:input tag.

I am getting an error when i try to bind an form:input tag with an list of objects in form

org.springframework.beans.NotReadablePropertyException: Invalid property 'sourceLocation0' of bean class [form]: Bean property 'sourceLocation0' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


Following is my jsp Code


Following is my form Object


following is my location object


As per my analysis the property should be sourceLocation[0] instead on sourceLocation0. I went ahead and did a view source of page following is the content to which form:input tag as converted to html



in jsp if i replace form:input tag with regular html input tag as below every thing works fine



Can you please suggest
reply
    Bookmark Topic Watch Topic
  • New Topic