Last active
August 4, 2022 11:27
-
-
Save CedricL46/845108847f382e8b97a2cfe267efe63c to your computer and use it in GitHub Desktop.
See full tutorial here : https://cedricleruth.com/how-to-set-current-column-value-of-selected-richtable-row-from-iterator-in-oracle-adf/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Function to call as follow : | |
//setRichTableSelectedRowAttributeValue("YOUR_TABLE_JSF_ID", "YOUR_VO_ATTRIBUTE_NAME", "THE_NEW_VALUE_TO_SET"); | |
public void setRichTableSelectedRowAttributeValue(String tableID, String attributeName, Object newAttributeValueToSet) { | |
Object value = null; | |
RichTable richTable = (RichTable)JSFUtils.findComponentInRoot(tableID); | |
if (richTable != null) { | |
RowKeySet rks = richTable.getSelectedRowKeys(); | |
Iterator it = rks.iterator(); | |
while (it.hasNext()) { | |
List selectedRowKeyPath = (List)it.next(); | |
Row row = ((JUCtrlHierNodeBinding)richTable.getRowData(selectedRowKeyPath)).getRow(); | |
row.setAttribute(attributeName, newAttributeValueToSet); //Be sure that the attributeName is defined in the VO to avoid errors | |
//Note : The attributeName is the name of the table column as written in the View Object (It is case sensitive) | |
} | |
} | |
} | |
//The function use the findComponentInRoot util, usually set in a bean called JSFUtils. If you don't have it already here it is: | |
/** | |
* Method find in the JSFUtils ADF toolkit: https://github.com/CedricL46/Oracle-ADF-and-JSF-Utils-libraries | |
* Locate an UIComponent in view root with its component id. Use a recursive way to achieve this. | |
* @param id UIComponent id | |
* @return UIComponent object | |
*/ | |
public static UIComponent findComponentInRoot(String id) { | |
UIComponent component = null; | |
if (id != null) { | |
FacesContext facesContext = FacesContext.getCurrentInstance(); | |
if (facesContext != null) { | |
UIComponent root = facesContext.getViewRoot(); | |
if (root != null) { | |
component = findComponent(root, id); | |
} | |
} | |
} | |
return component; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment