-----Original Message-----
From: Richard Dallaway <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, 16 March 1999 1:16
Subject: Elegant BEAN setting/getting
>My problem is that my "country" value is really an integer. My set and
>get methods should really be: "int getCountry()" and "void
>setCountry(int)".  But this doesn't work: the set() method is not
>called, presumably because the bean mechanism thinks my FORM variable
>"country" is a string.
>
>And I can't mix the set() and get()s to have "void setCountry(String)"
>with an "int getCountry()".  That would sort of be OK.  However,  the
>setMethod() is not called.  Presumably because introspection has decided
>it is a read-only property after finding the int getCountry....
>
>Anyone want to offer an elegant way to handle this sort of thing?  Is
>there something I have do something special with BeanInfo to get this
>kind of thing to work?


I won't claim this is elegant, but you could change your get/setCountry
methods to use integers, and then create get/setCountryAsString methods
which do the appropriate conversions and call get/setCountry. At least this
wouldn't force you to do conversions in the bean's client code when you use
it outside a JSP.

Tom

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to