title: Elegant handling of attributes without a session bean
body: <p>I'm working on an application using JSF 2.0 and Richfaces 4, that consists of many tables that display elements and of course, the usual View/Edit/Delete options. After some SO browsing and Google search I've decided to post a question because the answers I found did not solve my problem.</p>
  
  <p>Right now, and going straight to the point, my application is having issues when handling certain attributes that are stored in request beans and, on certain points, are lost due to successive requests.</p>
  
  <p>For example, when I want to edit an object, the object is sent (f:propertyActionListener) to a request bean that displays the data on a form, then it is discarded as that request ends. When saving, a new object is created and the attributes on the form are setted to it and the item gets saved instead of updated, since it has no id (JPA + Hibernate).</p>
  
  <p>I've investigated many options and this is what I've did so far and the results:</p>
  
  <p><strong>f:param + h:link or h:commandLink:</strong> With @ManagedProperty the param is null, and I can't find it on the Context to look it up through JNDI.</p>
  
  <p><strong>f:setPropertyActionListener + h:commandLink + Request Bean:</strong> Works... but I'm losing some data. The form that displays the data has some conditionally rendered fields and I can't hold that info, so the form is messed if the validation phase finds invalid data.</p>
  
  <p><strong>f:viewParam + h:commandLink + View Scoped Bean:</strong> Weird stuff here. This one doesn't directly work because the bean seems to get discarded before rendering the form, because the form is rendered with no information since the bean is clean.</p>
  
  <p><strong>Using a session bean:</strong> Works like a charm, but I don't want to make a session bean for every form just because I'm still learning things about the JSF lifecycle, I want to do it the proper way.</p>
  
  <p>If I want to keep the Request session approach, is there a way to store a parameter (either an object or a plain string) and obtain later on a request bean?.</p>
  
  <p>Dunno if this helps but I'm using a master page through ui:insert and ui:define.</p>