2 Replies Latest reply on Dec 12, 2007 3:03 PM by Casey Boyd

    Update Data Model from another Bean

    Casey Boyd Novice

      I have a Data Model and some input boxes on a page.

      Select a record from the Data Model and the input boxes is populated with the records information.

      Change the data in the input boxes and hit a "Update" button.

      Update the record in the database and then reload the Data Model.

      All this works great except the reloading of the Data Model...

      Here is the code...

      Bean Responsible for the Data Model

      
      @Name("getusers")
      @Scope(PAGE)
      @Restrict("#{identity.loggedIn}")
      public class GetUsersAction {
      
      
       @DataModel
       private List<User> users2;
      
       @Factory("users2")
       public List<User> getUsers2() { ... }
      
      
      }
      
      


      Bean Responsible for updating the record...

      
      @Name("updateuser")
      @Stateful
      @Scope(EVENT)
      @Restrict("#{identity.loggedIn}")
      public class UpdateUserAction implements UpdateUserActionInterface {
      
      
       public void updateUser() { ... }
      
      }
      
      


      And the web page...

      
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a4j="http://richfaces.org/a4j"
       xmlns:rich="http://richfaces.org/rich"
       template="layout/template.xhtml">
      
       <ui:define name="body">
      
       <h:form>
      
       <a4j:region>
      
       <rich:dataTable id="tblUsers" var="varUser" value="#{users2}" >
      
       ....
      
       </rich:dataTable>
      
       </a4j:region>
      
       <a4j:commandButton value="Update" action="#{updateuser.updateUser()}" ></a4j:commandButton>
      
       <h:inputText value="#{currentUser.firstname}"></h:inputText>
      
       </h:form>
      
       </ui:define>
      
      </ui:cocmposition>
      
      


      The question is, how do I update the Data Model (users2) from the updateuser Bean after the updateUser method has completed?

      I don't want to Inject and Outject it....

      Thanks

      indy