title: Passing parameter from one page to another - The scope of the object referenced by expression is shorter than the referring managed beans error
body: <p>I am trying to pass a parameter from one page to another, but when i press the button "Details" it gives me this error: "Unable to create managed bean agencyDetailBean. The following problems were found: - The scope of the object referenced by expression #{agency}, request, is shorter than the referring managed beans (agencyDetailBean) scope of session"</p>
  
  <p>This is part from my .xhtml page:</p>
  
  <pre><code>&lt;p:dataGrid var="agency" value="#{agencyBean.agencyList}" columns="1"
      rows="5" paginator="true" paginatorPosition="bottom"&gt;
      &lt;p:growl id="growl" showDetail="true" /&gt;
      &lt;p:fieldset legend="${agency.tUser.name}" toggleable="true"&gt;
          &lt;p:ajax event="toggle" listener="#{fieldsetBean.handleToggle}"
              update="growl" /&gt;
          &lt;h:panelGrid columns="2" cellpadding="3" cellspacing="1"&gt;
              &lt;h:panelGrid columns="2" cellpadding="3" cellspacing="1"&gt;
                  Name: &lt;h:outputText value="${agency.tUser.name}" /&gt;
                  Phone: &lt;h:outputText value="${agency.tUser.phone}" /&gt;
              &lt;/h:panelGrid&gt;
  
              &lt;h:commandButton value="Details" action="agencyDetail"&gt;
                  &lt;f:setPropertyActionListener target="#{agencyBean.tAgency}"
                      value="${agency}" /&gt;
              &lt;/h:commandButton&gt;
          &lt;/h:panelGrid&gt;
  
      &lt;/p:fieldset&gt;
  &lt;/p:dataGrid&gt;
  </code></pre>
  
  <p>My 1st bean: </p>
  
  <pre><code>@ManagedBean(name = "agencyBean")
  @SessionScoped
  public class AgencyBean implements Serializable {
  
      private TAgency tAgency = new TAgency();
      private List&lt;TAgency&gt; agencyList;
  
      public List&lt;TAgency&gt; getAgencyList() {
          return agencyList;
      }
  
      public void setAgencyList(List&lt;TAgency&gt; agencyList) {
          this.agencyList = agencyList;
      }
  
      @PostConstruct
      public void init() {
          EntityManager em = HibernateUtil.getEntityManager();
          Query q = em.createQuery("select u from TAgency u");
          agencyList = q.getResultList();
      }
  
      public TAgency gettAgency() {
          return tAgency;
      }
  
      public void settAgency(TAgency tAgency) {
          this.tAgency = tAgency;
      }
  }
  </code></pre>
  
  <p>My 2nd bean class:</p>
  
  <pre><code>@ManagedBean(name = "agencyDetailBean", eager = true)
  @SessionScoped
  public class AgencyDetailBean implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @ManagedProperty(value = "#{tAgency}")
      private AgencyBean agencyBean;
  
      private TAgency tAgency;
  
      public TAgency gettAgency() {
          if (agencyBean != null) {
              tAgency = agencyBean.gettAgency();
          }
          return tAgency;
      }
  
      public void setAgencyBean(AgencyBean agency) {
          this.agencyBean = agency;
      }
  }
  </code></pre>
  
  <p>Initially, the .xhml page was like this and it worked.</p>
  
  <pre><code>&lt;p:growl id="growl" showDetail="true" /&gt;
  &lt;c:forEach items="#{agencyBean.agencyList}" var="agency"&gt;
      &lt;p:fieldset legend="${agency.tUser.name}" toggleable="true"&gt;
          ...
              &lt;h:commandButton value="Details" action="agencyDetail"&gt;
                  &lt;f:setPropertyActionListener target="#{agencyDetailBean.agency}"&lt;br/&gt;
                      value="${agency}" /&gt;
              &lt;/h:commandButton&gt;
          &lt;/h:panelGrid&gt;
      &lt;/p:fieldset&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Any suggestion what is the problem and how to fix it?
  Thanks in advance!</p>