Announcement Announcement Module
Collapse
No announcement yet.
<form:input path="property[10]"/> cause org.springframework.beans.NotReadableProperty Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <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, 09:07 AM.

  • #2
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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

            Comment


            • #7
              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...

              Comment


              • #8
                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

                Comment


                • #9
                  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.

                  Comment

                  Working...
                  X