2014-02-20 40 views
0

我有一個名爲添加面板的添加面板的按鈕需要顯示,並且面板內有一個取消按鈕onclick取消面板應該關閉我的問題是點擊添加按鈕面板來一會兒消失。實際上,我已經incuded template_2.xhtml其中..如果我從template_2.xhtml面板工作正常,但這些警告即將到來這樣的形式組件需要有一個UIForm在其祖先。建議:附上必要的組件中的兩個我都想要的東西,做工精細,並警告不應該來。這裏是我的代碼i know the problem that i am using 2 times form in 1 xhtml page but not able to overcome that help me out `點擊jsf/primefaces中的按鈕啓用/禁用面板?

 <h:commandButton value="Add" id="show" action="#" onclick="panelwv.show()" ></h:commandButton> 
    <h:form> 

     <p:panel id="panel" widgetVar="panelwv" visible="false" header="Add Dependents"> 
      <h:panelGrid id="myPanel" columns="3" cellpadding="5" styleClass="text-input"> 


      <h:outputText value=""/> 

       <h:outputLabel value="Name" style="font-family: cursive;font-size: 18px;font-weight:normal;"/> 
       <h:inputText id="name" value="#{depco.depapp.dep.name}" styleClass="border" label="First Name" /> 
       <h:outputText value=""/> 

       <h:outputLabel value="Relationship" style="font-family: cursive;font-size: 18px;font-weight:normal;"/> 
       <h:inputText id="rel" value="#{depco.depapp.dep.relationship}" styleClass="border" label="Relationship" /> 
       <h:outputText value=""/> 



       <h:outputLabel value="Date of Birth" style="font-family: cursive;font-size: 18px;font-weight:normal;"/> 
       <p:calendar id="dob" value="#{depco.depapp.dep.dob}" showOn="button" label="Date of Birth" /> 
       <h:outputText value=""/> 


      <h:outputLabel value="Emp Id" /> 
      <h:selectOneMenu value="#{depco.depapp.dep.empId}" > &nbsp; 
       <f:selectItems value="#{coemp.empapp.itemsAvailableSelectOne}" var="emp" itemLabel="#{emp.empId}" itemValue="#{emp.empId}" /> 
       <f:converter converterId="employeeConverter" /> 
      </h:selectOneMenu> 
       <h:outputText value=""/> 


       <h:commandButton value="Save" action="#{depco.createDepAction()}"/> 
       <h:commandButton action="#" id="hide" onclick="panelwv.hide()" value="cancel"/> 


      </h:panelGrid> 
       </p:panel> 
    </h:form> 
    ` 

回答

0

JSF菜單和子菜單標籤應包括表單標籤內。所以我只是法師一個單獨的JSF文件與一些名(比如xyz.xhtml),我只是使用包括

0

你的榜樣是我工作的罰款,[使用Primefaces 3.5 JSF 2.1.13 ]。
這可能是您使用的按鈕的問題。

通常h:commandButton將不會執行Ajax提交,它會提交表單,直到您明確指定f:ajax,這可能是面板到來和消失的原因。

使用p:commandButton它默認提交ajax,或者使用f:ajaxh:commandButton

由於您沒有從h:commandButton中調用任何ManagedBean的屬性或方法,因此您甚至可以使用h:button

+0

在實際JSF頁面的xyz.xhtml:我已經包括jsf頁面調用template_2.xhtml,如果我包括 ... ....這個錯誤來了,面板越來越顯示。我嘗試使用p:commandButton同樣的問題出現,你能幫助我與例 – user3227175