Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3558

ViewScoped bean re-created on every ajax request

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.1.7
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 12.04

      Description

      Given a view scoped bean:

      @ManagedBean
      @ViewScoped
      public class Bean implements Serializable {
      @PostConstruct
      public void pc()

      { System.out.println("in postConstruct"); }

      }

      and a simple form:

      <h:form>
      <h:commandLink value="update">
      <f:ajax render="label"/>
      </h:commandLink>
      <h:outputText id="label" value="#

      {bean}

      "/>
      </h:form>

      Repeatable hitting on "update" button makes the value of label change:
      com.denisk.test.Bean@5b62a166
      com.denisk.test.Bean@27afca98
      com.denisk.test.Bean@3a93ea5f

      PostConstruct is fired only once though.
      I know that there is plenty of ViewScoped-related havoc in JSF2, which is described in
      http://java.net/jira/browse/JAVASERVERFACES-1492
      and related JSF spec issue (which will be fixed in spec v. 2.2):
      http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-787
      But current defect seems to be MyFaces-specific since on Mojarra 2.1.8 this works just fine

        Attachments

          Activity

            People

            • Assignee:
              lu4242 Leonardo Uribe
              Reporter:
              denisk20 Denis Kniazhev
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: