Part 4: The first simple Composite Component
Writing html Tag output by yourself is cumbersome, not to mention the support for other client Markup languages. Fortunately, we can reuse the standard tags of JSF2. This section implements the HtmlInput tag interface in the previous section, which is called the HtmlInput2 tag. The complete functions will be implemented in the following section.
First, create a directory jsfexunder src/main/resources/META-INF/, and create the htmlinput2.xhtml file under the jsfexdirectory, the content is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml" xmlns: h = "http://java.sun.com/jsf/html" xmlns: ui = "http://java.sun.com/jsf/facelets">
<H: body>
<Ui: composition>
<H: inputText/>
<H: commandButton type = "submit" value = "Click Me! "/>
<H: outputText value = "null"/>
</Ui: composition>
</H: body>
</Html>
Three standard tags of jsf2. Add a line under the namespace tag in the helloworld. taglib. xml file:
<Namespace> http://com.freebird/jsfex </namespace>
<Composite-library-name> jsfex </composite-library-name>
Add a tag element at the same time:
<Tag>
<Tag-name> htmlinput2 </tag-name>
<Source> jsfex/HtmlInput2.xhtml </source>
</Tag>
From the interface, this is all to do, isn't it easy? With this, you no longer need to output HTML tags through ResponseWriter.
Not finished, to be continued ..