tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phillip Morelock <subscripti...@phillipmorelock.com>
Subject Re: Unable to find setter: a problem with custom tag in TC 4.0.4b2
Date Sat, 01 Jun 2002 23:08:08 GMT
I don't know if this is the desired answer, and don't have time to think
about the Java language issues here, but a quick fix would be to change:
 
protected int numItems = -1;

to

private int numItems = -1;

Then remove the overrides from Search and FullSearch classes.  Then ensure
that all access to the numItems variable occurs through getNumItems() and
setNumItems() in the base class, ListTag.

I have a feeling this has something to do with the fact that jsp:setProperty
can take two courses:
1.  Set a public variable directly if it has the same name
2.  Prepend "set" and adjust capitalization, as you seem to have
anticipated.

I would think, though, that option #1 would be excluded in this case because
the java compiler would refuse to compile your jsp if it thought you were
exactly trying to address a non-permitted variable (which the protected
variable shouldn't be permitted).

Can you send the stack trace of the exception?  Also, do you know that the
translated version of your page (the .java file it gets converted into) is
in the /work directory?  Check that out (_if_ tomcat got past the
translation phase, this is why you need to provide the stack trace) and you
can usually pinpoint your problem.

fillup

P.S.  Subclasses inherit all the public methods of all superclasses, so I
don't really understand your overrides.

On 5/29/02 8:04 PM, "Vernon Wu" <vernonw@gatewaytech.com> wrote:

> Hi, all,
> 
> I run into an error message on Tomcat 4.0.4b2 when I use a custom tag in a JSP
> file. The error message is:
> 
> /jsp/fullsearchlist/content.jsp(4,0) Unable to find setter method for
> attribute:   numItems
> 
> The code fragment is  the followings:
> 
> public abstract class ListTag extends TagSupport {
> // ...
> protected int numItems = -1;
> //...
> 
> // setters
> public void setNumItems(String numItemsStr) {
>   numItems = Integer.parseInt(numItemsStr);
> }
> }
> 
> public abstract class SearchListTag extends ListTag {
> //...
> // setters (overloaded to fix bug in tomcat)
> public void setNumItems(String numItemsStr) {
>   super.setNumItems(numItemsStr);
> }
> }
> 
> public class FullSearchListTag extends SearchListTag {
> //...
> public void setNumItems(String numItemsStr) {
>   super.setNumItems(numItemsStr);
> }
> }
> 
> I have tried to remove the setNumItems method from SearchList and/or
> FullSearchList, but can't resolute the problem.
> I
> learn that there was a bug led to this problem in the early version of Tomcat.
> Is   the bug unresolved yet? How I can
> overcome this problem?
> 
> Thanks very much in advance.
> 
> Vernon
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message