2 Replies Latest reply on May 28, 2012 8:29 AM by arun.b

    Simple rich:panel

    arun.b Newbie

      Hi All,

       

      I am new to JSF and Richfaces, and I am trying the sample below. When I use template, the page is working fine (CSS and JS are being added). But when I directly write the rich:panel inside the ui:composition (without ui:define) as mentioned below, CSS and JS are not being added to the page output. Can someone help me in understanding the mistake I did when not using template?

       

      With template:

      <?xml version='1.0' encoding='UTF-8' ?>
      <!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:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich">
          <h:head>
              <title>Facelet Title</title>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          </h:head>
          <h:body>
              <ui:composition xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich" template="templates/template.xhtml">
                  <ui:define name="body">
                  <rich:panel header="Panel with default Look-n-feel">
                      Each component in RichFaces has a pre-defined set of CSS classes you can manipulate. If defined, those
                      classes overwrite the ones that come from the skin.
                  </rich:panel>
                  </ui:define>
              </ui:composition>
          </h:body>
      </html>
      

       

      template:

      <!DOCTYPE html>
      <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">
      
      <h:head>
          <title>RichFaces Application</title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          </h:head>
      
      <h:body>
              <ui:insert name="body">Default content</ui:insert>
      </h:body>
      </html>
      

       

      Without template: (CSS and JS are not being sent in the response)

      <?xml version='1.0' encoding='UTF-8' ?>
      <!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:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j"
                  xmlns:rich="http://richfaces.org/rich">
          <h:head>
              <title>Facelet Title</title>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
          </h:head>
          <h:body>
              <ui:composition>
                  <rich:panel header="Panel with default Look-n-feel">
                      Each component in RichFaces has a pre-defined set of CSS classes you can manipulate. If defined, those
                      classes overwrite the ones that come from the skin.
                  </rich:panel>
              </ui:composition>
          </h:body>
      </html>
      

       

       

      Thanks in advance.

        • 1. Re: Simple rich:panel
          Brendan Healey Master

          I expect it's the inclusion in the "without template" example of the ui:composition tag. There's something in the docs along

          the lines of "any content outside the ui:composition tag will be ignored by the view handler". Clearly you're not using a template

          in this example, you don't want anything to be ignored and you shouldn't be using ui:composition. If you just remove it everything

          should work.

           

          In your template example perhaps a better way of doing things is to replace the html tags with ui:composition. I have h:head

          and h:body tags only in my template, and ui:insert name="header" inside the h:head tag, and ui:insert name="content" inside

          the h:body tag.

           

          Hope this helps.

           

          Regards,

          Brendan.

           

          p.s. it's also a good idea in your template to wrap the h:head & h:body tags in f:view contentType="text/html". This helps make

          everything work on webkit based browsers like chrome.

          • 2. Re: Simple rich:panel
            arun.b Newbie

            Thanks Brendan for your quick response. Now, I have removed the ui:composition from the page without template and it works! I will check the corresponding documentation.