You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by k1dev <k1...@yahoo.com> on 2008/02/27 00:27:54 UTC

Frames with Tree component

Hi!

I have a web application that required to use frames.
It should display different frames depending on tree node clicks.
To achieve this I took the Frames example from wicket examples and added a
Tree component to the left frame of it and tried to change the right panel
depending on clicked nodes.

According to the examples the the parent="_target" attribute has to be set
on every link.
So wrote the following code that does exactly this:

@Override
protected void populateTreeItem(WebMarkupContainer item, int level) {
    super.populateTreeItem(item, level);
    item.visitChildren(Link.class, new IVisitor()
    {
        public Object component(Component component)
        {
            component.add(new SimpleAttributeModifier("target", "_parent"));
            return IVisitor.CONTINUE_TRAVERSAL;
        }
    }); 				
}

Also set LinkType property to of Tree to LinkType.REGULAR to make it work
(did not work with AJAX links).

Then overriden the onNodeClicked method with this code:
    bodyFrame.getFrameTarget().setFrameClass(showFrame);
    // trigger re-rendering of the page
    setResponsePage(bodyFrame);

Now on the first click the right frame disappears then on the second click
the upper frame disappears and the right is displayed.

Can someone tell me how to fix this or provide an example that works.
Thanks.
Bye
Kone

-- 
View this message in context: http://www.nabble.com/Frames-with-Tree-component-tp15702557p15702557.html
Sent from the Wicket - User 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: Frames with Tree component

Posted by k1dev <k1...@yahoo.com>.
Hi!

Sorry, I cound not find out the solution so I've put together a demo
application and attached it.

It was cut-pasted from standard wicket examples. Namely the frames and the
ajax tree example.

Demonstrates the frame "proliferation" and intended parameter passing
between frames that simply does not seems to work for me.

Please try it.

If you click on links that start with "1:test 1." then page 1 is displayed
otherwise page 2.
Page 2 also expects a paramter that is the text of selected node. It tries
to simply display that text but unfortunately every time the default
constructor is called.

Thanks for your help.
Rgds,
Kone


