ADF中選擇表行後改變當前行的編輯狀態,adf當前

來源:互聯網
上載者:User

ADF中選擇表行後改變當前行的編輯狀態,adf當前

 

現在要實現在table中,選中某一行,該行的上傳按鈕可用,不選中的行為不可用,如下實現效果:

 

 

具體實現方式如下:

1、對應的table代碼,用<selectionListener>屬性關聯實作類別

               <af:table value="#{bindings.PtsTestVVO1.collectionModel}"
                            var="row" width="100%"
                            rows="#{bindings.PtsTestVVO1.rangeSize}"
                            first="#{bindings.PtsTestVVO1.rangeStart}"   
                            emptyText="#{bindings.PtsTestVVO1.viewable ? 'No rows yet.' : 'Access Denied.'}"  
                           
                            selectionListener="#{testBean.selectionChanged}"
                            banding="none"     
                            binding="#{testBean.testTable}">

 

2、對應“上傳”按鈕的代碼,注意這裡disabled的寫法

                  <af:commandButton text="#{res['UPLOAD']}"
                                 useWindow="true"
                                      windowHeight="600" windowWidth="450" 
                                      immediate="true"  disabled="#{row.Flag=='0'?true:false}"
                                    action="#{testBean.uploadFile}">

 

3、在對應實作類別中,每次選中當前行,改變flag的值

    public void selectionChanged(SelectionEvent selectionEvent) {
           UIComponent cmp = selectionEvent.getComponent();
                //取當前TABLEID
                 DCBindingContainer tableBindings =
                     (DCBindingContainer)getDCBindingContainer();
                 DCIteratorBinding iterBinding= tableBindings.findIteratorBinding("PtsTestVVO1");
               
               
                String strID = cmp.getId();
               

                CoreTable tableReceiptOrderAssign = this.getTableOjb(strID);
                //遍曆VO set Falg\
                ViewObject VO = this.getPtsAM().findViewObject("PtsTestVVO1");
                int rowCount;
                int rowCount0 = VO.getRowCount();
                int rowCount1 = VO.getRangeSize();
                if (rowCount0 >= rowCount1) {
                    rowCount = rowCount1;
                } else {
                    rowCount = rowCount0;
                }
                for (int i = 0; i < rowCount; i++) {
                    VO.getRowAtRangeIndex(i).setAttribute("Flag", "0");
                }
                Set rowSet = tableReceiptOrderAssign.getSelectionState().getKeySet();
                if (rowSet.size() == 0) {
                    return;
                }
                Iterator rowSetIter = rowSet.iterator();
                while (rowSetIter.hasNext()) {
                    Key key = (Key)rowSetIter.next();
                    iterBinding.setCurrentRowWithKey(key.toStringFormat(true));

                    RowImpl curentRow = (RowImpl)iterBinding.getCurrentRow(); //得到當前行
                    curentRow.setAttribute("Flag", "1"); //設定標緻位                   
                }
                AdfFacesContext.getCurrentInstance().addPartialTarget(tableReceiptOrderAssign);
    }

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.