title: JSF: bean scope; session vs request
body: <p>I have a managed bean called <code>UserSearchHandler</code>, it has a <code>doSearch</code> method that populates <code>UserSearchHandler.searchResults</code> which are displayed in a table on the <code>userSearch.xhtml</code> page.  </p>
  
  <p>I have another managed bean called <code>UserHandler</code>, it has a <code>showUser</code> method and so on.</p>
  
  <p>In the search results table, the user name is a link that, when clicked, is supposed to show user details on a <code>userView.xhtml</code> page.  The table and link looks like this:</p>
  
  <pre><code>&lt;p:dataTable var="user" value="#{userSearchHandler.searchResults" &gt;
  
  // ... and so on ... then
  
  &lt;h:commandLink value="#{user.firstName}" action="#{userHandler.showUser}"&gt;
    &lt;f:setPropertyActionListener target="#{userHandler.userIdToShow}" value="#{profile.id}"/&gt;
  &lt;/h:commandLink&gt;
  </code></pre>
  
  <p>Everything works fine when the managed beans are set to <code>session</code> scope.</p>
  
  <p>However, when I change the scope on the beans to <code>request</code>, the search works and the table gets populated, but when I click on the name link nothing happens.  I put a break point on the <code>userHandler.showUser</code> method and it never gets hit when the <code>userSearchHandler</code> is set to "request" scope.</p>
  
  <p>Can anyone help explain why this is, or what I'm doing wrong?</p>