Once again I have a problem which I can't find the solution to.
A managed bean
@Named(value="changeInfoBean")
@RequestScoped
public class ChangeInfoBean {
private String email;
private String firstName;
private String lastName;
/** Creates a new instance of ChangeInfoBean */
public ChangeInfoBean() {
FacesContext context = FacesContext.getCurrentInstance();
// Gets the user which is currently logged in
LoginBean bean = (LoginBean) context.getExternalContext().getSessionMap().get("loginBean");
BasicUser user = bean.getUser();
this.email = user.getEmail();
this.firstName = user.getFirstName();
this.lastName = user.getLastName();
}
public String changeName() {
Session session = HibernateUtil.getSessionFactory().openSession();
try {
Transaction tx = session.beginTransaction();
BasicUser updateUser = (BasicUser) session.load(BasicUser.class, this.email);
updateUser.setFirstName(firstName);
updateUser.setLastName(lastName);
tx.commit();
}
catch(Exception e) {
e.printStackTrace();
}
finally {
session.close();
return "succes";
}
}
The return "succes" is just to return something. Part of a page that uses the bean
<h:panelGroup rendered="#{param.change == 'name'}">
<h:form id="changeNameForm">
<h:messages/>
<h:panelGrid id="panel1" columns="2">
First Name:
<h:inputText id="firstName" value="#{changeInfoBean.firstName}"/>
Last Name:
<h:inputText id="lastName" value="#{changeInfoBean.lastName}"/>
<f:facet name="footer">
<h:panelGroup style="display:block; text-align:center">
<h:commandButton value="Submit Name" action="#{changeInfoBean.changeName}"/>
</h:panelGroup>
</f:facet>
</h:panelGrid>
</h:form>
</h:panelGroup>
I have checked that all it runs trough every lifecycle phase, tried to make the bean session scoped and tried to set immediate="true". I have tried to delete the inputText fields and only have the commandButton left. In every case the method changeName() is not called. What can be done?