You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Heath Borders <he...@gmail.com> on 2005/02/02 18:08:38 UTC

Macro tag.

I've been trying to thing of a strategy for developing a custom tag
that is nothing more than a macro of other tags.  You could really use
this strategy as a way for developing custom JSF components without
needing to write a renderer because you'd be utilizing the rendering
of the existing JSF components that the macro tag is building.


Here is an example:

Let's say that I want to build beveled header (just a text header with
a background color and rounded images on the sides to give it a
rounded-rectangle appearance).

Its easy to build a custom component for that header and have its
children render themselves inside.

Now, let's say that I'm constantly adding dataTables inside this
header, and I want to make a common datatable tag (HeaderTable) that
first adds a header to the JSF tree, then adds my datatable as a
child, and then adds any children of my HeaderTable as children of the
datatable.  Here is code:

<heath:headerTable value="#{bean.foos}" var="foo" header="My Header Table">
<h:column>
  <h:outputText value="#{foo.bar}" />
</h:column>
</heath:headerTable>

The above JSP code should be the same as this JSP code:

<heath:header value="My Header Table">
<h:dataTable value="#{bean.foos}" var="foo">
<h:column>
  <h:outputText value="#{foo.bar}" />
</h:column>
</heath:headerTable>

It is not currently possible to accomplish this inside of the
setProperties method of UIComponentTag, so I'm wondering what I would
need to do to accomplish this.  I'd of course attempt to make this
code abstract so that others could use it.

-- 
-Heath Borders-Wing
hborders@mail.win.org