p:commandButton and update

UI Components for JSF
Post Reply
larasith
Posts: 15
Joined: 12 Nov 2009, 20:43

19 Nov 2009, 20:22

I never get it to work the update="miComp" attribute of p:commandButton. Anyone know that i do?

User avatar
ydarcin
Posts: 258
Joined: 04 Jan 2009, 19:02
Location: Turkey

19 Nov 2009, 22:01

Hi,

please post your code for us to help you.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

20 Nov 2009, 00:15

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.

larasith
Posts: 15
Joined: 12 Nov 2009, 20:43

02 Dec 2009, 19:20

yes, i do it

larasith
Posts: 15
Joined: 12 Nov 2009, 20:43

02 Dec 2009, 19:35

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>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

05 Dec 2009, 15:56

You are using h:commandButton instead of p:commandButton.

larasith
Posts: 15
Joined: 12 Nov 2009, 20:43

07 Dec 2009, 15:17

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:

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>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Dec 2009, 15:06

What's the response you're getting from ajax response? Can you check with firebug? That'll help us.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests