Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

question about extending component capabilities

 
Anthony Taylor
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSF, Is there a way to extend one of the current components capabilities without rewriting the whole component. For example, say I wanted to add some new elements to a textbox but I didn't want to rewrite an entirely new textbox object. Can anyone provide me with examples of how this would be done. I have done it before in dot.net with relative ease. Any help would be greatly appreciated.
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think someone asked this same question a month or 2 back, so you might want to search the forums.

Short answer: JSF objects are subclassable, so yes, you can extend them. However you'll have to define a new tag and associated TLD to associate this newly-enhanced object type with appropriate descriptions of its capabilities.
 
Anthony Taylor
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I searched through some of the examples on this site but none really answered the question. Suppose I wanted to extend the textbox tag in the following manner : <h:inputText id="name" attribute1="value1" attribute2="value2" value="Hello world"/>. In this example, attribute1 and attribute2 are not standard attributes. What all needs to change to make something like this work? The rendered, the actual class that represents this tag behind the scenes. I guess I am looking for a definitive example or set of steps to take to achieve this goal.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!