Question

I am trying some sample of richfaces4 in tomcat7. If I copy the code in the "view source" of http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=panel&skin=emeraldTown to a test.xhtml file. If I go to http://localhost/jsf-blank/test.jsf. I will just see a web page with PLAIN TEXT, not the panel shown in the demo...

I found 2 ways to make it like the demo page.

The first way is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
<h:head>
</h:head>
<h:body>
    <--!!!insert rich:panel tags here!!!-->
</h:body>
</html>

The second way is:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich">

 <f:view>
 <h:head></h:head>
 <h:body>
    <--!!!insert rich:panel tags here!!!-->   
 </h:body>
 </f:view>

</ui:composition>

Question: Could someone explain in more depth why the above 2 pieces of code work but the code directly from the demo does not work??? Looks like the tag is the key to render the components. Someone asked the similar question here RichFaces4 don't render the components Thanks.

Was it helpful?

Solution

You might find answer in Java EE 6 Tutorial in section "Using Facelets Templates": http://docs.oracle.com/javaee/6/tutorial/doc/giqxp.html

What you see when you click "View source" link is code of a client page so you need also a template.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top