You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Craig R. McClanahan" <Cr...@eng.sun.com> on 2000/08/18 20:40:58 UTC

Re: Problems with jsp:setProperty

I don't know if this is the key to your problem or not, but this one bit me --
so, just in case ...

According to the JavaBeans specification, it is not legal for you to have more
than one property setter method for the same property, with different argument
types.  So, for example, if you have both of the following methods in your bean:

    public void setNumberOfSeats(int seats);

    public void setNumberOfSeats(String seats);

the JavaBeans introspector (used by <jsp:setProperty>) will decide that there is
no setter method for the "numberOfSeats" property, and <jsp:setProperty> will
therefore not call either of them.

Craig McClanahan


Daniel wrote:

> Hello,
>
> I use <jsp:setProperty name=<beanName> property="'*"> in my jsp-files.
> In my bean there are all set-methods for my properties. The properties all
> start with a little letter.
> Well, some properties will set in the bean how you would expect. However
> some others are not set in spite of the correct form of the set-method. Such
> properties are <input type=text...> fields which often contain only numbers.
> However, first my set-method for such a field expected a int as a parameter.
> Becaus of exception-handling I turned the parameter type from in to string.
> However, from then on, the method is not be called so that the property is
> not set. If I change the name the name of the property from i.e.:
> numberOfSeats to nnumberOfSeats or so and I create a set-method like this
> public void setNnumberOfSeats(String newNumberOfSeats) it will work.
> But I wonder because other property fields, which also often only contain
> numbers will work fine with their set-methods expecting a string parameter.
> If I turn the the type of the parameter of the not working set-methods again
> to int it will work again.
>
> I using VisualAge for Java and Tomcat RC3.1 (but there are the same effects
> with Tomcat 3.0). I suppose the either VisualAge has problems with a kind of
> caching or it is somethin wrong with Tomcat because if I try to use
> <jsp:setProperty name=<beanName> property="numberOfSeats"
> param="numberOfSeats"/> I will get the Error message: No such method found,
> but the method exists in the bean and restarting of Tomcat has no effect.
>
> Thanks for your help. I hope somebody will have an answer.
>
> So long...
>
> Daniel
>
> --------------------------------------------------------------------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org