2013-03-13 66 views
0

從DB(postgre)挑數據,我的commandbutton不工作,JSF + primefaces?

此頁第一個列表在列表 的數據,那麼我有一個commandlink「modificar」至極承載數據從元素在對話框 點擊,但我不知道爲什麼在這個對話框中的命令按鈕沒有調用方法「DAOEventos.modificarEvento」.... 在最後我有一個按鈕,從對話框註冊數據到數據庫,這是行不通的

我唯一的問題是對話框來自commandlink!

我做了一個調試,問題是與「p:日曆」如果我踢,該方法被調用,但我需要從日曆中的值!

<h:body> 
    <h:form id="form">    
     <p:dataTable style="width:100%" value="#{DAOEventos.listaEventos()}" var="even" > 

      <f:facet name="header">Listado de Eventos</f:facet> 
      <p:column filterBy="#{even.descripcion}" filterMatchMode="contains"> 
       <f:facet name="header"> 
        <h:outputLabel value="Evento"/> 
       </f:facet> 
       <h:outputText value="#{even.descripcion}"></h:outputText> 

      </p:column> 
      <p:column filterBy="#{even.fec}" filterMatchMode="contains"> 
       <f:facet name="header"> 

        <h:outputLabel value="Fecha"/> 
       </f:facet> 
       <h:outputText value="#{even.fec}"></h:outputText> 

      </p:column> 
      <p:column> 
       <f:facet name="header"> 
        <h:outputLabel value="Modificar"/> 
       </f:facet> 
       <p:commandLink value="Modificar" oncomplete="dlg2.show();" 
           update="modalDialog2" action="#{beanEventos.traerDatos()}" style="color: black"> 
        <f:setPropertyActionListener target="#{beanEventos.codEvento}" value="#{even.codEvento}" /> 
        <f:setPropertyActionListener target="#{beanEventos.codSec}" value="#{even.codSec}" /> 
       </p:commandLink> 

       <p:dialog id="modalDialog2" header="Modificar Eventos" widgetVar="dlg2" dynamic="true" resizable="false"> 
        <h:form> 
         <table> 
          <tr> 
           <td> 
            <h:outputLabel value="Nombre Evento"/> 
            <h:inputText id="nombre" value="#{beanEventos.nombre}"/> 
           </td> 
          </tr> 
          <tr> 
           <td> 
            <h:outputLabel value="Descripcion Evento"/> 
            <h:inputText id="desc" value="#{beanEventos.descripcion}"/> 
           </td> 
          </tr> 
          <tr> 
           <td> 
            <h:outputLabel value="Fecha Evento"/> 
            <p:calendar value="#{beanEventos.fec}" 
               showButtonPanel="true"/>      
           </td> 
          </tr> 
          <tr> 
           <td> 
            <h:selectBooleanCheckbox value="#{beanEventos.vigencia}"/> 
            <h:outputText value="Vigencia" style="font-weight:bold"/> 
           </td> 
          </tr> 
          <tr> 
           <td> 
            <h:commandButton value="Modificar" action="#{DAOEventos.modificarEvento()}" /> 
           </td> 
          </tr> 
         </table> 
        </h:form> 
       </p:dialog> 
      </p:column> 
     </p:dataTable> 

     <p/> 
     <p:commandButton id="showDialogButton" value="Agregar" oncomplete="dlg.show()" /> 

     <p:dialog header="Enter FirstName" widgetVar="dlg" resizable="false" id="dialogo" > 
      <h:form> 

       <table> 
        <tr> 
         <td> 
          <h:outputLabel value="Nombre Evento "/> 
          <h:inputText id="nombre" value="#{beanEventos.nombre}"/> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          <h:outputLabel value="Descripcion Evento "/> 
          <h:inputText id="desc" value="#{beanEventos.descripcion}"/> 
         </td> 
        </tr> 

        <tr> 
         <td> 
          <h:outputLabel value="Fecha de Evento"/> 
          <p:calendar value="#{beanEventos.fec}" id="cal" showButtonPanel="true"/> 
         </td> 
        </tr> 

        <tr> 
         <td> 
          <h:commandButton value="Registrar Evento" 
              action="#{DAOEventos.insertarEvento()}"/> 
         </td> 
        </tr> 
       </table> 
      </h:form> 
     </p:dialog> 

    </h:form> 
</h:body> 

+3

http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked/2120183#2120183 – BalusC 2013-03-13 18:17:33

回答

1

正如SrinivasR所說,你不應該(儘管這可能工作正常)嵌套形式。 但我覺得這裏的問題是,你要定義你的地方:

<p:dialog id="modalDialog2">...</p:dialog> 

你應該把它的數據表外。

<h:body> 
<h:form id="form">    
    <p:dataTable style="width:100%" value="#{DAOEventos.listaEventos()}" var="even" > 

     <f:facet name="header">Listado de Eventos</f:facet> 
     <p:column filterBy="#{even.descripcion}" filterMatchMode="contains"> 
      <f:facet name="header"> 
       <h:outputLabel value="Evento"/> 
      </f:facet> 
      <h:outputText value="#{even.descripcion}"></h:outputText> 

     </p:column> 
     <p:column filterBy="#{even.fec}" filterMatchMode="contains"> 
      <f:facet name="header"> 

       <h:outputLabel value="Fecha"/> 
      </f:facet> 
      <h:outputText value="#{even.fec}"></h:outputText> 

     </p:column> 
     <p:column> 
      <f:facet name="header"> 
       <h:outputLabel value="Modificar"/> 
      </f:facet> 
      <p:commandLink value="Modificar" oncomplete="dlg2.show();" 
          update=":padding" actionListener="#{beanEventos.traerDatos()}" style="color: black"> 
       <f:setPropertyActionListener target="#{beanEventos.codEvento}" value="#{even.codEvento}" /> 
       <f:setPropertyActionListener target="#{beanEventos.codSec}" value="#{even.codSec}" /> 
      </p:commandLink> 


     </p:column> 
    </p:dataTable> 
</h:form> 
    <p/> 
    <h:panelGroup id="padding" layout="block"> 
     <p:dialog id="modalDialog2" header="Modificar Eventos" widgetVar="dlg2" dynamic="true" resizable="false"> 
      <h:form id="form2">  
       <table> 
        <tr> 
         <td> 
          <h:outputLabel value="Nombre Evento"/> 
          <h:inputText id="nombre" value="#{beanEventos.nombre}"/> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          <h:outputLabel value="Descripcion Evento"/> 
          <h:inputText id="desc" value="#{beanEventos.descripcion}"/> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          <h:outputLabel value="Fecha Evento"/> 
          <p:calendar value="#{beanEventos.fec}" 
             showButtonPanel="true"/>      
         </td> 
        </tr> 
        <tr> 
         <td> 
          <h:selectBooleanCheckbox value="#{beanEventos.vigencia}"/> 
          <h:outputText value="Vigencia" style="font-weight:bold"/> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          <h:commandButton value="Modificar" action="#{DAOEventos.modificarEvento()}" /> 
         </td> 
        </tr> 
       </table> 
      </h:form> 
     </p:dialog> 
    </h:panelGroup> 

    <h:form id="form3">  
    <p:commandButton id="showDialogButton" value="Agregar" oncomplete="dlg.show()" /> 

    <p:dialog header="Enter FirstName" widgetVar="dlg" resizable="false" id="dialogo" > 


      <table> 
       <tr> 
        <td> 
         <h:outputLabel value="Nombre Evento "/> 
         <h:inputText id="nombre" value="#{beanEventos.nombre}"/> 
        </td> 
       </tr> 
       <tr> 
        <td> 
         <h:outputLabel value="Descripcion Evento "/> 
         <h:inputText id="desc" value="#{beanEventos.descripcion}"/> 
        </td> 
       </tr> 

       <tr> 
        <td> 
         <h:outputLabel value="Fecha de Evento"/> 
         <p:calendar value="#{beanEventos.fec}" id="cal" showButtonPanel="true"/> 
        </td> 
       </tr> 

       <tr> 
        <td> 
         <h:commandButton value="Registrar Evento" 
             action="#{DAOEventos.insertarEvento()}"/> 
        </td> 
       </tr> 
      </table> 

    </p:dialog> 

</h:form> 

+0

實際上我separete在3條形成用於所述第一部分,則第二個對話框和第三個對話框,但是第一個對話框的更新值有問題modaldialog2 – MitoCode 2013-03-13 19:09:27

+0

您能否給出更多解釋?你把對話框放在數據表外嗎?你遇到了什麼樣的「更新問題......」? – 2013-03-13 19:25:23

+0

好吧,我把對話框外,但你可以把我的確切代碼請 – MitoCode 2013-03-13 19:27:37