Re: WicketTester and clicking a tree node

2011-06-02 Thread msalman
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: WicketTester and clicking a tree node

2011-06-02 Thread Pedro Santos
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 mohammad_sal...@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-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





-- 
Pedro Henrique Oliveira dos Santos

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



Re: WicketTester and clicking a tree node

2011-06-02 Thread msalman
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-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: WicketTester and clicking a tree node

2011-05-27 Thread Pedro Santos
You can use the ITreeState API to manipulate the expand/collapsed node
state. Put your code inside a link or a button and call it from Wicket
tester.

On Fri, May 27, 2011 at 10:21 PM, msalman mohammad_sal...@yahoo.com wrote:
 Hi,

 I am trying to simulate/test clicking and expanding tree nodes.  My Tree is
 based off LinkTree class.

 Can some one please provide me the solution or ideas.

 Thanks.

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

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





-- 
Pedro Henrique Oliveira dos Santos

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