showRowKey functionality
How to create showRowKey functionality in ADF (ADF table rowkey/RowKey)
If you want to create a showRowKey functionality in ADF through managed bean, here is the way :
showRowKey is a cool functionality which leverage the user to easily navigate to a particular row within the table. If the table consist of thousand of rows, user can easily navigate to row which he is interested on.
As a first step, you have to populate the table with rows using TreeModel. Then, use the below code to implement the showRowKey functionality.
public void displayRowKey(ActionEvent event)
{
UIComponent parentComponent = event.getComponent().getParent();
UIComponent table = parentComponent.findComponent("<table_id>");
// clear out the displayRow first
_setCurrentDisplayRow(null, table);
EditableValueHolder edit = (EditableValueHolder)
parentComponent.findComponent("rowKeyValue");
Object rowKey = edit.getValue();
if(rowKey != null)
{
if(table instanceof RichTable)
((RichTable)table).setDisplayRowKey(new Integer(rowKey.toString()));
else
{
String[] keys = rowKey.toString().split(",");
List<Integer> treeKeys = new ArrayList<Integer>(keys.length);
for(String key: keys)
{
treeKeys.add(new Integer(key));
}
if(table instanceof RichTreeTable)
((RichTreeTable)table).setDisplayRowKey(treeKeys);
else if(table instanceof RichTree) {
((RichTree)table).setScrollTop(100);
((RichTree)table).setScrollTopRowKey(treeKeys);
((RichTree)table).setDisplayRowKey(treeKeys);
}
}
}
}
private void _setCurrentDisplayRow(String displayRow, UIComponent table)
{
if(table instanceof RichTable)
{
((RichTable)table).setDisplayRowKey(null);
((RichTable)table).setDisplayRow(displayRow);
}
else if(table instanceof RichTreeTable)
{
((RichTreeTable)table).setDisplayRowKey(null);
((RichTreeTable)table).setDisplayRow(displayRow);
}
else if(table instanceof RichTree)
{
((RichTree)table).setDisplayRowKey(null);
((RichTree)table).setDisplayRow(displayRow);
}
}
Comments
Post a Comment
Please add your comment