You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Adrian Gonzalez <ad...@yahoo.fr> on 2012/12/04 11:32:13 UTC

CODI ViewAccessScoped destroyed on GET request

Hello,

I just began using @ViewAccessScoped.
Problem is that my bean is removed on some GET requests (h:link) - even if I'm always displaying the same page using this viewAccessScoped bean.

Environment :
 * CODI 1.0.5
 * JBoss 7.1.0.Final

My page (test.xhtml) uses a single @ViewAccessScoped bean.

In my page I have :
 * a h:link pointing to test.xhtml
 * h:commandButton just doing a simple postback (no action, no navigation rule).

When I do :
 1. http://myhost/myapp/test.xhtml
 2. click on h:commandButton
 3. click on h:link

Everything works fine.

When I do :
 1. http://myhost/myapp/test.xhtml
 2. click on h:link
@PreDestroy and @PostConstruct are called in phase 6 of step 2 (the bean is removed and recreated).


Is this a bug or did I miss sthing ?

Thanks for the help !

P.S. 
here's my sample :
To reproduce failed testcase, just :
 1. http://myhost/myapp/test.xhtml on your browser
 2. click on first link '1.GET - windowId propagation'

jsf page 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml";
    xmlns:f="http://java.sun.com/jsf/core";
    xmlns:h="http://java.sun.com/jsf/html";
    xmlns:ui="http://java.sun.com/jsf/facelets";>
    <h:head/>
    <h:body>
    #{pingController.value}
    <h:messages globalOnly="true"/>
    <p>windowId=#{currentWindow.id}</p>
    <ol>
      <li><h:link outcome="test.xhtml" value="GET - windowId propagation"/></li>
       <li>
         <h:link outcome="test.xhtml" value="GET - no propagation">
           <f:param name="windowId" value=""/>
       </h:link>
       </li>
       <li><a href="#{facesContext.externalContext.request.contextPath}/test.xhtml?windowId=#{currentWindow.id}">GET - windowId propagation with a href</a></li>
       <li>
         <h:form>
           <h:commandButton value="POST"/> POST - windowId propagation
         </h:form>
       </li>
     </ol>
  </h:body>
</html>

ViewAccess bean :
@Named
@ViewAccessScoped
@SuppressWarnings("serial")
public class PingController implements Serializable {

private String value;
@PostConstruct
public void initialize() {
System.out.println("@PostConstruct");
Messages.addGlobalInfo("@PostConstruct");
}

@PreDestroy
public void destroy() {
System.out.println("@PreDestroy");
Messages.addGlobalInfo("@PreDestroy");
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}

Re: CODI ViewAccessScoped destroyed on GET request

Posted by Adrian Gonzalez <ad...@yahoo.fr>.
I just created an application from scratch, and the problem went away.

Everything working fine for now.

Sorry for this wrong alert.


----- Mail original -----
De : Adrian Gonzalez <ad...@yahoo.fr>
À : "users@myfaces.apache.org" <us...@myfaces.apache.org>
Cc : 
Envoyé le : Mardi 4 décembre 2012 11h32
Objet : CODI ViewAccessScoped destroyed on GET request

Hello,

I just began using @ViewAccessScoped.
Problem is that my bean is removed on some GET requests (h:link) - even if I'm always displaying the same page using this viewAccessScoped bean.

Environment :
 * CODI 1.0.5
 * JBoss 7.1.0.Final

My page (test.xhtml) uses a single @ViewAccessScoped bean.

In my page I have :
 * a h:link pointing to test.xhtml
 * h:commandButton just doing a simple postback (no action, no navigation rule).

When I do :
 1. http://myhost/myapp/test.xhtml
 2. click on h:commandButton
 3. click on h:link

Everything works fine.

When I do :
 1. http://myhost/myapp/test.xhtml
 2. click on h:link
@PreDestroy and @PostConstruct are called in phase 6 of step 2 (the bean is removed and recreated).


Is this a bug or did I miss sthing ?

Thanks for the help !

P.S. 
here's my sample :
To reproduce failed testcase, just :
 1. http://myhost/myapp/test.xhtml on your browser
 2. click on first link '1.GET - windowId propagation'

jsf page 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml";
    xmlns:f="http://java.sun.com/jsf/core";
    xmlns:h="http://java.sun.com/jsf/html";
    xmlns:ui="http://java.sun.com/jsf/facelets";>
    <h:head/>
    <h:body>
    #{pingController.value}
    <h:messages globalOnly="true"/>
    <p>windowId=#{currentWindow.id}</p>
    <ol>
      <li><h:link outcome="test.xhtml" value="GET - windowId propagation"/></li>
       <li>
         <h:link outcome="test.xhtml" value="GET - no propagation">
           <f:param name="windowId" value=""/>
       </h:link>
       </li>
       <li><a href="#{facesContext.externalContext.request.contextPath}/test.xhtml?windowId=#{currentWindow.id}">GET - windowId propagation with a href</a></li>
       <li>
         <h:form>
           <h:commandButton value="POST"/> POST - windowId propagation
         </h:form>
       </li>
     </ol>
  </h:body>
</html>

ViewAccess bean :
@Named
@ViewAccessScoped
@SuppressWarnings("serial")
public class PingController implements Serializable {

private String value;
@PostConstruct
public void initialize() {
System.out.println("@PostConstruct");
Messages.addGlobalInfo("@PostConstruct");
}

@PreDestroy
public void destroy() {
System.out.println("@PreDestroy");
Messages.addGlobalInfo("@PreDestroy");
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}