2 Replies Latest reply on Jun 18, 2008 10:37 PM by Duncan Stockdill

    How to bind input form to new entity outside of a long running conversation

    Duncan Stockdill Newbie

      I have a search screen that lists and allows searching of contacts.  This is outside of a long running conversation.  I would like to place an input form on this page to enable quick  addition of new contacts. 


      If the page was running in a long running conversation I could  do something like the following



      @Stateful
      @Name("contactManager")
      @Scope(ScopeType.CONVERSATION)
      public class ContactManager {
      
      @Out
      Contact newContact = new Contact();
      
      public saveNewContact() {
        entityManager.persist(newContact);
        newContact = new Contact();
      }




      The view would simply be something like



      <h:form>
       <h:inputText value="#{newContact.firstName}"/>
       <h:inputText value="#{newContact.lastName}"/>
       <h:commandButton value="Save" action="#{contactManager.saveNewContact}"/>
      </h:form>





      Question is, how do I do achieve the same thing outside of a long running conversation?  I could add firstName and lastName as bean properties of the manager, but this means I have to duplicate validation rules on the entity.  I would prefer to inject/bind directly to the new entity if possible.


      Thanks