p:commandButton and update
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Does the enclosing form has prependId="false"? If not you need to use update="formId:miComp", if prependId is true it should be update="miComp" then.
show this snippet
Code: Select all
<h:form prependId="false">
<p:dataTable id="pac" var="paciente"
value="#{pantallaPrincipalMbean.pacientes}" paginator="true"
rows="10" widgetVar="pacientes" selectionMode="single"
selection="#{pantallaPrincipalMbean.seleccion}">
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{paciente.nombre}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Apellidos" />
</f:facet>
<h:outputText value="#{paciente.apellidos}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Telefono" />
</f:facet>
<h:outputText value="#{paciente.telefono}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Nif" />
</f:facet>
<h:outputText value="#{paciente.nif}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Fecha Nacimiento" />
</f:facet>
<h:outputText value="#{paciente.fechaString}" />
</p:column>
</p:dataTable>
<h:commandLink value="nuevo" onclick="dlg.show()">
</h:form>
<p:dialog header="add Paciente" width="400px" widgetVar="dlg" fixedCenter="true" modal="true"
binding="#{pantallaPrincipalMbean.dialogoPaciente}" >
<h:form prependId="false">
<p:panel id="panelPaciente">
<h:inputHidden value="#{pantallaPrincipalMbean.paciente.id}" />
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="nombre" value="Nombre:" />
<h:inputText id="nombre" value="#{pantallaPrincipalMbean.paciente.nombre}" />
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="apellidos" value="Apellidos:" />
<h:inputText id="apellidos" value="#{pantallaPrincipalMbean.paciente.apellidos}" />
</h:panelGrid>
<h:panelGrid columns="3" style="margin-bottom:10px">
<h:outputLabel for="fechaNac" value="Fecha de Nacimiento:">
<p:calendar id="fechaNac" value="#{pantallaPrincipalMbean.paciente.fechaNacimiento}" />
</h:outputLabel>
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="nif" value="NIF:" />
<h:inputText id="nif" value="#{pantallaPrincipalMbean.paciente.nif}" />
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="telefono" value="Telefono:" />
<h:inputText id="telefono" value="#{pantallaPrincipalMbean.paciente.telefono}" />
</h:panelGrid>
</p:panel>
<h:commandButton value="aceptar" action="#{pantallaPrincipalMbean.addPaciente}" async="true" update="pac" />
</h:form>
</p:dialog>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
You are using h:commandButton instead of p:commandButton.
Sorry, i had a mistake when i copied, in the original code i was useing a h:commandButton because p:commandButton don't refresh my component.
this code don't work me:
this code don't work me:
Code: Select all
<h:form prependId="false">
<p:dataTable id="pac" var="paciente"
value="#{pantallaPrincipalMbean.pacientes}" paginator="true"
rows="10" widgetVar="pacientes" selectionMode="single"
selection="#{pantallaPrincipalMbean.seleccion}">
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{paciente.nombre}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Apellidos" />
</f:facet>
<h:outputText value="#{paciente.apellidos}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Telefono" />
</f:facet>
<h:outputText value="#{paciente.telefono}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Nif" />
</f:facet>
<h:outputText value="#{paciente.nif}" />
</p:column>
<p:column sortable="true">
<f:facet name="header">
<h:outputText value="Fecha Nacimiento" />
</f:facet>
<h:outputText value="#{paciente.fechaString}" />
</p:column>
</p:dataTable>
<h:commandLink value="nuevo" onclick="dlg.show()">
</h:form>
<p:dialog header="add Paciente" width="400px" widgetVar="dlg" fixedCenter="true" modal="true"
binding="#{pantallaPrincipalMbean.dialogoPaciente}" >
<h:form prependId="false">
<p:panel id="panelPaciente">
<h:inputHidden value="#{pantallaPrincipalMbean.paciente.id}" />
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="nombre" value="Nombre:" />
<h:inputText id="nombre" value="#{pantallaPrincipalMbean.paciente.nombre}" />
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="apellidos" value="Apellidos:" />
<h:inputText id="apellidos" value="#{pantallaPrincipalMbean.paciente.apellidos}" />
</h:panelGrid>
<h:panelGrid columns="3" style="margin-bottom:10px">
<h:outputLabel for="fechaNac" value="Fecha de Nacimiento:">
<p:calendar id="fechaNac" value="#{pantallaPrincipalMbean.paciente.fechaNacimiento}" />
</h:outputLabel>
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="nif" value="NIF:" />
<h:inputText id="nif" value="#{pantallaPrincipalMbean.paciente.nif}" />
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="telefono" value="Telefono:" />
<h:inputText id="telefono" value="#{pantallaPrincipalMbean.paciente.telefono}" />
</h:panelGrid>
</p:panel>
<p:commandButton value="aceptar" action="#{pantallaPrincipalMbean.addPaciente}" async="true" update="pac" />
</h:form>
</p:dialog>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
What's the response you're getting from ajax response? Can you check with firebug? That'll help us.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 29 guests