[jsr-314-open] minor feature enhancement for Facelets/VDL
Andy Schwartz
andy.schwartz at ORACLE.COM
Mon Apr 13 10:58:58 EDT 2009
Hey Dan -
I agree that this would be a useful feature. I can easily imagine cases
where template authors may want to selectively render some bit of
content depending on whether a particular named template has been
ui:define'd.
Actually, a similar case may come up with composite component facets,
depending on how <composite:insertFacet> is implemented. If inserted
facets remain parented to the component component, then we should be
able to use #{compositeComponent.facets.<facet name here>} to check for
the presence of a particular facet. However, if insertFacet relocates
the facet component, seems like this would get trickier.
Andy
Dan Allen wrote On 4/8/2009 4:07 PM ET:
> I just thought of a feature I have often needed in Facelets that
> perhaps we can weave into the VDL. It would be nice to know if a named
> template has been defined inside the master template. Consider the
> following example:
>
> page.xhtml
> <ui:composition template="/WEB-INF/template.xhtml" ...>
> <ui:param name="title" value="VDL Template Page"/>
> <ui:define name="content">
> <h:outputText value="Hello World" />
> </ui:define>
> </ui:composition>
>
> template.xhtml
> <html ...>
> <h:head>
> <title>#{not empty title ? title : 'My Site'}</title>
> </h:head>
> <body>
> <div id="container">
> <ui:insert name="content"/> <- how do I know if it has
> been defined?
> </div>
> </body>
> </html>
>
> Since the <ui:param> creates a regular variable, I can check whether
> it is empty or not. But I do not have a way to check if the named
> template "content" has been defined. Of course, I can nest default
> content within the <ui:insert>, which is used when the named template
> is not defined, but there are cases when I simply need to know whether
> or not it is defined. Could we come up with some way to check if it is
> defined?
>
> -Dan
>
> --
> Dan Allen
> Senior Software Engineer, Red Hat | Author of Seam in Action
>
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
> http://in.relation.to/Bloggers/Dan
>
> NOTE: While I make a strong effort to keep up with my email on a daily
> basis, personal or other work matters can sometimes keep me away
> from my email. If you contact me, but don't hear back for more than a
> week,
> it is very likely that I am excessively backlogged or the message was
> caught in the spam filters. Please don't hesitate to resend a message if
> you feel that it did not reach my attention.
More information about the jsr-314-open-mirror
mailing list