JSF模板 - 当faces-redirect未设置为“true”Primefaces时,标题不显示

时间:2014-01-12 20:43:56

标签: jsf layout primefaces templating

我正在使用JSF和Primefaces编写一个简单的页面。 这是我的模板:

<?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:p="http://primefaces.org/ui"
  xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
<p:layout fullPage="true">
    <p:layoutUnit position="north" header="North - header" style="font-size: 15px;">
        <h:form>
            <ui:include src="header.xhtml"/>
        </h:form>
    </p:layoutUnit>

    <p:layoutUnit position="west" header="West - menu" style="font-size: 15px;">
        <h:form>
            <ui:include src="menu.xhtml"/>
        </h:form>
    </p:layoutUnit>

    <p:layoutUnit position="center" header="Center - content" style="font-size: 15px;">
            <ui:insert name="content"/>
    </p:layoutUnit>

    <p:layoutUnit position="east" header="East - nothing" style="font-size: 15px;">
    </p:layoutUnit>

    <p:layoutUnit position="south" header="South - footer" style="font-size: 15px;">
        <ui:include src="footer.xhtml"/>
    </p:layoutUnit>
</p:layout>
</h:head>

<h:body>
</h:body>

</html>

我做了简单的菜单:

<?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:p="http://primefaces.org/ui">

<h:head>
<title>Simple JSF Facelets page</title>
</h:head>

<h:body>
<ui:composition>
    <p:menu>
        <p:submenu label="Main">
            <p:menuitem value="Show main" action="glowna?faces-redirect=true"/>
            <p:menuitem value="Show resultPage" action="resultPage?faces-    redirect=true"/>
            <p:menuitem value="Pictures" action="obrazek?faces-redirect=true"/>
        </p:submenu>
    </p:menu>
</ui:composition>
</h:body>

</html>

现在:我想在“content”unitlayout中添加一些内容。我制作了一个使用下面模板的简单页面。如果我添加了menuitem操作,例如:action =“glowna”,当我在页面运行时单击该项目时,将显示所有模板但没有标题部分。 左,右,中间和页脚部分显示正确,但标题消失。 但是,如果我添加动作atribute faces-redirect = true(action =“glowna?faces-redirect = true”),一切正常。

这是我的内容页面:glowna.xhtml

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

<h:head>
<title>Simple JSF Facelets page</title>
</h:head>

<h:body>
<ui:composition template="template.xhtml"
        xmlns:p="http://primefaces.org/ui">
    <ui:define name="content">
        <h1>Oto zawartość strony głownej - content</h1>
        <p:growl id="growl" showDetail="true"/>
        <p:panelGrid columns="1">
            <p:inputText value="#{user.imie}" required="true"/>
            <p:inputText value="#{user.nazwisko}" required="true"/>
            <p:commandButton value="Show it!" actionListener="#{user.click}" update="growl"/>
        </p:panelGrid>
    </ui:define>
</ui:composition>
</h:body>

</html>

任何人都知道为什么? 感谢ansewers:)

0 个答案:

没有答案
相关问题