Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 2073 invoked from network); 28 Sep 2007 19:35:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Sep 2007 19:35:53 -0000 Received: (qmail 75984 invoked by uid 500); 28 Sep 2007 19:35:42 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 75548 invoked by uid 500); 28 Sep 2007 19:35:41 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 75537 invoked by uid 99); 28 Sep 2007 19:35:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 12:35:41 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simon.lessard.3@gmail.com designates 209.85.132.244 as permitted sender) Received: from [209.85.132.244] (HELO an-out-0708.google.com) (209.85.132.244) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2007 19:35:43 +0000 Received: by an-out-0708.google.com with SMTP id c3so493231ana for ; Fri, 28 Sep 2007 12:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=GDE1WjQVk4rEowRtjgYpbBc2WNH0gxDtw3jwLUQbyXw=; b=q3QJ72u6WjHLGMDQhMJA553srmoR9g80BOd2ly0cGl+KKtnef48mecXN5t+6TsYMf2MfyZoh4EkFAG+6jNMVxgb8do0UZxplH+1IvolnCJem+DifdNFMrmliOfCWFDybvTIVhBsnOZl8MQ3r2ymyOS6PVa4alwmCpCccaDB6geI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=ucNJI2Pyv9PnAsJ1ZX0MUYPCqAWutz7vT+ju7iegmBXNsdJYAVCHeYxtxsrv9ftN0bouuqKFRYD2sj2sASHFu+6aBWqC+2y4vItwXiZOhG8iqgyRzQnfd8DoXB7i9R0eUiaGINiv2YMNvPLIIkYWmEyCTH4A12xJMsCtA0HGW3c= Received: by 10.115.79.1 with SMTP id g1mr461478wal.1191008121180; Fri, 28 Sep 2007 12:35:21 -0700 (PDT) Received: by 10.115.79.2 with HTTP; Fri, 28 Sep 2007 12:35:21 -0700 (PDT) Message-ID: <254acf980709281235y3c7111f8t8b5fe6c44a43bdf1@mail.gmail.com> Date: Fri, 28 Sep 2007 15:35:21 -0400 From: "Simon Lessard" To: MyFaces-Devs Subject: Opinion on a possible page flow scope bug MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1967_29212589.1191008121173" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_1967_29212589.1191008121173 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, We have a client who played with page flow scope and bit and came to the following. Of course, the use case is extremely synthetic, but it's still strange: page.jspx Bean.java public class Bean { public Bean() { RequestContext rContext = RequestContext.getCurrentInstance(); Map pageFlowScope = rContext.getPageFlowScope(); if (!pageFlowScope.containsKey("someKey")) { System.out.println("Creating the long to create object and we sure don't want to create it twice for the page flow"); pageFlowScope.put("someKey", getAnExpensiveToCreateObject()); } } public String getValue() { RequestContext rContext = RequestContext.getCurrentInstance(); Map pageFlowScope = rContext.getPageFlowScope(); return ((SomeClass)pageFlowScope.get("someKey")).getStringAttribute(); } public void setValue(String value) { RequestContext rContext = RequestContext.getCurrentInstance(); Map pageFlowScope = rContext.getPageFlowScope(); ((SomeClass)pageFlowScope.get("someKey")).setStringAttribute(value); } } With that code, the expensive object is going to be created twice, when the page is first rendered and on first postback. This happen because at the time the form is rendered, the page flow scope is still empty (bean was never referenced) and the default behavior in that case is to not add the token to the action url thus losing the object. Therefore, if you change the page to page.jspx Then the expensive object get created only once. Personally I think we should consider that a bug as it's very counter intuitive and hard to debug. Am I missing something? Regards, ~ Simon ------=_Part_1967_29212589.1191008121173 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all,

We have a client who played with page flow scope and bit and came to the following. Of course, the use case is extremely synthetic, but it's still strange:

page.jspx
<f:view>
  <tr:document>
    <tr:form>
      <tr:inputText value="#{bean.value}"/>
      <tr:commandButton text="Go"/>
    </tr:form>
  </tr:document>
</f:view>

Bean.java
public class Bean
{
  public
Bean()
  {
    RequestContext rContext =
RequestContext.getCurrentInstance ();

    Map<String, Object> pageFlowScope =
rContext.getPageFlowScope();

    if (!pageFlowScope.containsKey("someKey"))
    {
      System.out.println("Creating the long to create object and we sure don't want to create it twice for the page flow");
     
pageFlowScope.put("someKey", getAnExpensiveToCreate Object());
    }
  }

  public String getValue()
  {
    RequestContext rContext = RequestContext.getCurrentInstance ();

    Map<String, Object> pageFlowScope =
rContext.getPageFlowScope();

    return
((SomeClass)pageFlowScope.get("someKey")).getStringAttribute();
  }

  public void setValue(String value)
  {
    RequestContext rContext = RequestContext.getCurrentInstance();

    Map<String, Object> pageFlowScope =
rContext.getPageFlowScope();

   
((SomeClass)pageFlowScope.get("someKey")).setStringAttribute(value );
  }
}

With that code, the expensive object is going to be created twice, when the page is first rendered and on first postback. This happen because at the time the form is rendered, the page flow scope is still empty (bean was never referenced) and the default behavior in that case is to not add the token to the action url thus losing the object. Therefore, if you change the page to

page.jspx
<f:view>
  <tr:document>
    <tr:outputText value="#{
bean.value}"/>
    <tr:form>
      <tr:inputText value="#{bean.value}"/>
      <tr:commandButton text="Go"/>
    </tr:form>
  </tr:document>
</f:view>

Then the expensive object get created only once. Personally I think we should consider that a bug as it's very counter intuitive and hard to debug. Am I missing something?


Regards,

~ Simon
------=_Part_1967_29212589.1191008121173--