2 Replies Latest reply on Jan 25, 2007 1:54 PM by gavin.king

    Object cached when page parameter not specified


      According to Seam App Framework documentation, "when we link to the page with no request parameter, the Create page will be displayed".

      But, the behavior I'm really getting is: when clicking "new" button for the first time, a new entity is created. So I click back button, and choose (in a list) a saved entity to edit. Click back button again, and click new button. Here, instead of having a new entity, the page displays the last edited entity.

      A) pages.xml

      <page view-id="/edit.xhtml">
      <param name="id" value="#{home.id}"
       converterId="javax.faces.Long" />

      B) index.xhtml
      B1) New Button:
      <s:link view="/edit.xhtml" value="#{messages.new}" propagation="begin" />

      B2) Edit Button:
      <s:link view="/edit.xhtml" value="#{entity.name}" propagation="begin">
       <f:param name="id" value="#{entity.id}" />

      Note: If I declare new button with id param, with no value, so the page is correctly displayed:
      <s:link view="/edit.xhtml" value="#{entity.name}" propagation="begin">
       <f:param name="id" />

      Is it the desired behavior?

      Thanx in advance

        • 1. Re: (Solved by extending EntityHome?) Object cached when pag

          When debugging the error, I noticed that even if EntityHome id was changed (via page params), EntityHome was always getting the last entity returned by getInstance. So, I extended EntityHome and called clearDirty inside getInstance method. The problem looks like to be solved. Is it reazonable?

          public T getInstance() {
           if (instance==null || clearDirty())
           return instance;

          Maybe another way to solve the problem is using explicit conversation id (section 6.6 in Seam 1.1.0 reference). This way I can be sure the desired conversation (and thus the desired state) is loaded. But in some cases (when using EntityHome components, so I can't use annotations) I have to declare it via pages.xml:

          <page view-id="/edit.xhtml">
           <param name="id" value="#{userManager.id}" />
           <begin-conversation nested="true" id="somealias#{id}" />

          Is it possible?


          • 2. Re: Object cached when page parameter not specified

            I made a similar fix in CVS - please try it out, thanks.