Change the editing status of the current row after selecting the table row in the ADF.

Source: Internet
Author: User

Change the editing status of the current row after selecting the table row in the ADF.

 

Now, select a row in the table. The upload button for this row is available, and the unselected row is unavailable:

 

 

The specific implementation method is as follows:

1. corresponding table code. Use the <selectionListener> attribute Association implementation class.

<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. The code corresponding to the "Upload" button. Pay attention to the disabled method.

<Af: commandButton text = "# {res ['upload']}"
UseWindow = "true"
Required wheight = "600" required wwidth = "450"
Immediate = "true" disabled = "# {row. Flag = '0 '? True: false }"
Action = "# {testBean. uploadFile}">

 

3. In the corresponding implementation class, the flag value is changed each time the current row is selected.

Public void selectionChanged (SelectionEvent selectionEvent ){
UIComponent cmp = selectionEvent. getComponent ();
// Obtain the current TABLEID
DCBindingContainer tableBindings =
(DCBindingContainer) getDCBindingContainer ();
DCIteratorBinding iterBinding = tableBindings. findIteratorBinding ("PtsTestVVO1 ");


String strID = cmp. getId ();

CoreTable tableReceiptOrderAssign = this. getTableOjb (strID );
// Traverse 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 (); // get the current row
CurentRow. setAttribute ("Flag", "1"); // you can specify a Flag.
}
AdfFacesContext. getCurrentInstance (). addPartialTarget (tableReceiptOrderAssign );
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.