2013-01-14 46 views
0

我在JSF2.1中使用Primefaces 3.4.2我創建了一個分成一些佈局單元的頁面。在正確的佈局單元中,我有一個accordionPanel並創建了動態菜單,中間的中間佈局由ui:include和一個頁面加載到圖層中,當我點擊一個鏈接時會打開一個包含動態頁面的對話框。 打開和關閉對話框後,如果沒有在右側佈局中執行任何操作,則中間中間佈局不再起作用。我可以看到它,但我點擊輸入文本我不能輸入任何東西,也點擊其他組件沒有反應!什麼是問題?有沒有解決方法?primefaces佈局

當點擊菜單項打開對話框時包括其他頁面和點擊樹節點中心佈局改變時,在對話框中打開的頁面運行良好,但在關閉對話框,中間佈局按鈕和輸入不工作時,其他佈局組件運行良好!

我的新代碼:

 <p:layoutUnit id="right" position="east" size="145" style="text-align:center;direction: ltr!important;padding: 0px!important;"> 
        <h:form prependId="false"> 
         <script type="text/javascript"> 
          function test(id,url,title){ 
           document.getElementById('h1').value=id; 
           document.getElementById('h2').value=url; 
           document.getElementById('h3').value=title; 
           salamm.jq.click(); 
          } 
         </script> 
         <h:inputHidden id="h1" value="#{adminC.nclose}" /> 
         <h:inputHidden id="h2" value="#{adminC.nurl}"/> 
         <h:inputHidden id="h3" value="#{adminC.ntitle}"/> 
         <p:commandButton actionListener="#{adminC.addTab()}" id="salam" widgetVar="salamm" update=":dlgpanel" onstart="waitDialogmain.show()" style="display: none" oncomplete="waitDialogmain.hide();dlg1.show()"/> 
         <p:accordionPanel style="text-align: center;font-family: tahoma!important" activeIndex="#{menuGen.activeIndex}"> 
          <p:tab title="connections" id="t0" rendered="#{menuGen.menuList1.length()>0}" > 

           <center> 

               <h:outputText escape="false" value="#{menuGen.menuList1}"/> 
              </center> 
              <br/> 
             </p:tab> 
             <p:tab title="manage" id="t1" rendered="#{menuGen.menuList2.length()>0}" > 
              <center> 
               <h:outputText value="#{menuGen.menuList2}" escape="false"/> 
              </center> 
              <br/> 
             </p:tab> 

          </p:accordionPanel> 
        </h:form> 
           </p:layoutUnit> 
       <p:layoutUnit id="center" style="padding: 0px!important;" position="center"> 
        <p:layout widgetVar="mkh"> 
         <p:layoutUnit id="middleright" position="east" size="170" collapsible="true" style="padding: 0px;direction: ltr" > 
          <h:form prependId="false"> 
          <p:tree value="#{treeC.root}" var="node" dynamic="true" style="width: 165px;border: none;direction: rtl!important;text-align: right;font-family: tahoma;font-weight: bold" selectionMode="single" selection="#{treeC.selectedNode}"> 
           <p:ajax event="select" listener="#{treeC.onNodeSelect}" onstart="waitDialogmain.show()" oncomplete="waitDialogmain.hide()" />  
           <p:treeNode > 
            <h:outputText value="#{node}"/> 
           </p:treeNode> 

          </p:tree> 
          <p:commandButton onclick="mkh.toggle('east')" icon="ui-icon-triangle-1-e" title="ctr+shift+right arrow" style="width: 6px;height: 80px;position: absolute;top: 50%;" type="button"/> 
         </h:form> 
         </p:layoutUnit> 
         <p:layoutUnit id="middlecenter" style="padding: 0px!important;" position="center"> 
          <p:layout style="text-align: center"> 
           <p:layoutUnit id="middlecenter1" style="padding: 0px!important;" position="center" resizable="true" > 

             <p:outputPanel autoUpdate="true" id="dlgpanelcenter">     
             <center> 
              <ui:include src="./../users/networkReport.xhtml" /> 
             </center> 
            </p:outputPanel> 

           </p:layoutUnit>         
           <p:layoutUnit id="middleBottom" size="100" style=" padding: 0px!important" position="south" resizable="true" > 



           </p:layoutUnit> 
          </p:layout> 
         </p:layoutUnit> 
        </p:layout> 
       </p:layoutUnit> 
      </p:layout> 
      <p:dialog id="dlg" resizable="false" maximizable="true" modal="true" draggable="true" height="400" widgetVar="dlg1" style="background-color: white!important;text-align: center!important;direction: ltr"> 

       <p:outputPanel style="direction: rtl" id="dlgpanel" >     
        <center> 
         <ui:include src="#{adminC.url}" /> 
        </center> 
        </p:outputPanel> 

      </p:dialog> 

     </h:body> 
    </f:view> 
</html> 

,這是一個網頁,裏面的對話框打開:

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" 
      template="./../template/masterTemplate.xhtml" 
      xmlns:p="http://primefaces.org/ui" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:sec="http://www.springframework.org/security/tags"> 

<ui:define name="top"> 

</ui:define> 
<ui:define name="content"> 
    <h:form id="regChannel" prependId="false" style="text-align: right;float: none!important"> 
     ........ 

    </h:form>   
</ui:define> 
<ui:define name="bottom"> 

</ui:define> 

+0

也許你正在處理一個JavaScript錯誤。打開一個像螢火蟲一樣的瀏覽器開發工具,看看是否有問題。 –

+0

我檢查與鉻調試器,但沒有問題! – faranak

+0

相關:http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked/2120183#2120183 – BalusC

回答

5

擺脫所有的嵌套形式(<h:form),

我注意到你有很多人

你不能讓頁面上的以下結構

<h:form..... 
    some elements.... 
    some elements.... 
    some elements.... 
    <h:form.... 

例如,你可以將一個<h:form將包裝<p:tab

或地方<h:form每個<p:tab

內的另一種方法來檢查你沒有嵌套<h:form是在你的頁面上做查看源,看看<form裏面是否有<form(嵌套形式是baaaad)


更新

你確定你需要的所有對話框中那些<ui:define?嘗試刪除所有的<ui:define + template="./../template/masterTemplate.xhtml"從內ui:composition和剛剛離開的

<ui:composition.... 
    <h:form... 

    </h:form> 
</ui:composition> 
+0

我擺脫了所有的形式,並且在dialoge中打開的頁面只有一個,但沒有解決我的問題問題!!當只在頁面中使用一個包含佈局的h:表單時,初始化佈局組件發生錯誤並且不會呈現頁面!所以我已經爲每個layerunit添加了一個標籤! – faranak

+0

我沒有告訴你擺脫所有的形式,只留下一種形式...只是爲了擺脫嵌套形式...你可以發佈你的新代碼...但在此之前,只要確保你不' t有commandButtons的形式之外... – Daniel

+0

我意識到,我只是爲了測試,我沒有想到表單標籤的問題,好吧,我會發布我的新代碼 – faranak