Monday, March 5, 2012

How to get a specific component in Backing bean without binding to backing bean using ADF ?

Below snippet provides a way to get a selected ADF UI RichComponent in backing bean without actually binding the component to a backing bean or managed bean. This will help you to avoid too many bindings in any managed or backing bean

private static UIComponent findUIComponent(UIComponent pRootComponentString pComponentId)
{
if (pComponentId.equals(pRootComponent.getId()))
return pRootComponent;
UIComponent kid = null;

UIComponent result = null;
Iterator kids = pRootComponent.getFacetsAndChildren();
while (kids.hasNext() && (result == null))
{
kid = (UIComponent) kids.next();
if (pComponentId.equals(kid.getId()))
{
result = kid;
break;
}
result = findComponent(kid, pComponentId);
if (result != null)
{
break;
}
}
return result;
}

No comments:

Post a Comment