14 Replies Latest reply on Jul 27, 2006 3:38 PM by Gavin King

    DataModel issue

    Fane Babanu Newbie

      This may be a silly question but I haven't figured out the answer by myself, nor found any examples so please bear with me.

      Say I have the following domain model: Department -* Employee.

      I want to have a page that displays all departments, each with it's employees, and have a select button for each department *and* for each employee - on the same page. Something like this:

      <ui:repeat value="#{departments}" var="dep">
       h:button action="#{bean.selectDepartment}" value="#{dep.name}"/>
       <ui:repeat value="#{department.employees}" var="emp">
       <h:button action="#{bean.selectEmployee}" value="#{emp.name}"/>
       </ui:repeat>
      </ui:repeat>
      


      So far my relevant backing bean code looks like this:

      @DataModel
      private List<Department> departments;
      @DataModelSelection
      private Department selectedDepartment;
      @Factory
      private void findDepartments() {
       departments = departmentDAO.getAll();
      }
      
      public String selectDepartment() {
       // do stuff with selectedDepartment
      }
      
      public String selectEmployee() {
       // ???
      }
      


      How do I build on this to add the select functionality for employees?

      TIA