First I need to have some common methods.
// find a jsf component inside the JSF page private UIComponent getUIComponent(String name) { FacesContext facesCtx = FacesContext.getCurrentInstance(); return facesCtx.getViewRoot().findComponent(name) ; } // find a UIComponent inside a UIComponent private UIComponent getUIComponent(UIComponent component, String name) { if (component != null) System.out.println(component.getId()); List<UIComponent> items = component.getChildren(); Iterator<UIComponent> facets = component.getFacetsAndChildren(); if ( items.size() > 0 ) { System.out.println("got childern"); for (UIComponent item : items) { UIComponent found = getUIComponent(item, name); if (found != null) { return found; } if (item.getId().equalsIgnoreCase(name)) { return item; } } } else if ( facets.hasNext()) { System.out.println("got facets"); while ( facets.hasNext() ){ UIComponent facet = facets.next(); UIComponent found = getUIComponent(facet, name); if (found != null) { return found; } if (facet.getId().equalsIgnoreCase(name)) { return facet; } } } return null; }Now we can find the right Region and then search inside the Region for the ADF Tree
// get the dymamic region of the main page RichRegion region = (RichRegion)getUIComponent("dynam1"); if ( region != null) { // find tree 2 RichTree rt = (RichTree)getUIComponent(region,"t2"); if ( rt != null ) { // do your thing } }Or you can use the findComponent method after you found the region
// get the dymamic region of the main page RichRegion region = (RichRegion)getUIComponent("dynam1"); if ( region != null) { // find tree 2 RichTree rt = (RichTree)region.findComponent("t2"); if ( rt != null ) { // do your thing } }
I have a page with a region, the region has a panelStretchLayout, and within this an inputText,
ReplyDeletewhen the method to call the children of panelStretchLayout, the method returns null
Hi,
ReplyDeleteCan you make a testcase and send it to biemond at gmail dot com
thanks
Test Case
ReplyDeletehttp://www.box.net/shared/s8g7gxac01
Run-> Main.jspx and look the Log of JDeveloper
Hi,
ReplyDeleteI found the problem,
first the quick solution , you can do a findComponent on the region.
RichRegion region = (RichRegion)getUIComponent("theRegion");
RichInputText it = (RichInputText)region.findComponent("it1");
and now your problem. Some components dont have childern but facets. So I changed the getUIComponent component.
private UIComponent getUIComponent(UIComponent component, String name) {
if (component != null)
System.out.println(component.getId());
List<UIComponent> items = component.getChildren();
Iterator<UIComponent> facets = component.getFacetsAndChildren();
if ( items.size() > 0 ) {
System.out.println("got childern");
for (UIComponent item : items) {
UIComponent found = getUIComponent(item, name);
if (found != null) {
return found;
}
if (item.getId().equalsIgnoreCase(name)) {
return item;
}
}
} else if ( facets.hasNext()) {
System.out.println("got facets");
while ( facets.hasNext() ){
UIComponent facet = facets.next();
UIComponent found = getUIComponent(facet, name);
if (found != null) {
return found;
}
if (facet.getId().equalsIgnoreCase(name)) {
return facet;
}
}
}
return null;
}
thanks I will update this blogpost
Thanks for your time
ReplyDeleteIn the next Blog I found a similar solution
http://www.jroller.com/page/mert?entry=how_to_find_a_uicomponent
Hi,
ReplyDeleteThe blog was very useful . I am using Jdeveloper 11.1.1.4.0 .. I am getting Missing in and out parameter...
the scenario is like this ..
I have a choice list , for which i have inturn created a view and provided a bind variable ,
Issue is whenever i select a value from the choice list i get the above error.
Hi,
ReplyDeleteI am able to get the component(SelectOneChoice) in the region, but when I try to get it's value it returns a null even when I have selected one.
Solved. The SelectOneChoice value attribute in the .jsff file should not be set, then after selecting one of the values it returns that value. But have no idea why this happens??
Delete