Hi, I wanted to add some custom tags in the cells of my TreeTable, but if I
return html code in the public String renderNode(TreeNode node) method of my
column,
the tags are stripped.
I found this idea to do what I want, it works but it's not very well :
I had to replace the TreeFragment used in TreeTable by my own TreeFragment,
and set the flag "FLAG_ESCAPE_MODEL_STRINGS" to false on the Label in the
Fragment
To replace the TreeFragment I had to extend the TreeTable. Here is what I
did (I'm using Wicket 1.2.6)
private static class MyTree extends TreeTable
{
public MyTree(String id, TreeModel model, IColumn columns[])
{
super(id, model, columns);
}
protected Component newTreePanel(MarkupContainer parent, String id,
TreeNode node, int level, IRenderNodeCallback renderNodeCallback)
{
return new TreeFragment(id, node, level,
renderNodeCallback);
}
public class TreeFragment extends Fragment
{
private static final long serialVersionUID = 1L;
public TreeFragment(String id, final TreeNode node, int level,
final
TreeTable.IRenderNodeCallbackrenderNodeCallback)
{
super(id, "fragment");
add(newIndentation(this, "indent", node, level));
add(newJunctionLink(this, "link", "image", node));
MarkupContainer nodeLink = newNodeLink(this, "nodeLink",
node);
add(nodeLink);
nodeLink.add(newNodeIcon(nodeLink, "icon", node));
Label child = new Label("label", new AbstractReadOnlyModel()
{
private static final long serialVersionUID = 1L;
/**
* @see wicket.model.AbstractReadOnlyModel#getObject(
wicket.Component)
*/
public Object getObject(Component c)
{
return renderNodeCallback.renderNode(node);
}
});
child.setEscapeModelStrings(false);
nodeLink.add(child);
}
}
}
I think there is something strange in this API : the ida of using the
TreeModel was great, but why not using something close to the
TreeCellRenderer so it would be possible to have true components in the
cells
Matthieu
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user