I spent some time chasing the same problem. It
appeared to me that the Introspector was getting
get/set methods in pairs based on the property name,
parameter list, and return type. It seemed to expect
that you adhered to the Java beans standard of
void setA(int a){}
int getA(){}
where the return type of the getter matched the input
parameter of the setter. It matched up get/set method
pairs that way.
So in your case the pair would be
void setA(int a)
int getA()
void setA(String a)
null
It then iterated through the list of methods looking
for one that matched the *name* I had requested. It
sometimes found the pair where the getter was null
before finding the other pair and caused the error
you've found.
I fixed it by renaming my method to setAasString() or
something like that. A bit ugly, but I couldn't find
another way to make the introspector behave.
Sean
>
> -----Original Message-----
> From: Dan Hinojosa [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 31, 2001 12:40 PM
> To: [EMAIL PROTECTED]
> Subject: Java Beans and JSP Question.
>
>
> I have a standard java bean. The different thing
> about it is that I
> usually have two overloaded set methods per
> attribute. For example,
>
> public class MyBean {
> private int a;
>
> public setA (int a) throws Exception {
> if (a > 100) throw new Exception ("Must be
> less than 100");
> }
>
> public setA (String a) throws Exception {
> try {
> setA(Integer.parseInt(a));
> } catch (NumberFormat Exception exception) {
> throw new Exception ("Format
> incorrect.");
> }
> }
>
> //I usually have one getA
> public int getA() {
> return a;
> }
> }
>
>
> Now when I use this bean in a JSP that is stored in
> the request scope,
> at times the compiler will complain that it cannot
> find a get method for
> "A". Even though one get method for that particular
> attribute is
> clearly there.
>
> Some added information, I use Forte Community
> Edition 2, and Tomcat.
> Forte's compiler complains about one attribute while
> Tomcat complains
> about another completely different attribute it
> cannot find the get
> method for. Which makes me itch with anger. The
> note is my example
> above is very simple. I used it just to explain my
> problem. My actual
> bean has about 17 attributes all with 2 setter
> methods each and 1 get
> method each.
>
> Does anyone know how to resolve this issue?
>
> Thanks for your help.
> Dan Hinojosa
>
>
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/