You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nick Pierpoint <ni...@panorama.com> on 2001/11/16 13:42:18 UTC

Using "class" as an attribute

Hello All.

I have a custom tag that Tomcat (Jasper) won't compile.

The problem is one of its attributes called "class". I want to include this
attribute so that users of the tag can set the style sheet attribute in the
same way as for other HTML4 tags.

Corresponding to the "class" attribute, there is a setClass(String) method.
There is not a getClass() method as it clashes with the getClass() method of
the underlying Object class.

I have tried this on Tomcat to 3.3 and it produces the following error
message:

    - org.apache.jasper.compiler.CompileException:
    /usr3/jakarta-tomcat-3.3/webapps/panportalDev/forms/ieformtest.jsp(41,0)
    Unable to find setter method for attribute: class
    at org.apache.jasper.compiler.TagBeginGenerator.generateSetters

There is public void setClass(String s) in the Tag
but, of course, no property called 'class'.


Using "class" as an attribute is very natural for page designers so I expect
there is a workaround. Anyone any ideas?


--
Nick Pierpoint


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Using "class" as an attribute

Posted by Mika Goeckel <mi...@stepstone.de>.
Nick,

unfortunately I know no straight workaround. The getClass method in
java.lang.Object is declared final and you would if you could override that
risk that the jre completely screws up.
You could of course call it CLASS. From a code purist's point of view that
would be blasphemic, but it should work.

Mika

----- Original Message -----
From: "Nick Pierpoint" <ni...@panorama.com>
To: <to...@jakarta.apache.org>
Sent: Friday, November 16, 2001 1:42 PM
Subject: Using "class" as an attribute


>
> Hello All.
>
> I have a custom tag that Tomcat (Jasper) won't compile.
>
> The problem is one of its attributes called "class". I want to include
this
> attribute so that users of the tag can set the style sheet attribute in
the
> same way as for other HTML4 tags.
>
> Corresponding to the "class" attribute, there is a setClass(String)
method.
> There is not a getClass() method as it clashes with the getClass() method
of
> the underlying Object class.
>
> I have tried this on Tomcat to 3.3 and it produces the following error
> message:
>
>     - org.apache.jasper.compiler.CompileException:
>
/usr3/jakarta-tomcat-3.3/webapps/panportalDev/forms/ieformtest.jsp(41,0)
>     Unable to find setter method for attribute: class
>     at org.apache.jasper.compiler.TagBeginGenerator.generateSetters
>
> There is public void setClass(String s) in the Tag
> but, of course, no property called 'class'.
>
>
> Using "class" as an attribute is very natural for page designers so I
expect
> there is a workaround. Anyone any ideas?
>
>
> --
> Nick Pierpoint
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Using "class" as an attribute

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Unfortunately, you're stuck -- and you can blame Java for this one ;-).

If you look at the JavaDocs for java.lang.Object (the top-level superclass
for all Java classes), you'll see that it includes a getClass() method
that returns the java.lang.Class for a paritcular object.  Therefore, you
cannot define your own "class" property (in the JavaBeans sense) as a
String, because the types will not match.

In the Struts tags that generate CSS class identifiers, I used an
attribute named "styleClass" instead, to get around this problem.

Craig


On Fri, 16 Nov 2001, Nick Pierpoint wrote:

> Date: Fri, 16 Nov 2001 12:42:18 -0000
> From: Nick Pierpoint <ni...@panorama.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Using "class" as an attribute
>
>
> Hello All.
>
> I have a custom tag that Tomcat (Jasper) won't compile.
>
> The problem is one of its attributes called "class". I want to include this
> attribute so that users of the tag can set the style sheet attribute in the
> same way as for other HTML4 tags.
>
> Corresponding to the "class" attribute, there is a setClass(String) method.
> There is not a getClass() method as it clashes with the getClass() method of
> the underlying Object class.
>
> I have tried this on Tomcat to 3.3 and it produces the following error
> message:
>
>     - org.apache.jasper.compiler.CompileException:
>     /usr3/jakarta-tomcat-3.3/webapps/panportalDev/forms/ieformtest.jsp(41,0)
>     Unable to find setter method for attribute: class
>     at org.apache.jasper.compiler.TagBeginGenerator.generateSetters
>
> There is public void setClass(String s) in the Tag
> but, of course, no property called 'class'.
>
>
> Using "class" as an attribute is very natural for page designers so I expect
> there is a workaround. Anyone any ideas?
>
>
> --
> Nick Pierpoint
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>