>From: "Ryan Wynn" <[EMAIL PROTECTED]> 
>
> A developer on my team is trying to use both full html and xml views 
> in his application. He is running into a problem after the first 
> transition from a full html view into a full xml view. 
> 
> The transition to to the first xml view displays correctly. The form 
> on this page is displays a postback to the /app/foo.xml view id. 
> However, when the form is submitted it seems the restoreView of clay's 
> viewHandler gets confused. It logs that it is restoring the 
> /app/bar.html view id which had previously transitioned to 
> /app/foo.xml instead of restoring /app/foo.xml. The result is a page 
> not found error. 
> 
> Although I haven't seen the combination used in the clay usecase app I 
> am assuming that the combination is possible from the documentation. 
> Does anyone know why transitioning from one full xml view to another 
> would be a problem given that the first came from a full html view? 
> 

The shale clay usecases app plays this game.  There are several trick to make 
it work.  The faces servlet has to be mapped to both suffixes in the web 
deployment descriptor.

 <!-- JavaServer Faces Servlet Mapping for Clay HTML Full View -->
 <servlet-mapping>
  <servlet-name>faces</servlet-name>
  <url-pattern>*.html</url-pattern>
 </servlet-mapping>
 <!-- JavaServer Faces Servlet Mapping for Clay XML Full View -->
 <servlet-mapping>
  <servlet-name>faces</servlet-name>
  <url-pattern>*.xml</url-pattern>
 </servlet-mapping>


You also need to register a preprocess filter command that catches the view 
suffix before it's converted to the "javax.faces.DEFAULT_SUFFIX".  The Clay 
view handler insists that the suffix remains the same.  

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

You will find this command defined in the /WEB-INF/chain-config.xml.

<catalogs>
 <!-- Define preprocessing command chain for Shale to execute -->
 <catalog name="shale">
  <chain name="preprocess">
   <!-- This command is only needed for full clay html views with myfaces  -->
   <command
    className="org.apache.shale.clay.faces.ClayViewHandlerCommand" />

In the long run, you might be better off in choosing a single type of page 
entry point.  JSF only allows you to define a single one using the 
"javax.faces.DEFAULT_SUFFIX" param.  As far as I know, the combination of the 
preprocess command and the servlet mappings will let you define two types but 
this is going against the grain.

I just checked in an example project in the sandbox called 
"shale-clay-mailreader" that uses xml views as the page entry point that 
includes html templates.  I tried to pick a lane in this example and only show 
one type of entry point.  


> Thanks, 
> Ryan


Gary
 

Reply via email to