1 Reply Latest reply on Dec 3, 2008 5:16 AM by buttau

    passing arguments to backing bean method from selectItems

    bentfrog

      I have a dataTable which contains a column that is a selectOneMenu. I need the contents of the list to be different depending on which row is displayed.

      Basically I want to pass the work order number of the current row in the grid to the list and have the backing bean perform a method based on this value.

      I know the following code does not work but I was wondering if anyone knew how to do it?

      <rich:dataTable id="workOrderResults" var="order" value="#{searchToRs.workOrders.results}" rows="12" width="100%" cellpadding="0" cellspacing="0" styleClass="resultsTable" sortMode="single">
       <rich:column styleClass="#{order.selected ? 'rowHighlighted' : ''}" sortable="true" sortBy="#{order.workOrderNo}">
       <f:facet name="header">
       <h:outputText value="#{labels.workOrder}"/>
       </f:facet>
       <h:outputText value="#{order.workOrderNo}" rendered="#{!searchToRs.editMode}"/>
       <h:selectOneMenu id="workOrder" tabindex="10" rendered="#{searchToRs.editMode}" value="#{order.workOrderNo}">
       <f:selectItems value="#{searchToRs.torWorkOrderListCombo(order.workOrderNo)}"/>
       </h:selectOneMenu>
       </rich:column>
      </rich:dataTable>
      


      And the backing bean

      public List<SelectItem> getTorWorkOrderListCombo(String workOrderNo) {
       return workOrderListAction.getTorWorkOrderListCombo(workOrderNo);
      }
      


        • 1. Re: passing arguments to backing bean method from selectItem
          buttau

          you can pass the selection list with your items, like that:

          <rich:dataTable id="tableItems" value="#{backingBean.items}" var="item" rowKeyVar="rkv">
           <rich:column>
           <h:selectOneMenu id="c2" tabindex="1" value="#{item.order}" style="width:100%">
           <f:selectItems value="#{item.orderList}" />
           </h:selectOneMenu>
           </rich:column>
          


          and in backing Bean:
          public List<Items> fillItems() {
          
          for (...) {
           Item item = new Item();
           item.workOrderNo = workOrderNo;
           item.orderList = getTorWorkOrderListCombo(workOrderNo)
          }