The code:
Code: Select all
public void encodeTreeNode(FacesContext context, Tree tree, TreeNode node, String clientId, boolean dynamic, boolean checkbox, boolean dragdrop) throws IOException {
//preselection
String rowKey = node.getRowKey();
boolean selected = node.isSelected();
boolean partialSelected = node.isPartialSelected();
boolean filter = (tree.getValueExpression("filterBy") != null);
UITreeNode uiTreeNode = tree.getUITreeNodeByType(node.getType());
if(!uiTreeNode.isRendered()) {
return;
}
List<String> filteredRowKeys = tree.getFilteredRowKeys();
boolean match = false;
if(filter && filteredRowKeys.size() > 0) {
for(String rk : filteredRowKeys) {
if(rk.startsWith(rowKey) || rowKey.startsWith(rk)) {
match = true;
if(!node.isLeaf() && !rowKey.startsWith(rk)) {
node.setExpanded(true);
}
break;
}
}
if(!match) {
return;
}
}
if(rk.startsWith(rowKey) || rowKey.startsWith(rk))
is wrong in my case there is a node that was matched with id: 0_101 and this check match also node with other ids e.g.: 0_1
I understand the logic of this check (matching parents of matched nodes) but it doesn't work in this case and in general I don't thing its a very good idea to put to many assumptions and logic into the id structure. The id should be unique and 'dumb' so it could be overridden easily by applications.