This is my first post. This site and all the people involved are wonderful. Thanks to all. My problem: I have a datatable with a dialog who shows information on the selected register. That works fine. But if I try to use the dialog for modifying information, the field does not show the information. Eclipse Juno 2EE, Primefaces 3.5 with jsf2 and Tomcat 7.0.39. Java 7.0.07 64 bits.
Page admin.xhtml ....
<h:form id="adminform" preempId="false">
....
<div id="datos">
<p:panel id="panelData" style="height: 100%; width: 100%; margin-left: auto; margin-right: 0; border: none; background: transparent;">
<ui:include src= "#{adminBean.pageSelected}" />
</p:panel>
</div>
</div>
</h:form>
Page adminusers.xhtml loaded by the ui:include
<p:panel id="usuarios" header="USUARIOS" style="background: transparent; border: 1; width: 850px;">
<p:commandButton value="Nuevo usuario" type="button" onclick="newuser.show()" immediate="true"/>
<br /><br />
<p:dataTable id="usertable" var="data" value="#{DTableCustomerBean.datos}" emptyMessage="Sin datos."
resizableColumns="true" style="text-align: center; align: center; border-radius: 1.6em;"
selection="#{DTableCustomerBean.selectedCustomer}" selectionMode="single" rowKey="#{data.id}" >
<p:columns value="#{DTableCustomerBean.columns}" var="column" columnIndexVar="colIndex"
width="#{column.width}">
<f:facet name="header">#{column.header}</f:facet>
<h:outputText value="#{data[column.property]}" />
</p:columns>
<p:column style="width: 80px;">
<p:commandLink update=":adminform:showuserform" oncomplete="showuser.show()" immediate="true"
title="Ver" style="margin-right: 10px;">
<img src="images/info.png" style="width: 20px; height: 20px; border: 0px;"/>
<f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
</p:commandLink>
<p:commandLink update=":adminform:edituserform" oncomplete="edituser.show()" immediate="true"
title="Modificar" style="margin-right: 10px;">
<img src="images/modificar.png" style="width: 20px; height: 20px; border: 0px;"/>
<f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
</p:commandLink>
<p:commandLink update=":adminform:showuserform" oncomplete="showuser.show()" immediate="true"
title="Borrar" style="margin-right: 10px;">
<img src="images/delete.png" style="width: 20px; height: 20px; border: 0px;"/>
<f:setPropertyActionListener value="#{data}" target="#{DTableCustomerBean.selectedCustomer}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="edituserdlg" header="Modificar datos" widgetVar="edituser" resizable="FALSE" modal="TRUE">
<h:messages errorClass="errorMessage" infoClass="infoMessage" warnClass="warnMessage" />
<h:panelGrid id="edituserform" columns="2" cellpadding="4" cellspacing="4"
style="font-size:16px; align: center; margin: 0 auto;" >
<h:outputText value="Identificador:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.id}" style="font-weight: bold;" />
<h:outputText value="Nombre:" />
<p:inputText id="edtnombre" value="#{DTableCustomerBean.selectedCustomer.nombre}" size="20" maxlength="20"
style="font-weight: bold;" />
<h:outputText value="Apellido:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.apellido}" style="font-weight: bold;" />
<h:outputText value="Empresa:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.empresa}" style="font-weight: bold;" />
<h:outputText value="Dirección:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.direccion}" style="font-weight: bold;" />
<h:outputText value="Rut:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.rut}" style="font-weight: bold;" />
<h:outputText value="Teléfonos:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.telefonos}" style="font-weight: bold;" />
<h:outputText value="Usuario:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.usuario}" style="font-weight: bold;" />
<h:outputText value="Permisos:" />
<h:outputText value="#{DTableCustomerBean.selectedCustomer.tipoUsuario}" style="font-weight: bold;" />
</h:panelGrid>
<p:panel style="margin-left: 30px; display: block; margin: 0 auto; text-align: center; background: transparent; border: 0;">
<p:commandButton value="Modificar" type="submit" oncomplete="edituser.hide()" update="usuario" />
<p:commandButton value="Cancelar" type="button" onclick="edituser.hide()" style="margin-left: 30px;"/>
</p:panel>
....
Back bean
@ManagedBean(name="DTableCustomerBean")
// @RequestScoped
// @SessionScoped
@ViewScoped
public class DTableCustomerBean implements Serializable {
private static final long serialVersionUID = 1L;
private List<ColumnModel> columns;
private List<Customer> datos;
private String columnName;
private Customer selectedCustomer;
public DTableCustomerBean() {
System.out.println("Inicia DTableCustomerBean");
createColumns();
addData();
}
// Getters and Setters
public List<ColumnModel> getColumns() {
return columns;
}
public void setColumns(List<ColumnModel> columns) {
this.columns = columns;
}
public List<Customer> getDatos() {
return datos;
}
public void setDatos(List<Customer> datos) {
this.datos = datos;
}
public String getColumnName() {
return columnName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public Customer getSelectedCustomer() {
return selectedCustomer;
}
public void setSelectedCustomer(Customer selectedCustomer) {
this.selectedCustomer = selectedCustomer;
}
// Fin Getters and Setters
private void createColumns() {
System.out.println("DTableCustomerBean createColumns");
columns = new ArrayList<ColumnModel>();
columns.add(new ColumnModel("Nombre", "nombre", 100));
columns.add(new ColumnModel("Apellido", "apellido", 100));
columns.add(new ColumnModel("Empresa", "empresa", 150));
columns.add(new ColumnModel("Teléfonos", "telefonos", 150));
columns.add(new ColumnModel("Usuario", "usuario", 50));
}
static public class ColumnModel implements Serializable {
private static final long serialVersionUID = 1L;
private String header;
private String property;
private int width;
public ColumnModel(String header, String property, int width) {
this.header = header;
this.property = property;
this.width = width;
}
public String getHeader() {
return header;
}
public String getProperty() {
return property;
}
public int getWidth() {
return width;
}
}
private void addData() {
UserDAO userdao;
System.out.println("DTableCustomerBean addData");
userdao = new UserDAO();
datos = new ArrayList<Customer>();
datos = userdao.getAllCustomers();
}
}
The data in the outputText fields appears correctly. The field inputText id="edtnombre" appears empty instead with the name. Of course if I change the inputText for an outputText it works ok.
I have googgled for a solution and found nothing. I have tried differents ideas but it didn't worked.
Anyone can help? Thanks!