I have a .xhtml page from which I launch a javascript, inside this javascript I would like to update the content of a bean, the easiest way I have found to do this is by adding a hidden form and linking said bean's property to its value:
index.xhtml
<h:form id="poi-form" styleClass="invisible">
<h:inputHidden id="poi" value="#{userBean.email}" />
</h:form>
javascriptfile.js
function handleEmailResponse(resp) {
document.getElementById('poi-form:poi').value = 'usersNewEmailValue';
window.location.replace("timeline.xhtml");
}
However, from the timeline.xhtml the value isn't the one I expected (as if it isn't updated) since I see the users old email value set in
userBean.java
@PostConstruct
public void init() {
email = "usersOldEmailValue;
}
Am I forgetting something? Thanks in advance for your help!