2 Replies Latest reply on Mar 10, 2007 3:51 PM by Stuart Robertson

    @DataModelSelection always set to first item in ListDataMode

    Stuart Robertson Novice

      First, this is Seam 1.2Patch1 on Jboss 4.0.5.

      In a nutshell, when I have a h:commandLink in a dataTable backed with a List, now matter which row's "clickable link" I select, the value in the variable annotated as @DataModelSelection is always the first element in the list.

      In my SFSB I have the following defined:

       protected FeedMappingColumn columnToDelete;
       public List<FeedMappingColumn> getMappedColumns() {
       List<FeedMappingColumn> columns = new ArrayList<FeedMappingColumn>();
       return columns;

      basically translating a map into a list for display purposes.

      The xhtml is as follows:

       <rich:dataTable id="mappedColumns" value="#{feedMapping.mappedColumns}"
       <f:facet name="header">
       <h:outputText value="Column Number" />
       <h:commandLink value="del" action="#{feedMapping.removeMapping}"/>

      and #{feedMapping.removeMapping} looks like this:

       public void removeMapping() {
       int columnNumber = columnToDelete.getRawColumn().getColumnNumber();
       info("Deleting column #0. columnToDelete instance is #1", columnNumber, columnToDelete);
       FeedMappingColumn column = mappedColumns.remove(columnNumber);
       // make sure it's already mapped. If not this is a programming error
       assert column != null : "Column [" + columnNumber + "] isn't mapped. Shouldn't be presented with unmap option";
       assert column.getMappingCdmField() != null : "Column [" + columnNumber + "] is a mapped column but doesn't have a CdmField";
       // add the cdmField back to the list of available ones
       unMappedColumns.put(columnNumber, column);

      I've been over the logic many times this afternoon, and I don't think it's a logic error. And I just stepped through Seam's DataModelSelector class, and it's getSelection() method in the debugger. After I click on for instance the last row in the list, I see that the selected value is indeed whatever happens to be the first item in the list.

      Any ideas? I suspect it's a bug in the DataModel stuff, but want to get feedback before submitting something in Jira.