final TreeTable tree = new TreeTable("treeTable", buildTreeModel(lll, cccc), columns) {
protected void populateTreeItem(WebMarkupContainer item, int level) {
super.populateTreeItem(item, level);
final TreeNode node = (TreeNode)item.getDefaultModelObject();
item.add(new AbstractBehavior() {
private static final long serialVersionUID = 1L;
//重写onComponentTag方法
public void onComponentTag(Component component, ComponentTag tag)
{
super.onComponentTag(component, tag);
if (getTreeState().isNodeSelected(node)) {
tag.put("style", "background-color:#CCCCCC");//背景颜色设为深灰色
} else {
tag.put("class", "row");
}
}
});
}
};
//控制多重选择
tree.getTreeState().setAllowSelectMultiple(false);