Building noncomposite custom components
Let's jump directly to the cool stuff and say that in JSF 2.0 a custom component was made available to page authors by configuring it in a Facelet tag library (*taglib.xml
).
Moreover, when the component is mapped in a JAR, a special entry in web.xml
is needed to point to the *taglib.xml
file. See the application named ch10_3
.
As of JSF 2.2, we don't need these files anymore. A JSF 2.2 simple custom component contains a single class, and it may look like the following code:
@FacesComponent(value = "components.WelcomeComponent", createTag = true) public class WelcomeComponent extends UIComponentBase { @Override public String getFamily() { return "welcome.component"; } @Override public void encodeBegin(FacesContext context) throws IOException { String value = (String) getAttributes().get("value"); String to = (String) getAttributes().get("to"); if...