1 Reply Latest reply on Jan 11, 2008 5:50 PM by Dan Florian

    @DataModelSelection Is Update When @Factory Method Gets Call

    Dan Florian Newbie

      I'm writing a very simple Web application and trying to use POJOs instead of SBs. I have a page that displays a parent object and it's children. The children's names are displayed in the cells of a datatable. Each child has an associated SEAM link that is used to redisplay the current page but now using the child as the parent. When I click the child link the page does redisplay but since the @DataModelSelection value is always set to the first child in the collection the wrong child is displayed (unless I click on the first child:-). I've verified that the @DataModelSelection is only updated when the @Factory method is called. See code (modified for simplicity) below. Thanks much for your help.

      xhtml code:

      <rich:dataTable
      value="#{pojo.kids}"
      var="child">

      <rich:column>
      <f:facet name="header">
      <h:outputText
      styleClass="tableHeaderText"
      value="Child Name" />
      </f:facet>
      <s:link
      action="#{pojo.viewChild}"
      value="#{child.name}">
      </s:link>
      </rich:column>
      </rich:dataTable>

      pojo code:

      @Name( "pojo" )
      @Scope( ScopeType.SESSION )
      public class Pojo implements Serializable {

      @Out
      @DataModelSelection( "kids" )
      private Node child;

      private Node node;

      @DataModel
      private List kids;

      @Factory( "kids" )
      public List getNodeChildren() throws Exception {
      this.kids = this.node.getChildren();
      return this.kids;
      }

      public String viewChild() throws Exception {
      this.node = this.child;
      return "view";
      }
      }