jpa - unable to update entity -
this method
public string changepassword(int id){ facescontext context = facescontext.getcurrentinstance(); try{ utx.begin(); wuser wuser= em.find(wuser.class, id); wuser.setpassword(passwordv); utx.commit(); return "login"; }catch (exception e) { facesmessage message = new facesmessage(facesmessage.severity_error, "error changing password! ", "unexpected error when changing password account. please contact system administrator"); context.addmessage(null, message); logger.getanonymouslogger().log(level.severe, "unable change password ", e); return null; } }
this jsf
page
<f:view> <h:form id="change"> <h:panelgrid columns="3" border="0"> username: <h:inputtext id="username" requiredmessage="*" value="#{usermanager.username}" required="true"/> <h:message for="change:username" style="color: red"/> old password: <h:inputsecret id="password" requiredmessage="*" value="#{usermanager.password}" required="true"/> <h:message for="change:password" style="color: red"/> new password (verify): <h:inputsecret id="passwordv" requiredmessage="*" value="#{usermanager.passwordv}" required="true"/> <h:message for="change:passwordv" style="color: red"/> id: <h:inputtext id="id" requiredmessage="*" value="#{usermanager.id}" required="true"/> <h:message for="change:id" style="color: red"/> </h:panelgrid> <h:commandbutton id="submit" value="create" action="#{usermanager.changepassword(id)}"/> <h:messages style="color: red" globalonly="true"/> </h:form>
hej radoslaf,
change h:commitbutton code this:
<h:commandbutton id="submit" value="create" action="#{usermanager.changepassword(usermanager.id)}"/>
the property "id" known in connection usermanager which, think, provides currentuser object want edit.
greets patrick
Comments
Post a Comment