Varias pestañas o ventanas del navegador con la misma clase de bean ViewScoped

Uso de Payara Server 4.1.2.174 con mojarra 2.2.15.

Tengo un Bean con nombre simple con alcance javax.faces.view.ViewScoped.

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;


@Named
@ViewScoped
public class SimpleBean implements Serializable
{
    private final Logger logger = Logger.getLogger(SimpleBean.class.getName());

    @PostConstruct
    private void init()
    {
        logger.log(Level.SEVERE, "{0}.init()", this);
    }

    private String name;

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String action()
    {
        logger.log(Level.SEVERE, "{0}.action()", this);
        logger.log(Level.SEVERE,"====================");
        logger.log(Level.SEVERE, "name: {0}", getName());
        logger.log(Level.SEVERE,"====================");
        return "submit";
    }
}

Entonces tengo una página simple index.xhtml con formulario.

<h:form>
  <h:inputText value="#{simpleBean.name}"></h:inputText>
  <h:link value="To submit" outcome="submit"/>
  <h:commandButton value="Welcome Me" action="#{simpleBean.action()}"/>
</h:form>

Puedo abrir index.xhtml en dos pestañas o ventanas diferentes del navegador. Entonces, tengo el siguiente registro:

Severe: [email protected]()
Finest: Handling PostConstructViewMapEvent
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {simpleBean=solvo.ee.beans.SimpleBean@2adafd68}
Severe: [email protected]()
Finest: Handling PostConstructViewMapEvent
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {simpleBean=solvo.ee.beans.SimpleBean@49a86248}

Como podemos ver, hay dos instancias diferentes de SimpleBean. Después de eso, envío el formulario de la primera pestaña.

Severe: [email protected]()
Severe: ====================
Severe: name: First tab
Severe: ====================
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {simpleBean=solvo.ee.beans.SimpleBean@2adafd68}
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {}

Si intento enviar el formulario de la segunda pestaña, la instancia anterior almacenada de SimpleBean (solvo.ee.beans.SimpleBean@49a86248) no se utilizará, en cambio, ViewScopeContextManager creará una nueva instancia de la clase SimpleBean, como podemos ver en Iniciar sesión:

Severe: [email protected]()
Severe: [email protected]()
Severe: ====================
Severe: name: Second tab
Severe: ====================
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {simpleBean=solvo.ee.beans.SimpleBean@4797f115}
Finest: Handling PreDestroyViewMapEvent
Finest: Destroying @viewscoped beans from view map: {}

He comprobado el código del método com.sun.faces.application.view.ViewScopeContextManager.copyViewScopeContextsFromSession y, según tengo entendido, este comportamiento es normal. Sin embargo, si almaceno parámetros de solicitud u otros datos importantes en mi bean, lo perderé porque la instancia se perderá después de enviar el primer formulario.

¿Hay una solución para mantener el bean asociado con la segunda pestaña principalmente (en mi ejemplo solvo.ee.beans.SimpleBean@49a86248)?

Respuestas a la pregunta(1)

Su respuesta a la pregunta