Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    105

    [Spring-web] problema con <form:input path

    Ciao Ragazzi,

    Come dal titolo ho un problema con la tag from di spring <form:input tag.

    di sotto ho una classe che raggiude di per se il problema

    codice:
    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;
    }
    }

    quando nella jsp scrivo <form:input path="propertydatalabel[1]" size="1" maxlength="200" lang="en" dir="ltr" /> mi lancia questa 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)


    Purtroppo ho la netta sensazione ci sia una sorta di constrain, cioe il getter method non accetta parametri e il setter accetta solo un parametro dello stesso tipo del return type del relativo getter.

    Qualcuno sa darmi qualche hint?

    Grazie mille.

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    105


    Mi auto rispondo, un modo e fare un fake di una lista mi spiego.

    questa istruzione é vaida <form:input path="propertydatalabel[1]" solo se propertydatalabel e una lista, array o mappa. Quindi la soluzione é creare un ObjectAdapter che delega al get e il set di List i metodi della classe ArrayOfProperty.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.