3 Replies Latest reply on Nov 17, 2007 3:14 PM by pmuir

    how to do indexed/map-backed fields in seam?

    mwkohout

      I've got a datatable that iterates over the results of a fairly expensive search.
      For each row, the user can perform an action on the entity for that row of the table depending on the value of a selectOneMenu.

      Since each row needs to have it's own "operation" field, I've tried to implement this using a Map-backed field(with the user's id as the key). For some reason this isn't working. On selection, nothing is placed in the Map and no exceptions are being thrown.

      here's the bit of facelet:

      <rich:dataTable id="memberSelectList" value="#{viewStudyAction.userSearchList}" >
      <rich:column>
       <h:selectOneMenu value="#{viewStudyAction.userRole[possibleMember.umnDID]}">
       <s:selectItems value="#{viewStudyAction.getAllStudyRoles()}" var="role" label="#{role.name}"/>
       <a4j:support event="onchange" reRender="memberGrid" ajaxSingle="true"/>
       </h:selectOneMenu>
      </rich:column>
      </rich:dataTable>
      


      here's the bit of the named component:
      @Name(value = "viewStudyAction")
      @Scope(value = ScopeType.CONVERSATION)
      @AutoCreate
      public class ViewStudyAction {
       HashMap userRole =new HashMap();
       public List<StudyRole> getAllStudyRoles()
       {
       return studyRoleHome.getAllRoles();
       }
      


      any suggestions, explicitives, or rants would be welcome
      Mike Kohout

        • 1. Re: how to do indexed/map-backed fields in seam?
          pmuir

          The problem is that datatable is iterated over when rendering the page and hence possibleMember.umnDID is not available when restoring the tree and applying the request values back on to it. In essence, this doesn't work.

          • 2. Re: how to do indexed/map-backed fields in seam?
            mwkohout

            doh! I posted an incomplete bit of facelet:

            <rich:dataTable id="memberSelectList" value="#{viewStudyAction.userSearchList}" var="possibleMember">
            <rich:column>
             <h:selectOneMenu value="#{viewStudyAction.userRole[possibleMember.umnDID]}">
             <s:selectItems value="#{viewStudyAction.getAllStudyRoles()}" var="role" label="#{role.name}"/>
             <a4j:support event="onchange" reRender="memberGrid" ajaxSingle="true"/>
             </h:selectOneMenu>
            </rich:column>
            </rich:dataTable>
            


            Since 'possibleMember' is the current row of the datatable, isn't it blessed/remembered somehow? If not, how do clickable datatables work?


            • 3. Re: how to do indexed/map-backed fields in seam?
              pmuir

              It should be, have you tried in a standard h:dataTable?