the problem is to cacth new values after i have previous values from the DB and overwrite them, i wanna save the new values in my beans "variables" and also show the values from de DB in this component, but if i put "Usuario.nombre", it doesnt show the values from the DB, and if i put "datos.nombres" it shows the values from the DB, please help
Here is my xhtml file
<p:dataTable style="width:450px" value="#{DAOUsuario.Listar()}" var="datos">
<p:column headerText="Datos Personales" style="background:#19708F ; color: white">
<p:outputLabel value="Nombre"/>
<h:inputText value="#{datos.nombre}"/>
<br/>
<p:outputLabel value="Clave" />
<h:inputText value="#{datos.clave}"/>
<br/>
<h:commandButton value="Modificar" action="#{DAOUsuario.Modificar()}">
</h:commandButton>
</p:column>
</p:dataTable>
</h:form>
</body>
Here is my Class which have methods to connect to the DB
public void Modificar() throws Exception {
FacesContext context = FacesContext.getCurrentInstance();
Usuario us = (Usuario) context.getApplication().evaluateExpressionGet(context, "#{Usuario}", Usuario.class);
String sql = "UPDATE usuario SET nombre = '" + us.getNombre() + "', clave = '" + us.getClave() + "' "
+ "WHERE codigousuario = 2";
try {
this.Insert(sql);
} catch (Exception ex) {
throw ex;
}
}
and here is my Bean Usuario:
public class Usuario {
private int codigo;
private String nombre;
private String clave;
public int getCodigo() {
return codigo;
}
public void setCodigo(int codigo) {
this.codigo = codigo;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getClave() {
return clave;
}
public void setClave(String clave) {
this.clave = clave;
}
}