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 );
}