Results 1 to 9 of 9

Thread: <form:input path="property[10]"/> cause org.springframework.beans.NotReadableProperty

  1. #1
    Join Date
    Sep 2009
    Location
    Lugano swiss
    Posts
    11

    Default <form:input path="property[10]"/> cause org.springframework.beans.NotReadableProperty

    Ciao Guys,

    I have a problem using the <form:input tag.

    following i show a piece of my class which it will be populate after the submitting of the form.

    Code:
    public class ArrayOfProperty{
    private String[] test = {"1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"};
    
    public String getpropertydatalabel(int id){
    	return this.test[id];
    }
    
    public void setpropertydatalabel(int id,String value){
    	this.test[id] = value;
    }
    }

    but when i use <form:input path="propertydatalabel[1]" size="1" maxlength="200" lang="en" dir="ltr" /> this tag i encounter this exception

    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'propertydatalabel[1]' of bean class [com.generalstudios.ArrayOfProperty]: Bean property 'propertydatalabel[1]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
    org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:540)
    org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:532)

    So in the end i want to reproduce the same behavior of the <html: tag of struts
    Last edited by joksy; Mar 30th, 2010 at 08:07 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Your getter/setter doesn't adhere to the javabeans spec. It should return the [] not an element. get[array](idx) or set(idx, value) isn't supported in spring nor is it needed.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Sep 2009
    Location
    Lugano swiss
    Posts
    11

    Default

    Quote Originally Posted by Marten Deinum View Post
    Your getter/setter doesn't adhere to the javabeans spec. It should return the [] not an element. get[array](idx) or set(idx, value) isn't supported in spring nor is it needed.
    Thanks for reply. Can you explain why is not it needed?? Ok in this particular example for sure not but in a different context could be useful.

    anyway thanks again.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Spring MVC isn't struts it works differently, it used PropertyEditors for conversion of objects and you don't need to add the getters/setters which provide the functionality to retrieve the object/set the object at the desired location.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Sep 2009
    Location
    Lugano swiss
    Posts
    11

    Default

    Plus, i know for sure that struts support this kind of task since probably the first version, so I think that spring must have something similar

  6. #6
    Join Date
    Sep 2009
    Location
    Lugano swiss
    Posts
    11

    Default

    Quote Originally Posted by Marten Deinum View Post
    Spring MVC isn't struts it works differently, it used PropertyEditors for conversion of objects and you don't need to add the getters/setters which provide the functionality to retrieve the object/set the object at the desired location.
    Ok. you have right that are different, but this not implies that this kind of features is not needed.

    Anyway is not a big big big problem.

    Thanks have a nice day

  7. #7
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Plus, i know for sure that struts support this kind of task since probably the first version, so I think that spring must have something similar
    No it doesn't as it works differently...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  8. #8
    Join Date
    Mar 2010
    Posts
    1

    Default Indexed properties

    Hi,
    at 5.4.1 point of reference doc http://static.springsource.org/sprin...alidation.html however is explained how to access indexed values. The bean should expose on a single method a Map, an Array or a List.

    BTW I don't know if then it works as setter of a property via form tags.

    Kind regards,
    LP

  9. #9
    Join Date
    Jul 2008
    Posts
    157

    Default

    This will work:
    Code:
    public class ArrayOfProperty{
    	private String[] test = {"1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"};
    
    	public String getPropertyDataLabels () {
    		return this.test;
    	}
    }
    Code:
    <form:input path="propertyDataLabels[1]" size="1" maxlength="200" lang="en" dir="ltr" />
    But then you have to upgrade to latest Spring 3.0.2, since Spring 3.0.1 (SPR-6871) strips out the square brackets so it won't work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •