1 Reply Latest reply on Jan 18, 2008 4:48 AM by Bogdan Bogucki

    @DataModelSelection always returns first row

    Krzysztof Bankiewicz Newbie

      Hello, I have a problem with outjecting @DataModelSelection from one bean to another. The first bean ("browseBusinessOperationsForm") is a stateful session bean which keeps @DataModel list and the second bean ("businessOperationForm") is a stateful conversation scope bean and @DataModelSelection is injected to it with variable selectedOperation. It should works like that, when user clicks button in the dataTable row (filled with @DataModel) on browseOperation page, the show() method from "businessOperationForm" bean is invoked and the long runing conversation with custom id is started. After show() method execution, user is redirected to second page with details of operation. But this @DataModelSelection injection doesn't work, I always get the first row from dataTable no matter which row I click.
      Any ideas what I'm doing wrong?

      Thanks,
      Sejan

      @Stateful
      @Name("browseBusinessOperationsForm")
      @Scope(ScopeType.SESSION)
      
      public class BrowseBusinessOperationsFormAction implements BrowseBusinessOperationsForm {
      
       @In
       private EntityManager em;
      
      // private TreeState treeState;
      
       private TreeNode rootNode = null;
      
       private TreeNodeData<Tag> selectedNode = null;
      
       private int dataScrollerRow = 0;
      
       @DataModel(value="operations")
       private List<BusinessOperation> operations;
      
       @DataModelSelection(value="operations")
       @Out(required=false)
       private BusinessOperation selectedOperation;
      
       @Out(required=false)
       private BusinessOperation operation;
      
       @In
       private FacesContext facesContext;
      ....}
      

      @Stateful
      @Name("businessOperationForm")
      @Scope(ScopeType.CONVERSATION)
      
      public class BusinessOperationFormAction implements BusinessOperationForm {
      
      
       @In
       private EntityManager em;
      
       @In
       private FacesMessages facesMessages;
      
       @In(required = false) @Out(required = false)
       private BusinessOperation operation;
      
       @In(required = false)
       private BusinessOperation selectedOperation;
      
       @In
       Identity identity;
      
       @Logger
       Log log;
      
      
       @Begin (id="operation=#{selectedOperation.id}")
       public String show() {
       log.info("show ref: [#0] - started", this);
       log.info("show ref: [#0] - conversation started", this);
       log.info("show ref: [#0] - operation id: #1 name: #2", this, selectedOperation.getId(), selectedOperation.getName());
      
       operation = em.find(BusinessOperation.class, selectedOperation.getId());
      
       log.info("show ref: [#0] - passed", this);
      
       return "businessOperation";
       }
       ....}
      


      And below is a snippet from browseOperation page with dataTable:
      <ui:define name="contentWithNavigation">
       <rich:panel id="browseOperationPanel">
       <f:facet name="header">
       <h:outputText value="#{messages['browseBusinessOperation.browseOperationLabel']}"/>
       </f:facet>
       <h:form id="browseBussinesOperationForm">
       <rich:datascroller id="operationDataScroller"
       align="center"
       for="operationDataTable"
       ajaxSingle="true"
       ignoreDupResponses="true"
       pageIndexVar="pageIndex"
       pagesVar="pages">
       </rich:datascroller>
       <h:dataTable id="operationDataTable"
       value="#{operations}"
       var="varOperation">
      
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{messages['browseBusinessOperation.operationVersionLabel']}" />
       </f:facet>
       <h:outputText
       value="#{varOperation.version}.#{varOperation.subVersion}.#{varOperation.buildVersion}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="#{messages['browseBusinessOperation.operationAsigneeLabel']}" />
       </f:facet>
       <h:outputText value="#{varOperation.asignee}" />
       </h:column>
       <h:column>
       <f:facet name="header">
       <h:outputText value="" />
       </f:facet>
       <h:commandButton id="showBusinessOperationButton"
       value="#{messages['browseBusinessOperation.showOperationButton']}"
       action="#{businessOperationForm.show}">
       </h:commandButton>
       </h:column>
       </h:dataTable>
       </h:form>
       </rich:panel>
       </ui:define>