Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Function to call as follow :
//Object myValue = MyBean.getRichTableSelectedRowAttributeValue("tableID", "VoAttributeName");
public Object getRichTableSelectedRowAttributeValue(String tableID, String attributeName) {
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();
value = (Object)row.getAttribute(attributeName); //Be sure that the attributeName is defined in the VO to avoid errors
}
}
return value;
}
//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
* 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
You can’t perform that action at this time.