Skip to content

Commit

Permalink
#598 **:id should return multiple ids if there are multiple matches
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Dec 26, 2016
1 parent 420c71e commit dfbc826
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public List<UIComponent> resolve(UIComponent component, List<UIComponent> parent
searchRoot = searchRoot.getParent();
}

UIComponent c = findIdRecursively(searchRoot, parameters[0]);
List<UIComponent> c = findIdsRecursively(searchRoot, parameters[0]);
if (null != c) {
result.add(c);
result.addAll(c);
}
}
if (result.size() > 0) {
Expand All @@ -32,18 +32,25 @@ public List<UIComponent> resolve(UIComponent component, List<UIComponent> parent
throw new FacesException("Invalid search expression - couldn't find id " + currentId + ". Complete search expression: " + originalExpression);
}

public UIComponent findIdRecursively(UIComponent parent, String id) {
public List<UIComponent> findIdsRecursively(UIComponent parent, String id) {
if (null==parent)
return null;
List<UIComponent> result = null;
if (id.equals(parent.getId())) {
return parent;
result = new ArrayList<UIComponent>();
result.add(parent);
}
Iterator<UIComponent> facetsAndChildren = parent.getFacetsAndChildren();
while (facetsAndChildren.hasNext()) {
UIComponent child = facetsAndChildren.next();
UIComponent result = findIdRecursively(child, id);
if (null != result) return result;
List<UIComponent> childresult = findIdsRecursively(child, id);
if (null != childresult && (!childresult.isEmpty())) {
if (null == result) {
result = new ArrayList<UIComponent>();
}
result.addAll(childresult);
}
}
return null;
return result;
}
}

0 comments on commit dfbc826

Please sign in to comment.