-
1. Re: How i can create a customized tag ?
ilya_shaikovsky Mar 10, 2008 10:48 AM (in response to peerless)check facelets documentation for example about custom facelets creation.
-
2. Re: How i can create a customized tag ?
fabmars Mar 10, 2008 12:38 PM (in response to peerless)there are 2 kinds of tags:
-facelets custom tags which are only useable in a facelets environment and which are more or less code templates with dynamic attributes assigment (auto wiring).
http://www-128.ibm.com/developerworks/java/library/j-facelets/
http://www-128.ibm.com/developerworks/web/library/j-facelets2.html
If you have some form inputs repeated in many pages (a name+address form for example), then this approach is good for you. This is not easy to manipulate at first, then you will work easily with facelets tags.
- JSF custom tags. Basically you can wire anything from your model to your page and vice-versa, like any other JSF tag via 3 classes : the tag class holding your string tag attributes, the component class holding the actual values after evaluation, and the renderer class writing the html on the response. you also need one .tld to define the taglib, and possibly the facelets definition .taglib.xml if you want to use your tag in a facelets environment as well.
Making them is more work than facelets tag but they are useable in any JSf environment (facelets or not). Maybe you will struggle as long as you don't understand the JSF lifecycle very well, but after a while you'll find it not so hard.
Recently I made a rich editor JSF tag based on FCK editor using this approach (yes I know there is already one on Sourceforge but I wasn't happy with it).
http://today.java.net/pub/a/today/2004/07/16/jsfcustom.html
http://www.theserverside.com/tt/articles/article.tss?l=BuildingCustomJSF
http://eltegra.com/tutorial/jsf/jsftutorial-customcomponents.html
Also if you want to make Ajax components, RichFaces has some SDK making it much easier, but I am no expert in it.