Problem with dataTable and dialog

Components, Ajax Framework, Utilities and More.
Post Reply
Posts: 10
Joined: 21 Dec 2010, 08:02

05 Jan 2011, 06:13

Hi..!! I've a dataTable and one column is used for edit row data...that column has a commandButton that show a dialog when it's clicked.
The problem's that the dialog appear, but it doesn't show data, only inputText empty.
I have been reading the oldest post that the users have been writting here, but the solutions it doesn´t work for me.

This is the code of the table

Code: Select all

            <p:dataTable id="clientesTable" paginator="true" value="#{ClienteBean.clienteList}" var="row"
                         rows="10" paginatorPosition="bottom"
                         paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                         emptyMessage="No hay datos cargados..">

                     <f:facet name="header">
                         <h:outputText value="Nombre"/>
                     <h:outputText value="#{row.nombre} #{row.apellido}"/>
                     <f:facet name="header">
                         <h:outputText value="Eliminar"/>
                     <p:commandButton styleClass="button_table_size" image="button_delete_icon" onclick="">
                         <f:setPropertyActionListener value="#{row}" target="#{ClienteBean.selectedCliente}"/>
                     <f:facet name="header">
                         <h:outputText value="Editar"/>
                     <p:commandButton update="datosAEditar" image="button_edit_icon" styleClass="button_table_size"
                         <f:setPropertyActionListener value="#{row}" target="#{ClienteBean.selectedCliente}"/>
This is the code of the dialog

Code: Select all

            <p:dialog header="Editar Usuario" widgetVar="editDialog" closable="true"
                      showEffect="slide" hideEffect="fold" modal="true">

                <p:outputPanel id="datosAEditar" rendered="#{not empty ClienteBean.selectedCliente}">
                    <h:panelGrid columns="2" >
                        <h:outputText value="Nombre:"/><h:inputText value="#{ClienteBean.selectedCliente.nombre}"/>
                        <h:outputText value="Apellido:"/><h:inputText value="#{ClienteBean.selectedCliente.apellido}"/>
                        <h:outputText value="Dni:"/><h:inputText value="#{ClienteBean.selectedCliente.dni}"/>
                        <h:outputText value="Telefono:"/><h:inputText value="#{ClienteBean.selectedCliente.telefono}"/>
                        <h:outputText value="Mail:"/><h:outputText value="#{ClienteBean.selectedCliente.mail}"/>
                        <h:selectBooleanCheckbox value="#{ClienteBean.selectedCliente.estudiante}"/><h:outputText value="Estudiante?"/>

                        <p:commandButton styleClass="button" value="Aceptar" actionListener="#{ClienteBean.editCliente}"
                                         update="clientesTable, messages" oncomplete="editDialog.hide()"/>
                        <p:commandButton styleClass="button" value="Cancelar" onclick="editDialog.hide()"/>

I have treated that the commandButton update the panelGrid directly without the outputpanel, but doesn't work...the output panel was a recomendation of OptimusPrime to an user, but doesn's work for me =(

This is my bean..

Code: Select all

public class ClienteBean implements Serializable{

    private Cliente cliente= new Cliente();
    private Cliente selectedCliente= new Cliente();
    private String infoAction="";

    public ClienteBean(){}

    //Getters y Setters
    public Cliente getCliente() {
        return cliente;

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;

    public Cliente getSelectedCliente() {
        return selectedCliente;

    public void setSelectedCliente(Cliente selectedCliente) {
        this.selectedCliente = selectedCliente;

    public String getInfoAction() {
        return infoAction;

    public void setInfoAction(String infoAction) {
        this.infoAction = infoAction;

    public List<Cliente> getClienteList(){
        List<Cliente> clientes=new ArrayList<Cliente>();
        clientes= GenericDAO.getList(Cliente.class);
        return clientes;

    //Mtodos propios
    public void saveCliente(){
        FacesContext currentContext= FacesContext.getCurrentInstance();

        if (!DataValidator.isEmail(cliente.getMail().trim()))
        {   // Si no es un email valido
            setInfoAction("Por favor ingrese un E-Mail válido.");
            currentContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error", infoAction));
        {   // Intentamos guardar el cliente
            Transaction t = GenericDAO.createTransaction();

            //Limpio los datos del cliente para ingresar otro
            // Si salio todo bien
            setInfoAction("Cliente cargado exitosamente.");
            currentContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"Exito", infoAction));
        catch (org.hibernate.exception.ConstraintViolationException e)
        {   // DNI 0 CUIT repetido
            setInfoAction("DNI/CUIT repetido.");
            currentContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"Error", infoAction));
        catch (Exception e)
        {   // Otro error
            setInfoAction("Error al tratar de conectarse con el servidor.   \n" +
                     "Por favor, verifique si el servidor esta encendido   \n" +
                     "o si existen problemas con la red.");
            currentContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL,"Error", infoAction));

    public void clean(){
        cliente=new Cliente();

    public void deleteSelectedCliente(ActionEvent evt){        
        Transaction t= GenericDAO.createTransaction();

        FacesContext context= FacesContext.getCurrentInstance();
        infoAction="El cliente se borro satisfactoriamente.";
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Exito: ", infoAction));

    public void editCliente(ActionEvent evt){
        Transaction t= GenericDAO.createTransaction();

        FacesContext context= FacesContext.getCurrentInstance();
        infoAction="El cliente se edito satisfactoriamente.";
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Exito: ", infoAction));
Delete a row works fine with the confirmDialog...

User avatar
Posts: 316
Joined: 08 Feb 2010, 20:33
Location: Brazil

05 Jan 2011, 12:42

take a look here: ... 261#p27261

its the way ive been using dialogs and i have no bugs.

i hope it helps.


Rafael Mauricio Pestano

Primefaces 5.x + JavaEE7(Glassfish 4.x and Wildfly 8)
Conventions Framework

Posts: 93
Joined: 14 Jul 2010, 22:30

06 Jan 2011, 02:59

maybe you should try to update a component which is alredy rendered, because if the element isn't rendered is not going to be updated.
I would try to put rendered expression in the panelgrid and let outputpanel always rendered, in order to commandbutton update takes effect!

Posts: 53
Joined: 07 Dec 2010, 21:30

06 Jan 2011, 21:42

you can either add this to your datatable definition

Code: Select all

onRowSelectComplete="" onRowSelectUpdate="datosEditar"
This will negate the need for pressing a button. Check out the Instant Selection Mode under DataTable in the showcase.

If you still need the commandButton to show the dialog, then you will need to add this to your commandButton in the datatable

Code: Select all

<p:commandButton styleClass="button_table_size" image="button_delete_icon" onclick="" update="datosEditar">
      <f:setPropertyActionListener value="#{row}" target="#{ClienteBean.selectedCliente}"/>
PF-2.2.1 || Mojarra 2.0.3-FCS || Eclipse 3.6.1 (Helios) || Weblogic 11gR1

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider], Bing [Bot] and 6 guests