0

DB(postgre)からデータを取得し、

このページは最初にリスト内のデータをリストし、次にダイアログでクリックされた要素からデータを運ぶコマンドリンク「modificar」がありますが、このダイアログのコマンドボタンがメソッド「DAOEventos.modificarEvento」を呼び出さない理由がわかりません...最後に、ダイアログからデータベースにデータを登録するボタンがありますが、これで問題ありません

私が持っている唯一の問題は、ダイアログがコマンドリンクから来ていることです!

私はデバッグを行い、問題は「p:calendar」にあります。それをキックすると、メソッドが呼び出されましたが、カレンダーからその値が必要です!

<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>

4

2 に答える 2

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>  

于 2013-03-13T17:06:41.693 に答える
1

HTML では有効な概念ではありませんHTML formHTML formJSF でこれを行っても、最終的なレンダリング コンポーネントは HTML のみになります。したがって、 <h:form id="form">コードから削除するか、上記のすべてのコードを単一のフォーム内に保持するようにしてください。

ここをチェックしてください: JSFページで <h:form> を使用する方法は?シングルフォーム?複数形?ネストされたフォーム?

于 2013-03-13T16:48:12.300 に答える