0

which pick data from DB (postgre),

this page first list the data in a list then i have a commandlink "modificar" wich carry the data from the element clicked in a dialog but i dont know why the commandbutton in this dialog doesnt invoke the method "DAOEventos.modificarEvento" .... at the end i have a button that register data to the db from a dialog, this is OK works

the only problem i have is with the dialog comes from commandlink!

i made a debug and the problem is with "p:calendar" if i kick that, the method was invoked, but i need that value from the 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>

1

2 Answers 2

1

You are nesting one HTML form inside another HTML form which is not a valid concept in HTML. Even if you doing this in JSF ultimate rendering component will be HTML only.So, remove <h:form id="form"> from your code or try to keep all the above code inside single form.

Check here : How to use <h:form> in JSF page? Single form? Multiple forms? Nested forms?

1

As SrinivasR said, you shouldn't (although this may work fine) nest forms. But I think the issue here is with the place where you are defining your:

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

You should put it outside the datatable.

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

12
  • actually i separete in 3 forms for the first part then the second dialog and the third dialog, but i have problems with the update value from the first dialog modaldialog2
    – MitoCode
    Commented Mar 13, 2013 at 19:09
  • Can you give some more explanations ? Did you put the dialog outside datatable ? what kind of "problems with the update..." did you encounter ? Commented Mar 13, 2013 at 19:25
  • well, i put the dialog outside, but can you put me the exactly code please
    – MitoCode
    Commented Mar 13, 2013 at 19:27
  • Ok, it's very simple to try my solution, please see my answer updated Commented Mar 13, 2013 at 19:33
  • i do that, but now the problem is the first dataTable the list value doesnt work, and i if i kick the "upadte" from the commandLink", the value list work the method doesnt invoke
    – MitoCode
    Commented Mar 13, 2013 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.