我想用primeface <p:layout>
創建兩個<p:layoutUnit>
s。西部<p:layoutUnit>
爲菜單和中心<p:layoutUnit>
爲點擊菜單上的項目時出現頁面。 因爲<p:menu>
必須包裝在<h:form>
,所以我的內容在中心,因爲我需要使用表來顯示數據。所以,我的XHTML頁面看起來像以下:如何在PrimeFaces中更新表格layoutUnit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.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:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head>
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
<title>PrimeFaces</title>
</f:facet>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="west" size="175" header="Left" collapsible="true">
<p:menu>
<p:submenu label="testUpdate">
<p:menuitem value="open" id="open" actionListener="#{backingBean.open()}" update=":center_form"/>
<p:menuitem value="close" id="close" actionListener="#{backingBean.close()}" update=":center_form"/>
</p:submenu>
</p:menu>
</p:layoutUnit>
<p:layoutUnit position="center">
<p:panel id="center_panel" rendered="#{backingBean.render}">
<h:form id="center_form">
testing
</h:form>
</p:panel>
</p:layoutUnit>
</p:layout>
</h:body>
</f:view>
</html>
和我的web.xml:
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
問題是AJAX似乎不能正常工作,當我點擊「打開」和「關閉」,我必須通過手動重新加載頁面來更新我的連接,以便更新頁面。
我可以知道是否可以做? 如果是這樣,我的代碼裏面有什麼不對嗎? 或者我能做些什麼來讓中心layoutUnit在我點擊菜單上的項目時自動更新?
你應該使用'H:head'包括對Ajax的JSF庫。 –
告訴我它是否有效! –
這不是問題,因爲我只是給我的代碼的一部分...否則,頁面無法正常啓動,但不只是一個更新問題..對不起,這.. ..我會粘貼我的完整代碼以後你的網頁 – tanghao