Search This Blog

Saturday, November 21, 2009

General Method to get component in a ADF page

public static void findComponent(String componentId, ContextCallback callback) throws FacesException {
// -- Get current instance of the Faces context object
FacesContext facesCtx = FacesContext.getCurrentInstance();
// -- Get view root for current view or page
UIViewRoot root = facesCtx.getViewRoot();
// -- Invoke the CallBack on the component associated with componentId
boolean found = root.invokeOnComponent(facesCtx, componentId, callback);
// -- Throw exception if the target component is not found
if (!found) throw new FacesException(componentId + " not found!");
}