2016-11-23 10 views
0

最初のcommandButtonを持つ人物を最初に探すと、データテーブル内の人物を選択して2番目のcommandButtonがあり、defaultCommandを切り替えたいと思いますbutton2私は人を選択した後、どのように私はこれを達成することができますか?Primeface DefaultCommandボタンはゾーンに応じて切り替わります

<h:form id="form" 
     rendered="#{security.asRole('ADMIN') or security.asRole('GESTIONNAIRE')}"> 
     <f:event type="preRenderView" listener="#{paieAgentView.init()}" /> 

     <p:fieldset legend="Recherche de l'agent"> 
      <p:panelGrid columns="2"> 
       <p:panelGrid columns="2" id="pgRechercheAgent"> 
        <h:outputLabel value="Matricule :" /> 
        <p:inputText id="matricule" 
         value="#{paieAgentView.agentSearched.matricule}"> 
         <p:ajax process="matricule" partialSubmit="true" event="keyup" /> 


        <h:commandButton id="boutonLigneAgent" 
         action="#{paieAgentView.searchLigneAgent()}" 
         value="Rechercher les agents" icon="ui-icon-search" 
         update="listAgents" immediate="true" > 
         <f:ajax render="@form" execute="@this" /> 
        </h:commandButton> 


        <br /> 
       </p:panelGrid> 

       <p:dataTable id="listAgents" var="agt" 
        value="#{paieAgentView.listLigneAgent}" 
        selection="#{paieAgentView.agentSelected}" 
        rowKey="#{agt.matricule}" style="margin-bottom:0" 
        selectionMode="single" scrollRows="20" scrollable="true" 
        liveScroll="true" scrollHeight="250"> 

        <p:ajax event="rowSelect" update=":form:pgRechercheContrats" /> 

        <p:column headerText="Matricule"> 
         <h:outputText value="#{agt.matricule}" /> 
        </p:column> 
        <p:column headerText="Nom"> 
         <h:outputText value="#{agt.nomPat} #{agt.prenom}" /> 
        </p:column> 

       </p:dataTable> 

      </p:panelGrid> 

      <p:defaultCommand target="boutonLigneAgent" /> 
     </p:fieldset> 
     <p:fieldset legend="Critères de recherche"> 
      <p:panelGrid columns="3" id="pgRechercheContrats"> 

       <h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5"> 
        <p:outputLabel for="typePeriode" value="Période de paie:" /> 
        <p:selectOneRadio id="typePeriode" 
         value="#{paieAgentView.typePeriode}"> 
         <f:selectItem itemLabel="Période de paie" itemValue="paie" /> 
         <f:selectItem itemLabel="Période d'origine" itemValue="origine" /> 
        </p:selectOneRadio> 
       </h:panelGrid> 


       <h:panelGrid columns="2" id="pgCalendar"> 
        <h:outputLabel value="Date Debut : " for="calendrierDateDebut" /> 
        <p:calendar id="calendrierDateDebut" 
         value="#{paieAgentView.dateDebut}" pattern="yyyy-MM-dd" 
         effect="slideDown" navigator="true" mode="inline" 
         locale="#{sessionControleur.langue}" style="moisAnSeul" /> 
        <h:outputLabel value="Date fin : " 
         for="calendrierDateFin" /> 
        <p:calendar id="calendrierDateFin" 
         value="#{paieAgentView.dateFin}" pattern="yyyy-MM-dd" 
         effect="slideDown" navigator="true" mode="inline" lang="fr" 
         locale="fr" style="moisAnSeul" /> 
       </h:panelGrid> 


       <p:selectManyCheckbox id="gridTypesPaie" 
        value="#{paieAgentView.selectedTypesPaie}" columns="1" 
        layout="pageDirection"> 
        <f:selectItems value="#{paieAgentView.typesPaie}" var="type" 
         itemLabel="#{type.label}" itemValue="#{type.value}" /> 
       </p:selectManyCheckbox> 

      </p:panelGrid> 
     </p:fieldset> 

     <p:commandButton process="pgRechercheContrats" 
      icon="ui-icon-file-pdf" value="Editer les fiches de paie" 
      action="#{paieAgentView.printPaieAgent()}" update="@form" 
      escape="false" ajax="false" 
      onclick="regenererCal();this.form.target='_blank'" /> 

    </h:form> 

答えて

0

2つのdefaultCommandsを両方ともレンダリング属性で作成します。レンダリングでは、人物が選択されているかどうかを確認し、呼び出されたアクションがそれに適合している必要があります。 ; のonclick =「this.form.target = 『_空白』 regenererCal()」:あなたは、フォーム全体を毎回何かの変更を更新しているので、これは

​​
+0

を動作するはず番目のボタンはonclickのための特定のイベントがありますだからこそ私はviewBeanの中でこれを行うことができません – coshikipix

関連する問題