// Get the Component based on given UIComponent ID and refresh the component
private static void refreshComponent(String pComponentID) {
UIComponent component = findComponentInRoot(pComponentID);
refreshComponent(component);
}
// Get Faces Context, Get Root Component, Find the given Component From the root component
private static UIComponent findComponentInRoot(String pComponentID) {
UIComponent component = null;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
UIComponent root = facesContext.getViewRoot();
component = findComponent(root, pComponentID);
}
return component;
}
// Refresh the Component
private static void refreshComponent(UIComponent component) {
if (component != null) {
AdfFacesContext.getCurrentInstance().addPartialTarget(component);
}
}
// Get the specific component from a root component tree.
private static UIComponent findComponent(UIComponent root, String id) {
if (id.equals(root.getId()))
return root;
UIComponent children = null;
UIComponent result = null;
Iterator childrens = root.getFacetsAndChildren();
while (childrens.hasNext() && (result == null)) {
children = (UIComponent)childrens.next();
if (id.equals(children.getId())) {
result = children;
break;
}
result = findComponent(children, id);
if (result != null) {
break;
}
}
return result;
}
No comments:
Post a Comment