JSF2 custom component programming series Part 4

Source: Internet
Author: User

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 ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.