You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by msalman <mo...@yahoo.com> on 2011/06/02 18:53:59 UTC

Re: WicketTester and clicking a tree node

Pedro, thanks for your response.

I solved my problem in the following way:


For my derived DefaultMutableTreeNode class I added an Ajax link element:


public class CheckBoxSelectableTreeItem 
extends DefaultMutableTreeNode
{
   ....
   protected AjaxLink clickLink;  // for testing the expand/collapse link

	public AjaxLink getClickLink() {
		return clickLink;
	}




	public void setClickLink(AjaxLink clickLink) {
		this.clickLink = clickLink;
	}

   ....

}



For my tree class I overrode the newJunctionLink  method like this:


public class CheckBoxTree extends LinkTree
{
  .....

	@Override
	protected Component newJunctionLink(MarkupContainer parent, final String
id, final Object node)
	{
		AjaxLink link = (AjaxLink) super.newJunctionLink(parent, id, node);
		
		
		((CheckBoxSelectableTreeItem)node).setClickLink(link);
		
		return link;
	}
  ....

}



So in the test when you have the node you can open (expand) it this way:

		CheckBoxSelectableTreeItem node= .... get Node
		
		AjaxLink nodeLink = node.getClickLink();
		
		tester.executeAjaxEvent(nodeLink, "onclick");







--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-and-clicking-a-tree-node-tp3556724p3568831.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: WicketTester and clicking a tree node

Posted by Pedro Santos <pe...@gmail.com>.
Hi Mohammad, nice you created the test case. I just would recommend to
don't make any reference from your domains objects (TreeNode) to view
ones (AjaxLink) because they are usually packaged in different places.
Take a look at how I created a similar test:

http://svn.apache.org/repos/asf/wicket/releases/wicket-1.4.17/wicket-extensions/src/test/java/org/apache/wicket/extensions/markup/html/tree/MoveChildToParentNodeMarkedForRecreationTest.java

On Thu, Jun 2, 2011 at 1:53 PM, msalman <mo...@yahoo.com> wrote:
> Pedro, thanks for your response.
>
> I solved my problem in the following way:
>
>
> For my derived DefaultMutableTreeNode class I added an Ajax link element:
>
>
> public class CheckBoxSelectableTreeItem
> extends DefaultMutableTreeNode
> {
>   ....
>   protected AjaxLink clickLink;  // for testing the expand/collapse link
>
>        public AjaxLink getClickLink() {
>                return clickLink;
>        }
>
>
>
>
>        public void setClickLink(AjaxLink clickLink) {
>                this.clickLink = clickLink;
>        }
>
>   ....
>
> }
>
>
>
> For my tree class I overrode the newJunctionLink  method like this:
>
>
> public class CheckBoxTree extends LinkTree
> {
>  .....
>
>        @Override
>        protected Component newJunctionLink(MarkupContainer parent, final String
> id, final Object node)
>        {
>                AjaxLink link = (AjaxLink) super.newJunctionLink(parent, id, node);
>
>
>                ((CheckBoxSelectableTreeItem)node).setClickLink(link);
>
>                return link;
>        }
>  ....
>
> }
>
>
>
> So in the test when you have the node you can open (expand) it this way:
>
>                CheckBoxSelectableTreeItem node= .... get Node
>
>                AjaxLink nodeLink = node.getClickLink();
>
>                tester.executeAjaxEvent(nodeLink, "onclick");
>
>
>
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-and-clicking-a-tree-node-tp3556724p3568831.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Pedro Henrique Oliveira dos Santos

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


Re: WicketTester and clicking a tree node

Posted by msalman <mo...@yahoo.com>.
Hi Pedro.

But how do you get the link's id i.e., "moveC3ToC2"?

I added all the code to the Node and Tree derive classes to so that I could
get the link id.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-and-clicking-a-tree-node-tp3556724p3569317.html
Sent from the Users forum mailing list archive at Nabble.com.

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