This ultra-quick blog entry shows how to use the JSF runtime to access metadata for a composite component. Note that most of the metadata is optional when creating a composite component, therefore, this entry will be of interest to tool vendors and those wishing to write composite components that stand a chance of showing up nicely in tools.

The Using Page

When showing a composite component demo, I always like to start out with the using page.

Listing 1: the using page

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <h:head>
  3.   <title>A Simple JavaServer Faces 2.0 View</title>
  4. <style type="text/css">
  5. .grayBox { padding: 8px; margin: 10px 0; border: 1px solid #CCC; background-color: #f9f9f9;  }
  6.  
  7. </h:head>
  8. <h:body>
  9.   <h:form>
  10.  
  11.     <p>Composite Component usage:</p>
  12.  
  13. <div id="cc"class="grayBox" style="border: 1px solid #090;">
  14. <my:myComponent loginAction="#{userBean.loginAction}" />
  15. </div>
  16.  
  17. <h2>Metada for This Composite Component</h2>
  18.  
  19. <div id="foo" class="grayBox" style="border: 1px solid #090;">
  20.     <pre>
  21.     <meta:printMetadata viewName="main.xhtml" libraryName="cc"
  22.                        resourceName="myComponent.xhtml"/>
  23.     </pre>
  24. </div>
  25.  
  26.  
  27.     <p><h:commandButtonvalue="submit" /></p>
  28.   </h:form>
  29. </h:body>
  30. </html>
  31.  

Line 5 declares the namespace

4 Comments