2009/5/7 Norbert Truchsess <span dir="ltr">&lt;<a href="mailto:norbert.truchsess@t-online.de">norbert.truchsess@t-online.de</a>&gt;</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;">
you can ommit the xml-declaration being passed through by using<br>
ui:composition:<br>
<div class="im"><br>
&lt;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&gt;<br>
</div>&lt;ui:composition xmlns:ui=&quot;<a href="http://java.sun.com/jsf/facelets" target="_blank">http://java.sun.com/jsf/facelets</a>&quot;&gt;<br>
<div class="im">     xmlns:f=&quot;<a href="http://java.sun.com/jsf/core" target="_blank">http://java.sun.com/jsf/core</a>&quot;<br>
     xmlns:af=&quot;<a href="http://xmlns.oracle.com/adf/faces/rich" target="_blank">http://xmlns.oracle.com/adf/faces/rich</a>&quot;&gt;<br>
</div>  &lt;f:view&gt;<br>
    &lt;af:document/&gt;<br>
  &lt;/f:view&gt;<br>
&lt;/ui:composition&gt;</blockquote><div><br>Yes, and this should be a recommended practice, should it not? <br><br>However, the preceeding fragment is XML, not XHTML. If you have a view implemented as a composition, and you reference it as an action of a button or link, the corresponding file must have a .xhtml extension, or the navigation handler won&#39;t find it. IOW..<br>
<br>&lt;h:commandButton ... action=&quot;welcome&quot;/&gt;<br><br>...means the navigation handler will look for welcome.xhtml. If you name the file welcome.xml, you get an error message at runtime. But if welcome.xhtml uses a composition, like the preceeding code fragment, it&#39;s not an XHTML file, it&#39;s XML. Ugh.<br>
<br>Should the navigation handler also look for welcome.xml, or is that too naiive of a fix? <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>
(other issues still remain though)<br>
<br>
regards,<br>
<br>
Norbert<br>
<br>
Andy Schwartz schrieb:<br>
<div><div></div><div class="h5">&gt; Gang -<br>
&gt;<br>
&gt; I have been think about the Dan&#39;s blog entry on Facelets pages as valid<br>
&gt; XML documents:<br>
&gt;<br>
&gt; <a href="http://blog.hibernate.org/10752.lace" target="_blank">http://blog.hibernate.org/10752.lace</a><br>
&gt;<br>
&gt; Actually, I have been struggling with related issues.  Wanted to ping<br>
&gt; the EG to see whether we can start some discussion on this topic.<br>
&gt;<br>
&gt; In Dan&#39;s case, XML (plus XSD) provides a way to improve the page<br>
&gt; authoring experience.  In my case, I am interested in XML as a way to<br>
&gt; support content-type independence for contents rendered by Faces<br>
&gt; components.  That is, it should be possible to use Facelets as an XML<br>
&gt; document that describes how to build the component tree and leave the<br>
&gt; decision of whether to render XHTML content or HTML content (or some<br>
&gt; other type of content) up to the render kit.  While Facelets is fairly<br>
&gt; close to meeting this requirement, there are a couple of minor<br>
&gt; assumptions built into the Facelets implementations (both Facelets 1.x<br>
&gt; and JSF 2.0) that complicate matters.<br>
&gt;<br>
&gt; The complications arise from how Facelets treats XML-specific constructs<br>
&gt; such as:<br>
&gt;<br>
&gt; - The XML declaration<br>
&gt; - XML processing instructions<br>
&gt; - CDATA sections<br>
&gt;<br>
&gt; Currently these constructs are doing double-duty:<br>
&gt;<br>
&gt; 1. They are consumed by the Facelets XML parser.<br>
&gt; 2. They are passed through to the browser.<br>
&gt;<br>
&gt; I suppose that #2 makes sense if you view the Facelets page as an XHTML<br>
&gt; document to which some pre-processing is applied before handing off to<br>
&gt; the client.  However, this subverts the ability to support non-XML/XHTML<br>
&gt; content generation, such as HTML content generation.<br>
&gt;<br>
&gt; A simple example that demonstrates where we run into trouble...  In ADF<br>
&gt; Faces applications, the root component (under the view root) is<br>
&gt; typically an af:document component.  af:document takes care of rendering<br>
&gt; the document &quot;chrome&quot;, including the doctype and the html/head/body<br>
&gt; elements.  A minimal ADF Faces page might look something like this:<br>
&gt;<br>
&gt; &lt;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&gt;<br>
&gt; &lt;f:view xmlns:f=&quot;<a href="http://java.sun.com/jsf/core" target="_blank">http://java.sun.com/jsf/core</a>&quot;<br>
&gt;        xmlns:af=&quot;<a href="http://xmlns.oracle.com/adf/faces/rich" target="_blank">http://xmlns.oracle.com/adf/faces/rich</a>&quot;&gt;<br>
&gt;  &lt;af:document/&gt;<br>
&gt; &lt;/f:view&gt;<br>
&gt;<br>
&gt; This creates a trivial component tree: a UIViewRoot containing an ADF<br>
&gt; Faces RichDocument component.  It should be possible to render this<br>
&gt; component tree as either an XHTML or an HTML document.  The Renderer for<br>
&gt; the RichDocument component could easily handle both of these cases.<br>
&gt;<br>
&gt; However, there is a stumbling block...  With Facelets, the XML<br>
&gt; declaration ends up being passed through to the browser, regardless of<br>
&gt; what type of content the RenderKit happens to generate.  The end result:<br>
&gt; when rendering the document to HTML, we end up with a bogus XML<br>
&gt; declaration in our generated HTML content.<br>
&gt;<br>
&gt; In the above example, the purpose of including the XML declaration in<br>
&gt; the Facelets page is to ensure that the Facelets page is a valid XML<br>
&gt; document (#1 above), not for the purpose of including this in the<br>
&gt; generated content (#2 above), yet we end up with both.<br>
&gt;<br>
&gt; We run into similar problems with CDATA sections.  For example, the<br>
&gt; following code uses the Trinidad trh:script component to insert a script<br>
&gt; into the page:<br>
&gt;<br>
&gt;  &lt;trh:script&gt;<br>
&gt;    &lt;![CDATA[<br>
&gt;      if (0 &lt; 1) alert(&quot;Woohoo! Zero *is* less than one!&quot;);<br>
&gt;    ]]&gt;<br>
&gt;  &lt;/trh:script&gt;<br>
&gt;<br>
&gt; As with the previous example, the XML-specific construct (a CDATA<br>
&gt; section in this example) is meant to apply to the Facelets page itself -<br>
&gt; not to the generated content.  That is, the CDATA section provides a way<br>
&gt; to tell the Facelets parser not to parse the specified character data.<br>
&gt; This is not intended to be used as an instruction to the browser (just<br>
&gt; to Facelets XML parser).  However, Facelets passes the CDATA through to<br>
&gt; the browser.  As a result, in the case where we render HTML content, we<br>
&gt; end up with bogus CDATA sections inside of our generated HTML document,<br>
&gt; which causes the browsers to get confused.<br>
&gt;<br>
&gt; In order to support content independence (or, more particularly, to<br>
&gt; support HTML rendering), the render kit needs to be able to make<br>
&gt; decisions such as whether script contents need to be wrapped in CDATA<br>
&gt; sections (when generating XHTML content yes, HTML content no) or whether<br>
&gt; an XML declaration is necessary in the generated content (same deal).<br>
&gt; Note that this sort of content-type independence is already possible<br>
&gt; using JSP documents (ie. XML-based JSP pages), since JSP engines<br>
&gt; interpret the XML constructs as instructions for the JSP&#39;s XML parser.<br>
&gt; There is no assumption that the generated output will be XML/XHTML.  We<br>
&gt; would like to see Facelets support similar behavior.<br>
&gt;<br>
&gt; Of course, every Facelets page that currently exists relies on the<br>
&gt; current XHTML-centric behavior, so there is no chance that we can change<br>
&gt; this default behavior.  However, I would like to see some mechanism for<br>
&gt; opting in to a more XML-centric processing model.  I suppose that this<br>
&gt; could be left up to the JSF implementations to provide, though it seems<br>
&gt; like this might be a reasonable candidate for a spec-level solution.<br>
&gt;<br>
&gt; Thoughts?<br>
&gt;<br>
&gt; Andy<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>