Richfaces模板标题

时间:2012-02-19 11:31:47

标签: templates jsf jsf-2 richfaces

我正在使用RichFaces 4.1,我找到了我的模板,如下所示:

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

它总是为我添加额外的头部信息:

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

如果我从模板中取出这部分,那些额外信息将会消失:

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

使用额外的信息,页面呈现得更好,但是如果此页面基于表单操作的值返回(如faces-config.xml中定义)导航到下一页,则组件(例如a4j:commandButton)将不起作用,需要点击两次才能运行。

这是一个错误吗?如果你去richfaces展示并打开源代码,那么head的元信息就是diff。任何理想我为什么会得到那些看似错误的额外元信息...

----一些额外的信息--- 嗨布伦丹

感谢您的建议,但没有帮助...

[模板]

<!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只做一件事,返回成功值:

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]

  • 我使用richfaces展示的样本(http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=graphValidator&skin=blueSky)<< li>

正如你在faces-config中看到的那样,在用户点击p.xhtml上的按钮后,它将转到resetpwd.xhtml,如果我在模板中定义了,那么resetpwd.xhtml上的按钮将不起作用没问题,我需要点击两次然后处理请求。好吧,如果我直接去resetpwd.xhtml去throgh p.xhtml,一切都运转良好。

所以我怀疑问题是由...在模板中定义的。使用这个xml元素,页面源会显示额外的标题信息:

必须是richfaces状态管理中的一些错误或头部中包含的额外元信息。如果我直接转到resetpwd.xhtml,一切正常(即该页面上的按钮无需点击两次即可响应)。如果从p.xhtml导航到resetpwd.xhtml可以正常工作,如果从tempalte文件中取出...,但如果我这样做,那么页面将无法用皮肤渲染。

0 个答案:

没有答案