<div class="gmail_quote">On Mon, Apr 13, 2009 at 3:16 PM, David Geary <span dir="ltr">&lt;<a href="mailto:clarity.training@gmail.com">clarity.training@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
2009/4/8 Dan Allen <span dir="ltr">&lt;<a href="mailto:dan.j.allen@gmail.com" target="_blank">dan.j.allen@gmail.com</a>&gt;</span><br><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

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:<br>


<br>page.xhtml<br>&lt;ui:composition template=&quot;/WEB-INF/template.xhtml&quot; ...&gt;<br>    &lt;ui:param name=&quot;title&quot; value=&quot;VDL Template Page&quot;/&gt;<br>    &lt;ui:define name=&quot;content&quot;&gt;<br>


         &lt;h:outputText value=&quot;Hello World&quot; /&gt;<br>    &lt;/ui:define&gt;<br>&lt;/ui:composition&gt;<br><br>template.xhtml<br>&lt;html ...&gt;<br>    &lt;h:head&gt;<br>        &lt;title&gt;#{not empty title ? title : &#39;My Site&#39;}&lt;/title&gt;</blockquote>

</div><div><br>Alternatively, you can do &lt;ui:insert name=&quot;title&quot;&gt;My Site&lt;/ui:insert&gt; if you ui:define title in page.xhtml, although last time I checked, I don&#39;t believe that default values were working for ui:insert in Mojarra.</div>
</div></blockquote><div><br>Naturally. But the fallback fragment only partially solves the problem. It doesn&#39;t help if you need to perform logic based on whether or not a template is defined, or enforce that two or more templates are defined. The point is, there are many cases when I have encountered a need to know whether it&#39;s been defined or not, irregardless of whether a fallback kicks in.<br>
 <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div><br>However, that solution (if it works) isn&#39;t good enough because page authors should be able to conditionally render any chunk of XHTML, instead of just conditionally inserting with ui:insert. For example, the container div in the example above might have padding and a border, so if it has no content, you&#39;ll get a rectangle with a border, instead of nothing. Therefore, you want the page author to be able to conditionally render the div based on whether content has been defined.</div>
</div></blockquote><div><br>Exactly. It&#39;s not always so simple.<br><br>-Dan </div></div><br>-- <br>Dan Allen<br>Senior Software Engineer, Red Hat | Author of Seam in Action<br><br><a href="http://mojavelinux.com">http://mojavelinux.com</a><br>
<a href="http://mojavelinux.com/seaminaction">http://mojavelinux.com/seaminaction</a><br><a href="http://in.relation.to/Bloggers/Dan">http://in.relation.to/Bloggers/Dan</a><br><br>NOTE: While I make a strong effort to keep up with my email on a daily<br>
basis, personal or other work matters can sometimes keep me away<br>from my email. If you contact me, but don&#39;t hear back for more than a week,<br>it is very likely that I am excessively backlogged or the message was<br>
caught in the spam filters.  Please don&#39;t hesitate to resend a message if<br>you feel that it did not reach my attention.<br>