I have managed to resolve this myself, by collapsing the tree dynamically
when the model is changed.
For those who may be interested I enclose the code to achieve this.
To find the component by ID I used the following code found in the Core JSF
book.
private UIComponent findComponent(UIComponent component, String id,
FacesContext context) {
String componentId = component.getClientId(context);
if (componentId.equals(id)) return component;
Iterator kids = component.getChildren().iterator();
while (kids.hasNext()) {
UIComponent kid = (UIComponent) kids.next();
UIComponent found = findComponent(kid, id, context);
if (found != null) return found;
}
return null;
}
And then I create an HtmlTree object from the retrieved component and call
collapseAll().
private void collapseTree() {
FacesContext context = FacesContext.getCurrentInstance();
UIComponent component = context.getViewRoot();
String id = "form:tree";
HtmlTree tree = (HtmlTree) findComponent(component, id, context);
tree.collapseAll();
}
This should be done from the change Tree Model event method.
Also make sure that you know the ID of the form and Tree components.
Hope this is of help to somebody.
cheers
Andrew.
Andrew Swift-2 wrote:
>
> Help,
>
> I am receiving the above exception when I try to change my tree model
> while
> my tree is expanded.
> I think it is when the model is shorter than the number of nodes expanded
> on
> the page.
>
> Not sure if this is a bug or there is a way of collapsing the tree before
> changing the model.
>
>
>
--
View this message in context:
http://www.nabble.com/Getting-an-IndexOutOfBoundsException-tf2103506.html#a6038583
Sent from the MyFaces - Users forum at Nabble.com.