Find component
Hi everyone,
I needto find a component by its id in the view from the code in the bean. I have written the following method, but is working only when the way is straight, i mean
view
html
head
body
form
component
component_to_be_found
but not in the following case, or alikes:
view
html
head
body
form
component 1
component 1.1
component 1.2
component_to_be_found
component 2
the method is as follows:
public UIComponent getElementById(UIComponent base, String compId) {
Dummy.println("Base = " + base);
if (compId.equals(base.getId())) {
Dummy.println("Encontrado = " + base);
return base;
}
UIComponent component = null;
ArrayList<UIComponent> list = (ArrayList<UIComponent>) base.getChildren();
for (UIComponent component2 : list) {
if ((component = getElementById(component2, compId)) != null) {
return component;
}
}
return null;
}
any help is mostly welcome,
ip

