public static UIComponent findComponent(UIComponent topComponent, String compId) {
if (compId==null)
throw new NullPointerException("Component identifier cannot be null");
if (compId.equals(topComponent.getId()))
return topComponent;
if (topComponent.getChildCount()>0) {
List<UIComponent> childComponents= topComponent.getChildren();
for (UIComponent currChildComponent : childComponents) {
UIComponent foundComponent=findComponent(currChildComponent, compId);
if (foundComponent!=null)
return foundComponent;
}
}
return null;
}
public static Object getSubmittedValue(String compId) {
UIComponent c = findComponent(FacesContext.getCurrentInstance().getViewRoot(), compId);
// value submitted from the browser
Object o = ((UIInput) c).getSubmittedValue();
if( null == o ){
// else not yet submitted
o = ((UIInput) c).getValue();
}
return o;
}