Majid,
Since you are using a ChildPropertyTreeModel, the keys are collections
of the Object where the Object is the key at each level.
Note that for performance, you are going to want to cache your
TreeModel someplace since it is likely that it will be accessed at
least once per phase and you don't want to recreate it each time.
-- Blake Sullivan
On Dec 18, 2009, at 2:25 AM, Majid Hussain wrote:
Hi,
My project is build in JSF, Hibernate and Faclets. i m using
trinidad treetable tag to build a tree with multiselection nodes.
Now i m facing a problem to initially selection of the nodes when
page is loaded at the first time. i have tried alot to accomplish
this task, but still unable to retain it. There is an attribute of
"selectedRowKeys" in TreeTable which takes the object of
"RowKeySet", but when i am building the tree in my bean, i don't
know the RowKeys generated, so how do i get my desired RowKeys to be
selected in the tree?
i am trying to provide the code below
myTree.xhtml
<tr:treeTable id="testTreeTable"
value="#{RoleManageBean.tree}"
var="node"
rowSelection="multiple"
initiallyExpanded="true"
rowBandingInterval="1"
horizontalGridVisible="true"
verticalGridVisible="true"
selectedRowKeys="#{
RoleManageBean.selectedRowKeys}">
<f:facet name="actions">
<tr:commandButton
id="treeTableSelectButton" text="Submit Sel." action="#
{RoleManageBean.treeTableSelect}" />
</f:facet>
<f:facet name="nodeStamp">
<tr:column headerText="Name">
<tr:outputText value="#{node.name}"/>
</tr:column>
</f:facet>
<f:facet name="pathStamp">
<tr:outputText value="#{node.name}"/>
</f:facet>
</tr:treeTable>
MyBean.java
public class RoleManageBean implements Serializable {
private TreeModel tree;
private RowKeySet selectedRowKeys = null;
public TreeModel getTree() throws Exception {
Application[] applications = dbops.getAllApplications();
List<Node1> empty1 = Collections.emptyList();
List<Node1> root1 = new ArrayList<Node1>();
List<Node1> apps = new ArrayList<Node1>();
for (Application application : applications) {
Set<ApplicationPage> appPages =
application.getApplicationPage();
List<Node1> pages = new ArrayList<Node1>();
for (ApplicationPage applicationPage : appPages) {
pages.add(new Node1(applicationPage.getPageName(),
String.valueOf(applicationPage.getPageID()), empty1));
}
apps.add(new Node1(application.getApplicationName(),
String.valueOf(application.getHomePage().getPageID()), pages));
}
root1.add(new Node1("Applications", "0", apps));
tree = new ChildPropertyTreeModel(root1, "children");
return tree;
}
public RowKeySet getSelectedRowKeys() {
selectedRowKeys = new RowKeySetImpl();
selectedRowKeys.add(String.valueOf("1,0"));
System.out.println("called");
return selectedRowKeys;
}
public void setSelectedRowKeys(RowKeySet selectedRowKeys) {
this.selectedRowKeys = selectedRowKeys;
}
Any guideline will be appriciated. Thanks in Advance
Majid.