4 Replies Latest reply on May 9, 2007 10:55 AM by Phil Haigh

    Scoping using Seam App Framework

    Phil Haigh Novice

      Hi,

      I'm sure this will be a really basic thing I'm missing... but..

      I have a simple CRUD application using entityhome etc in components.xml

      This works fine except for where I have validation on the form, and a non-string property (e.g. I am entering a "Vacancy" that has a "Company" object). If the form is submitted and fails validation, then the company is set back to null.

      <factory name="company" value="#{companyDAO.instance}" />
       <fwk:entity-home name="companyDAO"
       entity-class="model.Company">
       </fwk:entity-home>
      
      
       <factory name="vacancy" value="#{vacancyDAO.instance}" />
       <fwk:entity-home name="vacancyDAO"
       entity-class="model.Vacancy">
       </fwk:entity-home>
      
      


      I'm selecting the company for the addvacancy page on the preceeding page:

      <h:selectOneRadio styleClass="radiolist" layout="pageDirection" value="#{vacancy.company}" >
      <snip>
       <h:commandButton styleClass="button" value="Submit" action="/addvacancy.xhtml"/>


      Now, I can solve this problem by setting the scope of my entityhomes to session... but then the object isn't cleared after adding (next time you go to add one, you see all the old values). If I set the scope to page, it works, but then I can't edit the objects - calls to .update return the "updated" string, but don't do any database activity.

      I presume either there is:

      1. A funky way of doing this kind of thing that I've missed
      2. A way to configure conversations to avoid this issue (can this be done using entityhomes configured in components.xml?)
      3. A way to tell Seam to clear objects after a persist or update

      Any help would be greatly appreciated!