• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tags and class attribute

 
Jeremy Linzer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to have an attribute named "class" for a custom tag. In the tag handler, actually a superclass of the actual tag handler, I have a setClass method to set the "class" attribute. The problem is the JSP won't compile. I am using WSAD 5.0 and it tells me there is JSP translate error on the page - it can't find the setter for the "class" attribute. If I rename the attribute, and its setter, things work ok. Is "class" a reserved attribute or is the setClass method some how not able to be overrriden?

Thanks
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, JSPs compile down to Java, don't they, and class is obviously a Java reserved word. Your class attribute probably translates to a member field named class, which causes the compiler to make a quiet pop. In the APIs I've seen the word clazz substituted for class. Depending on what type of class you're using you might want to try a synonym.

Jules
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use className because that's really what you are passing, right? I've seen others use "clazz" which grates on my molars.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!