You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2007/02/01 01:49:08 UTC

Re: No getter method for property

Agustín, there was a change in behaviour between the two JVM versions 
you are using which accounts for the difference in behaviour. The 
problem is indeed that your get/set methods do not conform to the 
JavaBean specification. Refer to the link Taras posted [1] and make sure 
you follow the conventions to avoid problems.

L.

[1] 
http://java.sun.com/docs/books/tutorial/javabeans/properties/indexed.html


Taras Puchko wrote:
> Maybe it depends on JVM implementation, try to run the following:
> 
> public class Temp {
> 
>  private String abc;
> 
>  public String getAbc() { return abc; }
>  public void setAbc(String abc) { this.abc = abc; }
>  public String getAbc(int i) { return abc; }
>  public void setAbc(int i, String abc) { this.abc = abc; }
> 
>  public static void main(String[] args) throws IntrospectionException {
>    for (PropertyDescriptor descriptor :
> Introspector.getBeanInfo(Temp.class).getPropertyDescriptors()) {
>      System.out.println("\ndescriptor.getName() = " + 
> descriptor.getName());
>      System.out.println("descriptor.getClass().getName() = " +
> descriptor.getClass().getName());
>      System.out.println("descriptor.getPropertyType() = " +
> descriptor.getPropertyType());
>      System.out.println("descriptor.getReadMethod() = " +
> descriptor.getReadMethod());
>      System.out.println("descriptor.getWriteMethod() = " +
> descriptor.getWriteMethod());
>    }
>  }
> }
> 
> It shows:
> descriptor.getName() = abc
> descriptor.getClass().getName() = java.beans.IndexedPropertyDescriptor
> descriptor.getPropertyType() = null
> descriptor.getReadMethod() = null
> descriptor.getWriteMethod() = null
> 
> But when remove indexed methods I have:
> descriptor.getName() = abc
> descriptor.getClass().getName() = java.beans.PropertyDescriptor
> descriptor.getPropertyType() = class java.lang.String
> descriptor.getReadMethod() = public java.lang.String Temp.getAbc()
> descriptor.getWriteMethod() = public void Temp.setAbc(java.lang.String)
> 
> -Taras
> 
> On 1/31/07, Agustín <ag...@treelogic.com> wrote:
>> But currently my solution is running on a remote server........not is
>> running on localhost. So I think it's possible to have the methods as 
>> I have
>> them.
>>
>> Thanks.
>>
>> Agustín González García
>> -------------------------------------
>> Mantenimiento J2EE - Treelogic
>> Tel: 985 73 27 32
>> Edificio Centroastur, 2ª planta
>> Polígono SIA Copper
>> 33420, Lugones - Asturias - España
>> ----- Original Message -----
>> From: "Taras Puchko" <ta...@gmail.com>
>> To: "Struts Users Mailing List" <us...@struts.apache.org>
>> Sent: Wednesday, January 31, 2007 4:36 PM
>> Subject: Re: No getter method for property
>>
>>
>> > You've got String getNombre() but it should return an array of 
>> Stringsand
>> > setNombre(String) should accept an array to. Or you'll have togive
>> > different names to your properties:
>> > public String getNombre1(int i)public void setNombre1(int i, String
>> > nombre)
>> > public String getNombre2()public void setNombre2(String nombre)
>> > -Taras
>> > On 1/31/07, Agustín <ag...@treelogic.com> wrote:> I have got
>> > exactly this in the class:>> public String getNombre(int i) {>  return
>> > otrosSolicitantes[i].getNombre();>  }>>  public void setNombre(int i,
>> > String nombre) {>  otrosSolicitantes[i].setNombre(nombre);>  }>> public
>> > String getNombre() {>  return solicitantePrincipal.getNombre();>  }>>
>> > public void setNombre(String nombre) {>
>> > solicitantePrincipal.setNombre(nombre);>  }>> Agustín González
>> > García> -------------------------------------> Mantenimiento J2EE -
>> > Treelogic> Tel: 985 73 27 32> Edificio Centroastur, 2ª planta> Polígono
>> > SIA Copper> 33420, Lugones - Asturias - España> ----- Original
>> > Message -----> From: "Taras Puchko" <ta...@gmail.com>> To: 
>> "Struts
>> > Users Mailing List" <us...@struts.apache.org>> Sent: Wednesday, 
>> January 31,
>> > 2007 2:47 PM> Subject: Re: No getter method for property>>> > Hi,> > I
>> > think Struts is confused to see a simple and an indexed propertywith 
>> the>
>> >  > same name. If you have an indexed property, your methodsshould look
>> > like> > this:> > String getNombre(int)void setNombre(int, 
>> String)String[]>
>> >  > getNombre()setNombre(String[])> > See> >
>> > 
>> http://java.sun.com/docs/books/tutorial/javabeans/properties/indexed.html> 
>>
>> >  > Regards,Taras> >> >> > On 1/31/07, Agustín
>> > <ag...@treelogic.com> wrote:> If I only> > have two 
>> methods the
>> > application runs perfectly:>> getNombre()>> > setNombre(String)>> If I
>> > have four methods the applications not runs.>>>> > getNombre()>
>> > setNombre(String)>> getNombre(int)> setNombre(int, String)>>> > I don't
>> > know why the application runs on one server (on localhost) and> > not>
>> > runs on other server (on other host).>> Agustín González> >
>> > García> -------------------------------------> Mantenimiento J2EE -> >
>> > Treelogic> Tel: 985 73 27 32> Edificio Centroastur, 2ª planta> 
>> Polígono> >
>> > SIA Copper> 33420, Lugones - Asturias - España> ----- Original> >
>> > Message -----> From: "Dave Newton" <ne...@yahoo.com>> To: 
>> "Struts> >
>> > Users Mailing List" <us...@struts.apache.org>> Sent: Wednesday, January
>> > 31,> > 2007 1:14 PM> Subject: Re: No getter method for property>>> > 
>> ---
>> > Agustín> > <ag...@treelogic.com> wrote:> >> I have the 
>> get and
>> > set method> > fot the property> >> nombre, but I have more than one
>> > method. I have:> >>>> >  >> getNombre()> >> getNombre(int)> >>
>> > setNombre()> >> setNombre(int)> >> >> > I'm not sure that this is a 
>> legal
>> > JavaBean; does it> > work if you remove> > one set of accessors? 
>> (And no,
>> > I> > don't know why it works on one server> > and not another> > :)> 
>> >> >
>> > Dave> >> >> >> >> >> >
>> > 
>> ____________________________________________________________________________________>> 
>>
>> >  >  > Want to start your own business?> > Learn how on Yahoo! Small
>> > Business.>> >  > http://smallbusiness.yahoo.com/r-index> >>> >
>> >  > 
>> --------------------------------------------------------------------->
>> >  >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> > 
>> For> >
>> > additional commands, e-mail: user-help@struts.apache.org>> >
>> >  >>>> 
>> --------------------------------------------------------------------->>
>> >  > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For
>> > additional> > commands, e-mail: user-help@struts.apache.org>>>
>> >  >>>> 
>> --------------------------------------------------------------------->
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org> For 
>> additional
>> > commands, e-mail: user-help@struts.apache.org>>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org