igor.vaynberg wrote:
> 
> looks like your url points to a page that generates another frameset?
> or contains frame tags? it should just point to regular page with
> html/body
> 
> -igor
> 
> 
> On Wed, Feb 27, 2008 at 4:55 AM, k1dev <k1...@yahoo.com> wrote:
>>
>>  Hi!
>>
>>  Thanks for your reply.
>>
>>  Tried out your first tip (couldn't figure out how to do the second tip).
>>  Now the frames are there but the right frame is not replaced but a new
>> frame
>>  created with 0px width beside the others.
>>  Dragging the slider that separates left and right frame reveals the new
>>  frames generated with each clicks.
>>  The following ascii graphic simulates the situation (display with a
>> monotype
>>  font):
>>
>>  +------------------------------+
>>  |top frame                     |
>>  +----+------------+------------+
>>  |left|page2(right)|page1(right)|
>>  +------------------------------+
>>
>>  Here's the code doing this:
>>         public LeftFrame(final BodyFrame index)
>>         {
>>
>>                 final Tree tree = new Tree("treeMenu", new
>> DefaultTreeModel(new
>>  DefaultMutableTreeNode())) {
>>                         @Override
>>                         protected String renderNode(TreeNode node)
>>                         {
>>                                 DefaultMutableTreeNode treeNode =
>> (DefaultMutableTreeNode)node;
>>  // menunode is an interface, implementation can provide a text for the
>> node
>>  to be displayed
>>                                 MenuNode userObject = (MenuNode)
>> treeNode.getUserObject();
>>                                 return userObject.getText();
>>                         }
>>
>>                         @Override
>>                         protected void
>> onNodeLinkClicked(AjaxRequestTarget target,
>>                                         TreeNode node) {
>>                                 DefaultMutableTreeNode thisNode =
>> (DefaultMutableTreeNode)node;
>>
>>                                 Class showFrame = Page1.class;
>>
>>                                 String url = getRequestCycle().urlFor(
>>                                                 new
>> BookmarkablePageRequestTarget(BodyFrame.class, null))
>>                                                 .toString();
>>  // the wicket id for right frame is "rightFrame" that tag's name
>> attribute
>>  is "right", tried both but nothing changed
>>                                
>> target.appendJavascript("window.parent.right.location="+url);
>>
>>                                 if (thisNode != null) {
>>                                         Object userObject =
>> thisNode.getUserObject();
>>                                         if (userObject != null &&
>> userObject instanceof SpecialMenuNode1) {
>>                                                 showFrame = Page2.class;
>>                                         }
>>                                 }
>>
>>                                 // change frame class
>>                                
>> index.getFrameTarget().setFrameClass(showFrame);
>>
>>
>>                                 // trigger re-rendering of the page
>>                                 setResponsePage(index);
>>
>>                         }
>>                 };
>>
>>                 tree.setRootLess(true);
>>                 tree.setLinkType(LinkType.AJAX);
>>                 add(tree);
>>         }
>>
>>  I've stuck here. Any ideas?
>>  Thx,
>>  Rgds,
>>  Kone
>>
>>
>>
>>
>>  igor.vaynberg wrote:
>>  >
>>  > easiest way is to probably use ajax links and in onclick do
>>  >
>> taget.appendjavascript("window.parent.rightframe.location="+urltobookmarkablepage);
>>  >
>>  > second easiest is to override newclick and replace it with a
>>  > bookmarkable link, and append the target dir like you were doing. make
>>  > sure the bookmarkable url is generated for a different pagemap...
>>  >
>>  > -igor
>>  >
>>  > On Tue, Feb 26, 2008 at 3:27 PM, k1dev <k1...@yahoo.com> wrote:
>>  >>
>>  >>  Hi!
>>  >>
>>  >>  I have a web application that required to use frames.
>>  >>  It should display different frames depending on tree node clicks.
>>  >>  To achieve this I took the Frames example from wicket examples and
>> added
>>  >> a
>>  >>  Tree component to the left frame of it and tried to change the right
>>  >> panel
>>  >>  depending on clicked nodes.
>>  >>
>>  >>  According to the examples the the parent="_target" attribute has to
>> be
>>  >> set
>>  >>  on every link.
>>  >>  So wrote the following code that does exactly this:
>>  >>
>>  >>  @Override
>>  >>  protected void populateTreeItem(WebMarkupContainer item, int level)
>> {
>>  >>     super.populateTreeItem(item, level);
>>  >>     item.visitChildren(Link.class, new IVisitor()
>>  >>     {
>>  >>         public Object component(Component component)
>>  >>         {
>>  >>             component.add(new SimpleAttributeModifier("target",
>>  >> "_parent"));
>>  >>             return IVisitor.CONTINUE_TRAVERSAL;
>>  >>         }
>>  >>     });
>>  >>  }
>>  >>
>>  >>  Also set LinkType property to of Tree to LinkType.REGULAR to make it
>>  >> work
>>  >>  (did not work with AJAX links).
>>  >>
>>  >>  Then overriden the onNodeClicked method with this code:
>>  >>     bodyFrame.getFrameTarget().setFrameClass(showFrame);
>>  >>     // trigger re-rendering of the page
>>  >>     setResponsePage(bodyFrame);
>>  >>
>>  >>  Now on the first click the right frame disappears then on the second
>>  >> click
>>  >>  the upper frame disappears and the right is displayed.
>>  >>
>>  >>  Can someone tell me how to fix this or provide an example that
>> works.
>>  >>  Thanks.
>>  >>  Bye
>>  >>  Kone
>>  >>
>>  >>  --
>>  >>  View this message in context:
>>  >>
>> http://www.nabble.com/Frames-with-Tree-component-tp15702557p15702557.html
>>  >>  Sent from the Wicket - User 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
>>  >>
>>  >>
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>  > For additional commands, e-mail: users-help@wicket.apache.org
>>  >
>>  >
>>  >
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/Frames-with-Tree-component-tp15702557p15712660.html
>>
>>
>> Sent from the Wicket - User 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
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 
http://www.nabble.com/file/p15728275/frames-example.zip frames-example.zip 
-- 
View this message in context: http://www.nabble.com/Frames-with-Tree-component-tp15702557p15728275.html
Sent from the Wicket - User 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: Frames with Tree component

Posted by Igor Vaynberg <ig...@gmail.com>.
looks like your url points to a page that generates another frameset?
or contains frame tags? it should just point to regular page with
html/body

-igor


On Wed, Feb 27, 2008 at 4:55 AM, k1dev <k1...@yahoo.com> wrote:
>
>  Hi!
>
>  Thanks for your reply.
>
>  Tried out your first tip (couldn't figure out how to do the second tip).
>  Now the frames are there but the right frame is not replaced but a new frame
>  created with 0px width beside the others.
>  Dragging the slider that separates left and right frame reveals the new
>  frames generated with each clicks.
>  The following ascii graphic simulates the situation (display with a monotype
>  font):
>
>  +------------------------------+
>  |top frame                     |
>  +----+------------+------------+
>  |left|page2(right)|page1(right)|
>  +------------------------------+
>
>  Here's the code doing this:
>         public LeftFrame(final BodyFrame index)
>         {
>
>                 final Tree tree = new Tree("treeMenu", new DefaultTreeModel(new
>  DefaultMutableTreeNode())) {
>                         @Override
>                         protected String renderNode(TreeNode node)
>                         {
>                                 DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
>  // menunode is an interface, implementation can provide a text for the node
>  to be displayed
>                                 MenuNode userObject = (MenuNode) treeNode.getUserObject();
>                                 return userObject.getText();
>                         }
>
>                         @Override
>                         protected void onNodeLinkClicked(AjaxRequestTarget target,
>                                         TreeNode node) {
>                                 DefaultMutableTreeNode thisNode = (DefaultMutableTreeNode)node;
>
>                                 Class showFrame = Page1.class;
>
>                                 String url = getRequestCycle().urlFor(
>                                                 new BookmarkablePageRequestTarget(BodyFrame.class, null))
>                                                 .toString();
>  // the wicket id for right frame is "rightFrame" that tag's name attribute
>  is "right", tried both but nothing changed
>                                 target.appendJavascript("window.parent.right.location="+url);
>
>                                 if (thisNode != null) {
>                                         Object userObject = thisNode.getUserObject();
>                                         if (userObject != null && userObject instanceof SpecialMenuNode1) {
>                                                 showFrame = Page2.class;
>                                         }
>                                 }
>
>                                 // change frame class
>                                 index.getFrameTarget().setFrameClass(showFrame);
>
>
>                                 // trigger re-rendering of the page
>                                 setResponsePage(index);
>
>                         }
>                 };
>
>                 tree.setRootLess(true);
>                 tree.setLinkType(LinkType.AJAX);
>                 add(tree);
>         }
>
>  I've stuck here. Any ideas?
>  Thx,
>  Rgds,
>  Kone
>
>
>
>
>  igor.vaynberg wrote:
>  >
>  > easiest way is to probably use ajax links and in onclick do
>  > taget.appendjavascript("window.parent.rightframe.location="+urltobookmarkablepage);
>  >
>  > second easiest is to override newclick and replace it with a
>  > bookmarkable link, and append the target dir like you were doing. make
>  > sure the bookmarkable url is generated for a different pagemap...
>  >
>  > -igor
>  >
>  > On Tue, Feb 26, 2008 at 3:27 PM, k1dev <k1...@yahoo.com> wrote:
>  >>
>  >>  Hi!
>  >>
>  >>  I have a web application that required to use frames.
>  >>  It should display different frames depending on tree node clicks.
>  >>  To achieve this I took the Frames example from wicket examples and added
>  >> a
>  >>  Tree component to the left frame of it and tried to change the right
>  >> panel
>  >>  depending on clicked nodes.
>  >>
>  >>  According to the examples the the parent="_target" attribute has to be
>  >> set
>  >>  on every link.
>  >>  So wrote the following code that does exactly this:
>  >>
>  >>  @Override
>  >>  protected void populateTreeItem(WebMarkupContainer item, int level) {
>  >>     super.populateTreeItem(item, level);
>  >>     item.visitChildren(Link.class, new IVisitor()
>  >>     {
>  >>         public Object component(Component component)
>  >>         {
>  >>             component.add(new SimpleAttributeModifier("target",
>  >> "_parent"));
>  >>             return IVisitor.CONTINUE_TRAVERSAL;
>  >>         }
>  >>     });
>  >>  }
>  >>
>  >>  Also set LinkType property to of Tree to LinkType.REGULAR to make it
>  >> work
>  >>  (did not work with AJAX links).
>  >>
>  >>  Then overriden the onNodeClicked method with this code:
>  >>     bodyFrame.getFrameTarget().setFrameClass(showFrame);
>  >>     // trigger re-rendering of the page
>  >>     setResponsePage(bodyFrame);
>  >>
>  >>  Now on the first click the right frame disappears then on the second
>  >> click
>  >>  the upper frame disappears and the right is displayed.
>  >>
>  >>  Can someone tell me how to fix this or provide an example that works.
>  >>  Thanks.
>  >>  Bye
>  >>  Kone
>  >>
>  >>  --
>  >>  View this message in context:
>  >> http://www.nabble.com/Frames-with-Tree-component-tp15702557p15702557.html
>  >>  Sent from the Wicket - User 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
>  >>
>  >>
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>  >
>
>  --
>  View this message in context: http://www.nabble.com/Frames-with-Tree-component-tp15702557p15712660.html
>
>
> Sent from the Wicket - User 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
>
>

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


Re: Frames with Tree component

Posted by k1dev <k1...@yahoo.com>.
Hi!

Thanks for your reply.

Tried out your first tip (couldn't figure out how to do the second tip).
Now the frames are there but the right frame is not replaced but a new frame
created with 0px width beside the others.
Dragging the slider that separates left and right frame reveals the new
frames generated with each clicks.
The following ascii graphic simulates the situation (display with a monotype
font):

+------------------------------+
|top frame                     |
+----+------------+------------+
|left|page2(right)|page1(right)|
+------------------------------+

Here's the code doing this:
	public LeftFrame(final BodyFrame index)
	{
		
		final Tree tree = new Tree("treeMenu", new DefaultTreeModel(new
DefaultMutableTreeNode())) {
			@Override
			protected String renderNode(TreeNode node)
			{
				DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)node;
// menunode is an interface, implementation can provide a text for the node
to be displayed
				MenuNode userObject = (MenuNode) treeNode.getUserObject();
				return userObject.getText();
			}

			@Override
			protected void onNodeLinkClicked(AjaxRequestTarget target,
					TreeNode node) {
				DefaultMutableTreeNode thisNode = (DefaultMutableTreeNode)node;
				
				Class showFrame = Page1.class;

				String url = getRequestCycle().urlFor(
						new BookmarkablePageRequestTarget(BodyFrame.class, null))
						.toString(); 
// the wicket id for right frame is "rightFrame" that tag's name attribute
is "right", tried both but nothing changed
				target.appendJavascript("window.parent.right.location="+url);
				
				if (thisNode != null) {
					Object userObject = thisNode.getUserObject();
					if (userObject != null && userObject instanceof SpecialMenuNode1) {
						showFrame = Page2.class;
					}
				}

				// change frame class
				index.getFrameTarget().setFrameClass(showFrame);

				// trigger re-rendering of the page
				setResponsePage(index);

			}
		};		

		tree.setRootLess(true);
		tree.setLinkType(LinkType.AJAX);
		add(tree);
	}

I've stuck here. Any ideas?
Thx,
Rgds,
Kone


igor.vaynberg wrote:
> 
> easiest way is to probably use ajax links and in onclick do
> taget.appendjavascript("window.parent.rightframe.location="+urltobookmarkablepage);
> 
> second easiest is to override newclick and replace it with a
> bookmarkable link, and append the target dir like you were doing. make
> sure the bookmarkable url is generated for a different pagemap...
> 
> -igor
> 
> On Tue, Feb 26, 2008 at 3:27 PM, k1dev <k1...@yahoo.com> wrote:
>>
>>  Hi!
>>
>>  I have a web application that required to use frames.
>>  It should display different frames depending on tree node clicks.
>>  To achieve this I took the Frames example from wicket examples and added
>> a
>>  Tree component to the left frame of it and tried to change the right
>> panel
>>  depending on clicked nodes.
>>
>>  According to the examples the the parent="_target" attribute has to be
>> set
>>  on every link.
>>  So wrote the following code that does exactly this:
>>
>>  @Override
>>  protected void populateTreeItem(WebMarkupContainer item, int level) {
>>     super.populateTreeItem(item, level);
>>     item.visitChildren(Link.class, new IVisitor()
>>     {
>>         public Object component(Component component)
>>         {
>>             component.add(new SimpleAttributeModifier("target",
>> "_parent"));
>>             return IVisitor.CONTINUE_TRAVERSAL;
>>         }
>>     });
>>  }
>>
>>  Also set LinkType property to of Tree to LinkType.REGULAR to make it
>> work
>>  (did not work with AJAX links).
>>
>>  Then overriden the onNodeClicked method with this code:
>>     bodyFrame.getFrameTarget().setFrameClass(showFrame);
>>     // trigger re-rendering of the page
>>     setResponsePage(bodyFrame);
>>
>>  Now on the first click the right frame disappears then on the second
>> click
>>  the upper frame disappears and the right is displayed.
>>
>>  Can someone tell me how to fix this or provide an example that works.
>>  Thanks.
>>  Bye
>>  Kone
>>
>>  --
>>  View this message in context:
>> http://www.nabble.com/Frames-with-Tree-component-tp15702557p15702557.html
>>  Sent from the Wicket - User 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
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Frames-with-Tree-component-tp15702557p15712660.html
Sent from the Wicket - User 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: Frames with Tree component

Posted by Igor Vaynberg <ig...@gmail.com>.
easiest way is to probably use ajax links and in onclick do
taget.appendjavascript("window.parent.rightframe.location="+urltobookmarkablepage);

second easiest is to override newclick and replace it with a
bookmarkable link, and append the target dir like you were doing. make
sure the bookmarkable url is generated for a different pagemap...

-igor

On Tue, Feb 26, 2008 at 3:27 PM, k1dev <k1...@yahoo.com> wrote:
>
>  Hi!
>
>  I have a web application that required to use frames.
>  It should display different frames depending on tree node clicks.
>  To achieve this I took the Frames example from wicket examples and added a
>  Tree component to the left frame of it and tried to change the right panel
>  depending on clicked nodes.
>
>  According to the examples the the parent="_target" attribute has to be set
>  on every link.
>  So wrote the following code that does exactly this:
>
>  @Override
>  protected void populateTreeItem(WebMarkupContainer item, int level) {
>     super.populateTreeItem(item, level);
>     item.visitChildren(Link.class, new IVisitor()
>     {
>         public Object component(Component component)
>         {
>             component.add(new SimpleAttributeModifier("target", "_parent"));
>             return IVisitor.CONTINUE_TRAVERSAL;
>         }
>     });
>  }
>
>  Also set LinkType property to of Tree to LinkType.REGULAR to make it work
>  (did not work with AJAX links).
>
>  Then overriden the onNodeClicked method with this code:
>     bodyFrame.getFrameTarget().setFrameClass(showFrame);
>     // trigger re-rendering of the page
>     setResponsePage(bodyFrame);
>
>  Now on the first click the right frame disappears then on the second click
>  the upper frame disappears and the right is displayed.
>
>  Can someone tell me how to fix this or provide an example that works.
>  Thanks.
>  Bye
>  Kone
>
>  --
>  View this message in context: http://www.nabble.com/Frames-with-Tree-component-tp15702557p15702557.html
>  Sent from the Wicket - User 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
>
>

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