rich tree : java.lang.IllegalArgumentException: In AbstractTreeDataModel rowIndex must be -1. any 1 heared of it b4 ??
mmrs Apr 1, 2010 10:08 AMHi,
i'm trying to build a dynamic tree in my jsf web apps. and i used rich faces.
i took an example from the rich faces live demo and try it in my page .. the tree appear fine.
but when i click on any node the following exception appear :
java.lang.IllegalArgumentException: In AbstractTreeDataModel rowIndex must be -1.
at org.richfaces.model.AbstractTreeDataModel.setRowIndex(AbstractTreeDataModel.java:52)
at org.ajax4jsf.component.UIDataAdaptor.setRowIndex(UIDataAdaptor.java:289)
at javax.faces.component.UIData.visitColumnsAndRows(UIData.java:1544)
at javax.faces.component.UIData.visitTree(UIData.java:1212)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
at javax.faces.component.UIForm.visitTree(UIForm.java:333)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1457)
at javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:869)
at org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:439)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:131)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
at org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:107)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
actually on any submission in the page the above exception is thrown.
the code in jsp page :
------------------------------------------------------------------------------------
<f:view>
<h:form>
<rich:tree id="accountsTreee" style="width:300px" rendered="true"
nodeSelectListener="#{accountsChartIterators.processSelection}"
reRender="selectedNode" ajaxSubmitSelection="true" switchType="client"
value="#{accountsChartIterators.treeNode}" var="item" ajaxKeys="#{null}" >
</rich:tree>
</h:form>
</f:view>
------------------------------------------------------------------------------------
and the bean code :
------------------------------------------------------------------------------------
private TreeNode rootNode = null;
private List<String> selectedNodeChildren = new ArrayList<String>();
private String nodeTitle;
private static final String DATA_PATH = "\\WEB-INF\\simple-tree-data.properties";
public TreeNode getTreeNode() {
if (rootNode == null) {
loadTree();
}
return rootNode;
}
private void loadTree() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
try {
Properties properties = new Properties();
properties.load(dataStream);
rootNode = new TreeNodeImpl();
addNodes(null, rootNode, properties);
} catch (Exception e) {
logger.info("x : "+e.getMessage(), e);
} finally {
if (dataStream != null) {
try {
dataStream.close();
} catch (Exception e) {
logger.info("xx : "+e.getMessage(), e);
}
}
}
}
private void addNodes(String path, TreeNode node, Properties properties) {
boolean end = false;
int counter = 1;
while (!end) {
String key = path != null ? path + '.' + counter : String.valueOf(counter);
String value = properties.getProperty(key);
if (value != null) {
TreeNodeImpl nodeImpl = new TreeNodeImpl();
nodeImpl.setData(value);
node.addChild(new Integer(counter), nodeImpl);
addNodes(key, nodeImpl, properties);
counter++;
} else {
end = true;
}
}
}
public void processSelection(NodeSelectedEvent event) {
logger.info("processing Selection");
try{
HtmlTree tree = (HtmlTree) event.getComponent();
nodeTitle = (String) tree.getRowData();
selectedNodeChildren.clear();
TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
if (currentNode.isLeaf()){
selectedNodeChildren.add((String)currentNode.getData());
}else
{
Iterator<Map.Entry<Object, TreeNode>> it = currentNode.getChildren();
while (it!=null &&it.hasNext()) {
Map.Entry<Object, TreeNode> entry = it.next();
selectedNodeChildren.add(entry.getValue().getData().toString());
}
}
}catch(Exception e){
logger.info("xx : ");
logger.info(e.getMessage(),e);
}
}
------------------------------------------------------------------------------------
I google it but didn't find results
so any 1 faces this this b4 ??
many thanks
MMRS