JSF Tip #37 - Create a composite component

Creating and using a composite component is very straightforward.

  1. Creating the composite component
  2. Using the composite component

Creating the composite component


    <?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:cc="http://java.sun.com/jsf/composite">
        <body>
            <cc:interface></cc:interface>
            <cc:implementation>
                This is coming from a composite component! Hurray :)
            </cc:implementation>
        </body>
    </html>
        

Using the composite component


    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:mypanel="http://java.sun.com/jsf/composite/mypanel">
        <h:head>
            <title>Composite component</title>
        </h:head>
        <h:body>
            <h2>Composite component</h2>
            <mypanel:mypanel/>
        </h:body>
    </html>
        

Posted November 12, 2013

Up