You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ElenaStoll <es...@widas-crosslink.de> on 2009/04/22 16:22:31 UTC

LinkTree will not be updated

I have a problem with LinkTree in Wicket, namely : 
I have a LinkTree where NodeComponent a TreeLinkIconPanel is.
TreeLinkIconPanel is a subclass of LinkIconPanel.

public TreeLinkIconPanel(String id, IModel model, BaseTree tree) {
	super(id, model, tree);
}

Where a content as a label and image as a normal Icon:

protected Component newContentComponent(String componentId, BaseTree tree,
			IModel model) {
	...
        if (model.getObject() instanceof ProcessNode) {
	      lLabel = new Label(componentId, ((ProcessNode) model.getObject())
					.getName());
	}
        ...
        return lLabel;
}

@Override
protected Component newImageComponent(String componentId, BaseTree tree,
			IModel model) {
	Image lImage=(Image)super.newImageComponent(componentId, tree, model);
	if (model.getObject() instanceof ProcessNode) {
		lImage = new Image(componentId,((ProcessNode)model.getObject   
                              ()).getState());
	}
        ...
	return lImage;
	}


The model is not updated, when the Tree to AjaxRequestTarget added.
And when ClickEven must this tree, in my case image the tree's, refresh
But what is not done:

protected void onNodeLinkClicked(TreeNode node, BaseTree tree,
			AjaxRequestTarget target) {
	super.onNodeLinkClicked(node, tree, target);
	if (node instanceof ProcessNode) {
		((ProcessNode)node).setStateGreen();
		fireProcessClickEvent(target);
	} else if (node instanceof ActivityNode) {
		((ActivityNode)node).setStateYellow();
		fireActivityClickEvent(((ActivityNode) node).getName(), 
                        target);
	}
}

Here, this event is received:

tree.addTreeListener(new TreeListener() {

	@Override
	public void onActivityClicked(String nameOfNode,AjaxRequestTarget 
                                                        target){
		...
		target.addComponent(tree);
	}
	@Override
	public void onProcessClicked(AjaxRequestTarget target) {
		... 
                target.addComponent(tree);
	}

});


But if I befor the tree, the new model set, then it works:

tree.addTreeListener(new TreeListener() {

	@Override
	public void onActivityClicked(String nameOfNode,AjaxRequestTarget 
                                                        target){
		...
                tree.setModel(new Model((Serializable) new DefaultTreeModel
                                                  (processNode)));
		target.addComponent(tree);
	}
	@Override
	public void onProcessClicked(AjaxRequestTarget target) {
		... 
                tree.setModel(new Model((Serializable) new DefaultTreeModel
                                                  (processNode)));
                target.addComponent(tree);
	}

});
It is of course not as nice and not so expected. 
If someone can help me - that would be very nice. 
Thanks in advance.
Elena




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: LinkTree will not be updated

Posted by ElenaStoll <es...@widas-crosslink.de>.
James McLaughlin <jomclaughlin <at> gmail.com> writes:
> 
> add tree.updateTree(target) before adding the tree to the target.
> 
> hth,
> jim

Thank you for your quick response, but your proposal has not helped me, 
unfortunately. The tree remains as it is and it will not be updated.
Thanks

elena






---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: LinkTree will not be updated

Posted by James McLaughlin <jo...@gmail.com>.
add tree.updateTree(target) before adding the tree to the target.

hth,
jim


>
> tree.addTreeListener(new TreeListener() {
>
>        @Override
>        public void onActivityClicked(String nameOfNode,AjaxRequestTarget
>                                                        target){
>                ...
>                target.addComponent(tree);
>        }
>        @Override
>        public void onProcessClicked(AjaxRequestTarget target) {
>                ...
>                target.addComponent(tree);
>        }
>
> });
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>