PF5 <p:tree> <p:ajax listener =“”>通过<p:contextmenu> <p:menuitem>刷新后停止工作,在PF4中工作</p:menuitem> </p:contextmenu> </p :AJAX> </p:树>

时间:2014-09-15 20:07:21

标签: jsf primefaces tree listener

我使用的是PF5,Jboss7,Mojarra 2.2和Jdk1.7。 我有一个带有上下文菜单的动态树。当我单击menuitem时,页面将显示在内容面板中。然而,在那之后,看起来我失去了页面上包括树的所有听众。无法扩展,第二个menuitem没有响应,基本上,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:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:p="http://primefaces.org/ui">
<h:head>
   <title>IPMS Navigation Tree</title>
   <h:outputStylesheet library="stylesheet" name="lookfeel.css" />
</h:head>
<h:body>
   <p:layout fullPage="true">
      <p:layoutUnit position="west" resizable="true" size="400"
         minSize="100">
         <h:form id="navForm" prependId="false">
            <p:tabView>
                 <p:tab title="Domains">
                     <ui:include src="TabDomains.xhtml"/>
                 </p:tab>
                 <p:tab title="Orgs">
                     <ui:include src="TabOrgs.xhtml"/>
                 </p:tab>
                 <p:tab title="Admin">
                     <ui:include src="TabAdmin.xhtml"/>
                 </p:tab>
             </p:tabView>
         </h:form>
      </p:layoutUnit>

      <p:layoutUnit position="center">
         <h:form id="frmContent" prependId="false">
            <p:panel id="frmPanel">
               <ui:include src="#{menuController.page}.xhtml" />
            </p:panel>
         </h:form>
      </p:layoutUnit>
   </p:layout>
</h:body>
</html>

TabDomains.xhtml是

<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:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets">
    <p:tree id="domains" value="#{treeController.root}" 
        selectionMode="single"
         selection="#{treeController.selectedDomain}"
        var="node" dynamic="true" cache="false">
        <p:ajax event="expand" listener="#{treeController.onNodeExpand}" />
        <p:treeNode>
            <h:outputText value="#{node}" />
        </p:treeNode>
    </p:tree>
    <p:contextMenu for="domains">
        <p:menuitem id="propertiesMenu" value="Properties" update=":frmContent:frmPanel"
            actionListener="#{menuController.viewDomainProperties}">
            </p:menuitem>
        <p:menuitem id="editZoneMenu" value="Edit Zone" update=":frmContent:frmPanel"
            actionListener="#{menuController.viewEditZone}" 
            icon="ui-icon-close">
            </p:menuitem>
    </p:contextMenu>
</ui:composition>

支持bean是:

public class MenuController extends Controller
{
   private static final Logger logger = Logger.getInstance(MenuController.class);

   private String page;

   public MenuController()
   {
      super();
      this.page="MainContent";
   }

   public String getPage()
   {
      return page;
   }

   public void setPage(String page)
   {
      this.page = page;
   }

   public void viewEditZone()
   {
      logger.debug("begin viewEditZone");
      this.page="EditZone";
   }

   public void viewDomainProperties()
   {
      logger.debug("begin viewDomainProperties");
      this.page="DomainProperties";
   }
}

我在PF4中对此进行了测试,效果很好。任何帮助或指针来解决这个问题非常感谢。谢谢。

0 个答案:

没有答案