>From: René Zanner <[EMAIL PROTECTED]> 
>
> Hi folks, 
> 
> I'm missing something in Clay's full HTML views which is known from the Tiles 
> integration. 
> 
> In a JSF/Tiles integration, when specifying a view id, this id is looked up 
> in 
> the tiles-defs.xml first (maybe after some processing of the view id, e.g. 
> replacing the extension and so on). Only when there's no tiles definition 
> found 
> by that name, the request is dispatched to the default view handler (that is, 
> to 
> the file system to search for a corresponding JSP file). 
> 

The Clay full XML views, which are tiles like, are only conceptually similar.  
The JSF/Tiles integration allows you to build pages using fragments of JSP.  

The Clay feature that allows the application entry point to be a pseudo page 
(not a physical page), will not allow using JSP fragments as view compositions. 
 You can use a clay component in a JSP but a clay template can not include a 
JSP fragment.

There are a couple factors that prevent mixing JSP fragments within a clay 
template.  
* In JSF 1.1, the jsp tags create the JSF component, add it to the component 
tree and then invoke renderering.  Clay and Faclets are more like JSF 1.2.  
They build the entire component tree first and then invoke renderering.

* The JSF/JSP tags don't have a standard way of keeping track of the last JSF 
component.  When adding a page fragment to the component tree, a template has 
to know what parent to graft to.


> When specifying a view id with Clay, the suffix is checked first. When it's 
> *.html or *.xml, it's supposed to be a file template and Clay tries to load 
> that 
> file. 
> 

These suffixes can be overridden using a init param.  You will also have to 
define a mime type for the suffix in the web.xml and your http server's config.

<context-param>
   <param-name>
       org.apache.shale.clay.HTML_TEMPLATE_SUFFIX
   </param-name>
   <param-value>.clayh</param-value>
</context-param>
<context-param>
    <param-name>org.apache.shale.clay.XML_TEMPLATE_SUFFIX</param-name>
    <param-value>.clayx</param-value>
</context-param>



> So, when specifying a view id like /clay.html, I MUST have a corresponding 
> clay.html file in the document root of my web application, even if it has 
> only 
> the meaningless content: 
> 

That's is correct if you are using full html views as your page entry point.  
You will need a physical file to define the outer template.

However, full XML views are more like tiles defs.  The entry point can be a 
single file or can be a component definition within a single XML document (It 
would be hard to merge multiple html documents into a single document).

Full XML views are loaded on starup versus on demand.  You define these config 
files in a init param in the web.xml.

 <!-- Clay Configuration Full XML view Resources -->
 <context-param>
  <param-name>
   org.apache.shale.clay.FULLXML_CONFIG_FILES
  </param-name>
  <param-value>
   classpath*:org/apache/shale/usecases/symbols/clay-tiles-config.xml
  </param-value>
 </context-param>



> 
> 
> 
> Is there a way to avoid this? 
> 
> I want to use Tiles like page composition. My Clay config file contains a 
> base 
> layout definition and a page composition definition. 
> 

The symbols usecase in the shale-clay-usecases shows an example of using full 
XML views.
There is a bit of a trick in this app.  This app uses full HTML, XML and JSP's. 
 JSF only 
wants you to pick a single view type.  The trick is that we catch the suffix of 
the view before
it's normalized into the one type.

If you choose full Clay XML views as the page entry point, you will want to set 
the 
default suffix in the web xml to match the suffix clay assumes.

  <context-param>
     <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
     <param-value>.xml</param-value>
  </context-param>


>  <!-- base layout defintion -->
>  <component jsfid="basePage" extends="clay">
>    <attributes>
>      <set name="clayJsfid" value="/layouts/shale.layout.html" />
>    </attributes>
>    <symbols>
>      <set name="@title" value="Default Title" />
>      <set name="@bodycontent" value="space" />
>      <set name="@footercontent" value="footerPanel" />
>    </symbols>
>  </component>
> 
> <!-- page composition definition -->
>  <component jsfid="pageCompositionId" extends="basePage">
>    <symbols>
>      <set name="@title" value="Test page for page composition" />
>      <set name="@bodycontent" value="/tiles/shale.body.test.html" />
>    </symbols>
>  </component>
> 
> 
> I just want to request the page composition id (/pageCompositionId.html) and 
> receive the corresponding composite from the Clay config - without that 
> superfluous HTML template. 
> 

You need to look at the full XML views.  They are the most like tiles.   Within
the XML view you can include HTML templates but the entry point needs to be
a XML view.    


I have a mail reader example that uses full xml views.  This one choose a lane
where the other example tries to show it all.


> Thank you very much! 
> 
> Cheers, 
> 
> René 


Gary

Reply via email to