2009/4/8 Dan Allen <span dir="ltr"><<a href="mailto:dan.j.allen@gmail.com">dan.j.allen@gmail.com</a>></span><br><div class="gmail_quote"><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><ui:composition template="/WEB-INF/template.xhtml" ...><br> <ui:param name="title" value="VDL Template Page"/><br> <ui:define name="content"><br>
<h:outputText value="Hello World" /><br> </ui:define><br></ui:composition><br><br>template.xhtml<br><html ...><br> <h:head><br> <title>#{not empty title ? title : 'My Site'}</title></blockquote>
<div><br>Alternatively, you can do <ui:insert name="title">My Site</ui:insert> if you ui:define title in page.xhtml, although last time I checked, I don't believe that default values were working for ui:insert in Mojarra.<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;"><br>
</h:head><br> <body><br> <div id="container"><br> <ui:insert name="content"/> <- how do I know if it has been defined?<br> </div><br> </body><br>
</html><br><br>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 </blockquote>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">it is defined. Could we come up with some way to check if it is defined?</blockquote><div> <br>
With default values, you should be able to do this:<br><br> <ui:insert name="content"></ui:insert><br><br>And nothing should be inserted if content is not defined. Again, I don't know if that works in Mojarra.<br>
<br>However, that solution (if it works) isn'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'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.<br>
<br><br>david<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;"><br>
<br>-Dan<br><br>-- <br>Dan Allen<br>Senior Software Engineer, Red Hat | Author of Seam in Action<br><br><a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br>
<a href="http://in.relation.to/Bloggers/Dan" target="_blank">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'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't hesitate to resend a message if<br>
you feel that it did not reach my attention.<br>
</blockquote></div><br>