3 Replies Latest reply on Apr 9, 2012 12:30 PM by songjinglim

    Richfaces template header

    songjinglim

      I'm using richface 4.1 and I found out for my template as shown below:

       

          <!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">

         

          <h:head>

              <title><ui:define name="title">Application Title</ui:define></title>

              <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />

          </h:head>

         

          <h:body>

              <ui:insert name="body">Default content</ui:insert>

          </h:body>

          </html>

       

      It always add extra head info for me:

       

          <link type="text/css" rel="stylesheet" href="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/DEFAULT/skinning.css" /><script type="text/javascript" src="/javax.faces.resource/jsf.js.jsf?ln=javax.faces"></script><script type="text/javascript" src="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/packed/packed.js"></script>

       

      If I take out this portion from template, those extra info will be disappear:

       

          <h:head>

              <title><ui:define name="title">Application Title</ui:define></title>

              <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />

          </h:head>

       

      With that extra info, the page render more better however if this page navigate to next page base on value return from form action (as defined in faces-config.xml), the component (e.g. a4j:commandButton ) will not work, need click twice only function.

       

      Is that a bug?  if you go to richfaces showcase and open the source, the meta info for head are diff.  Any ideal why I get those extra meta info that seem buggy...

        • 1. Re: Richfaces template header
          healeyb

          Try wrapping everything inside the <html></html> tags with <f:view contentType="text/html"></f:view>, and try

          using ui:insert for the title rather than ui:define. I really don't know if it'll make any difference, but it's all I can

          think of!

          • 2. Re: Richfaces template header
            songjinglim

            Hi Brendan

             

            Thanks for the suggestion but not help...

             

            [Tempalte]

            <!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">

            <f:view contentType="text/html">

                <h:head>

                    <ui:insert name="head"></ui:insert>

                    <!-- Mimic Internet Explorer 8 -->

                    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

                    <meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />

                    <title><ui:insert name="title">CEA</ui:insert></title>

                </h:head>

               

                <h:body>

                    <div id="page">

                        <div id="header">

                            <div class="right-controls">

                                <ul class="top-links layout">

                                    <li><a href="http://jboss.org/richfaces" target="_blank">Project Site</a>

                                    </li>

                                </ul>

                            </div>

                        </div>

                        <div id="page-content">

                        

                            <ui:include src="/templates/includes/navigation.xhtml" />

                       

                            <ui:insert name="body">

                                    Body content missed

                            </ui:insert>

                            <div class="clear"></div>

                        </div>

                        <div id="footer">

                            <ui:insert name="footer"></ui:insert>

                        </div>

                    </div>

                </h:body>

            </f:view>

            </html>

             

            [p.xhtml]

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

             

            <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"

                template="/templates/template.xhtml">

             

                <h:outputStylesheet>

            .red {

                color: red;

            }

             

            .green {

                color: green;

            }

            </h:outputStylesheet>

                <ui:define name="body">

                    <h:form>

             

                        <a4j:commandButton value="Store changes"

                            action="#{profileCreation.goNext}" />

             

                    </h:form>

                </ui:define>

            </ui:composition>

             

             

            profileCreation.goNext only do one thing, return the success value:

            public String goNext() {

              return IdmConst.IDM_CREATE_PROFILES_SUCCESS;

            }

             

            [faces-config.xml]

            <navigation-rule>

              <display-name>p.jsf</display-name>

              <from-view-id>/public/idm/p.xhtml</from-view-id>

              <navigation-case>

               <from-outcome>IDM_CREATE_PROFILES_SUCCESS</from-outcome>

               <to-view-id>/jsf/idm/resetpwd.xhtml</to-view-id>

              </navigation-case>

            </navigation-rule>

             

            [resetpwd.xhtm]

            <!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:rich="http://richfaces.org/rich"

                xmlns:a4j="http://richfaces.org/a4j">

             

            <ui:composition template="/templates/template.xhtml">

                <ui:define name="head">

                    <style type="text/css">

            .leftColumn {

                width: 40%;

                vertical-align: top;

                text-align: left;

                padding: 15px;

                background: #00FFFF;

            }

             

            .rightColumn {

                width: 60%;

                vertical-align: top;

                text-align: left;

                padding: 15px;

            }

            .red {

                color: red;

            }

             

            .green {

                color: green;

            }

            </style>

                </ui:define>

                <ui:define name="title">Change / Rest Password</ui:define>

             

                <ui:define name="body">

             

                <h:form id="resetPwdForm">   

                    <rich:graphValidator value="#{passwordValidationBean}" id="gv">

                        <rich:panel header="Change password" style="width:500px">

                            <rich:messages for="gv"/>

                            <rich:messages globalOnly="true"/>

                            <h:panelGrid columns="3">

                                <h:outputText value="Enter new password:" />

                                <h:inputSecret value="#{passwordValidationBean.password}" id="pass" />

                                <rich:message for="pass" />

                                <h:outputText value="Confirm the new password:" />

                                <h:inputSecret value="#{passwordValidationBean.confirm}" id="conf" />

                                <rich:message for="conf" />

                            </h:panelGrid>

                            <a4j:commandButton value="Store changes"

                                action="#{passwordValidationBean.storeNewPassword}" />

                        </rich:panel>

                    </rich:graphValidator>       

                </h:form>

                </ui:define>

            </ui:composition>

            </html>

             

            [passwordValidationBean]

            - I use the sample from richfaces showcase (http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=graphValidator&skin=blueSky)

             

            As you can see as defined in faces-config, after user click the button on p.xhtml it will go to resetpwd.xhtml, if I have <h:head>..</h:head> defined in tempalte, then the button on resetpwd.xhtml will not work properly, I need click twice then will process the request.  Well, if I directly go to resetpwd.xhtml wthout go throgh p.xhtml, everything is working fine.

             

            So I suspect the problem cause by the <h:head>..</h:head> defined in tempalte., with this xml element, page source willd isplay extra header info:

                <link type="text/css" rel="stylesheet" href="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/DEFAULT/skinning.css" /><script type="text/javascript" src="/javax.faces.resource/jsf.js.jsf?ln=javax.faces"></script><script type="text/javascript" src="/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.1.0.Final/PackedCompressed/packed/packed.js"></script>

             

            Must be some bug in richface state managmeent or the extra meta info included in head.  As mention if I directly go to resetpwd.xhtml, everything work fine (i.e. button on that page no need click twice to respond).   If navigate from p.xhtml to resetpwd.xhtml will work fine if take out the <h:head>...</h:head> from tempalte file, but if I do so then the page will not render with skin.

             

            Please help.  Thanks

            • 3. Re: Richfaces template header
              songjinglim

              Problem identiy.  If jsf / xhtml page is forward from other page then the submit button will not work and need click twice.  However if jsf / xhtml page is redirect from other page then everything work fine.

              1 of 1 people found this helpful