I'm using JSF Mojarra 2.3.8 with Tomcat 8 (with additional libraries required for CDI and JPA). I have a ViewScoped bean:
@Named @ViewScoped
public class MyBean implements Serializable {
...
I have a page that uses this bean.
I open the page in 2 browser tabs, modify and post the page on tab 1. Then navigate away from the page on tab 1 (the action returns a different page).
Then, on tab 2, I try to modify and save the same record. There is no error, but I can see from the logs that MyBean is recreated and has lost the original data.
To save the data, I'm using:
<h:commandButton type="submit" value="Save" action="#{myBean.saveData}" />
I thought that ViewScoped beans could be used independently on multiple tabs. If that's true, why should one page affect the same bean associated with another page?
It seems that I have the same problem described here: Multiple browser tabs or windows with the same ViewScoped bean class but alas it has no answer.
Although this may share the same root cause as javax.faces.view.ViewScoped bean and multiple tabs issue I don't think it's a duplicate because I'm not using WildFly, so the answer for that question will be different to mine (i.e. WildFly was patched).