Sorry, I've seen you're using DefaultMutableTreeNode when you're
converting your structure to the tree.
So you have to cast to the TreeNode implementation:
rowClickSelect(node, ((DefaultMutableTreeNode)node).getUserObject());
Sven
On 04/25/2012 12:30 AM, Pablo Diaz wrote:
Hi, thank you for your answer.
I have 1.5.3 Wicket versión and I haven't the function getUserObject() to
use in TreeNode Object.
2012/4/24 Sven Meier<[email protected]>
Hi,
protected void onEvent(final AjaxRequestTarget target) {
final TreeNode node = (TreeNode) item.getDefaultModelObject();
rowClickSelect(node, item.getDefaultModelObject());
}
the item's model object is the TreeNode. You probably want to get hold on
the node's user object:
rowClickSelect(node, node.getUserObject());
Hope this helps
Sven
On 04/24/2012 08:23 PM, Pablo Díaz wrote:
Hi,
I'm trying to get the content of a cell when I click on it?.
I've the next code to create de treetable:
|public class DocTreeTable extends TreeTable {
private static final long serialVersionUID = 8799304134058383380L;
public DocTreeTable(String id, TreeModel model) {
super(id, model, createColumns());
}
private static IColumn[] createColumns() {
IColumn columns[] = new IColumn[] {
new PropertyRenderableColumn<**Integer>(new
ColumnLocation(
Alignment.LEFT, 3, Unit.EM), "Id",
"userObject.idDoc"),
new PropertyTreeColumn<String>(new ColumnLocation(
Alignment.MIDDLE, 50, Unit.PROPORTIONAL),
"Fichero",
"userObject.data.name"),
new PropertyRenderableColumn<**String>(new ColumnLocation(
Alignment.MIDDLE, 25, Unit.PROPORTIONAL),
"Descripción", "userObject.data.desc"),
new PropertyRenderableColumn<**String>(new ColumnLocation(
Alignment.RIGHT, 25, Unit.PERCENT), "Fase",
"userObject.data.phase.data.**name<http://userObject.data.phase.data.name>"),
};
return columns;
}
@Override
protected void populateTreeItem(final WebMarkupContainer item,
final int level) {
super.populateTreeItem(item, level);
item.add(new AjaxEventBehavior("onclick") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(final AjaxRequestTarget target) {
final TreeNode node = (TreeNode)
item.getDefaultModelObject();
rowClickSelect(node,item.**getDefaultModelObject());
}
});
}
private void rowClickSelect(TreeNode node, Object obj) {
node.toString();
if (this.getTreeState().**isNodeSelected(node)) {
DocTO doc = (DocTO) obj; // *HERE IS THE ERROR, AND I DON'T
KNOW HOW SOLVE IT.*
if (node.isLeaf())
getWebPage()
.setResponsePage(
new DocViewPage(doc));
}
}
}|
And I have de next code to create the page with treetable, after reading
the database content of a docs:
|
public DocsPage(PageParameters pageParameters) {
super(pageParameters);
DocTreeTable() tree = new DocTreeTable("docs", createTreeModel());
tree.setRootLess(false);
tree.getTreeState().**setAllowSelectMultiple(false);
add(tree);
}
public DocsPage() {
this(null);
}
private TreeModel createTreeModel(){
List docs = docService.findMainFolders();
return convertToTreeModel(docs);
}
private TreeModel convertToTreeModel(List<**Object> list){
TreeModel model = null;
DefaultMutableTreeNode rootNode = new
DefaultMutableTreeNode((DocTO)**list.get(0));
addNode(rootNode, list);
model = new DefaultTreeModel(rootNode);
return model;
}
private void addNode(DefaultMutableTreeNode parent, List sub){
for(Object obj : sub){
if(((DocTO)obj).getData().**getFolder()){
DefaultMutableTreeNode child = new
DefaultMutableTreeNode((DocTO)**obj);
parent.add(child);
addNode(child, docService.findFolderChilds((**DocTO)obj));
}else{
DefaultMutableTreeNode child = new
DefaultMutableTreeNode((DocTO)**obj);
parent.add(child);
}
}
}
|
Thank you in advance,
Pablo.
------------------------------**------------------------------**---------
To unsubscribe, e-mail:
users-unsubscribe@wicket.**apache.org<[email protected]>
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]