JSF2 Composite Component Metadata Blog
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
- <!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:f="http://java.sun.com/jsf/core"
- xmlns:my="http://java.sun.com/jsf/composite/cc"
- xmlns:meta="http://mojarra.dev.java.net/cc-metadata">
- <h:head>
- <style type="text/css">
- .grayBox { padding: 8px; margin: 10px 0; border: 1px solid #CCC; background-color: #f9f9f9; }
- </style>
- </h:head>
- <h:body>
- <h:form>
- <div id="cc"class="grayBox" style="border: 1px solid #090;">
- <my:myComponent loginAction="#{userBean.loginAction}" />
- </div>
- <div id="foo" class="grayBox" style="border: 1px solid #090;">
- <pre>
- <meta:printMetadata viewName="main.xhtml" libraryName="cc"
- resourceName="myComponent.xhtml"/>
- </pre>
- </div>
- </h:form>
- </h:body>
- </html>
Line 5 declares the namespace
4 Comments
-
The Tag Library Document Generator doesn't work against either taglib.xml or Composite component metadata that I have been able to see. //
-
Hi,
In first thanks for this article and sorry for my english.
I have a question about composite, I would like to create composite 'autonome'. So I have some difficulities to initialize it.
For example, i take a composite to edit a user like :
<mycomposite userId="theidOfTheUserToShow">
and for implementation
<composite:interface>
<composite:attribute name="userId" required="true" />
</composite:interface>
<composite:implementation>
Edit : #{ctrlEditUser.username} ....
</.....>
My problem is what is the best way to initialize backean? There is a way to do #{ctrlEditUser.init(userId)}, or anything way?
Thanks
-
In JSF 2.2, we'll have UIViewAction and the <f:viewAction> tag.
In JSF 2.1 and 2.0 you can use f:event, as shown in this demo:
svn.java.net/svn/mojarra~svn/trunk/jsf-ri/systest/web/viewParameters/events.xhtml
Which is included from
svn.java.net/svn/mojarra~svn/trunk/jsf-ri/systest/web/viewParameters/page02.xhtml
-
mcalpay Oct 26, 2009 4:20 PM