You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by leroudav <da...@hotmail.com> on 2008/08/29 15:38:34 UTC

Can't include DownloadLink in LinkTree

Hi everyone!
First of all, thanks for helping 2 french wicket padawan developers :-)

We tried to make a Tree for our wicket application, but we encountered a
problem.
The tree is created, with simple file names, but we can't redirect the click
to the download link, and that's a big problem. We saw that if we try to add
an ExternalLink to the Tree, it works (see comments in code).

This is the source (simplified for the post):

LinkTree tree = new LinkTree( "tree", new DefaultTreeModel( root ) ) {

			@Override
			protected Component newNodeComponent( String id, IModel model ) {
				return new LinkIconPanel( id, model, this ) {
					@Override
					protected Component newContentComponent( String componentId, BaseTree
tree, IModel model ) {
						Object obj = ( ( DefaultMutableTreeNode )model.getObject()
).getUserObject();
						if( obj instanceof AbstractLink ) {
							// return new ExternalLink( componentId, "http://www.google.fr",
"Example ExternalLink" );
							DownloadLink dl = new DownloadLink( componentId, new File(
"toto-example.png" ), "Example DownloadLink" );
							return dl;
						}
						return new Label( componentId, model.getObject().toString() );
					}
				};
			}
		};

As you can see, we override the method newNodeComponent(.,.) for allowing
overriding the method newContentComponent(.,.,.). The problem is that we
can't see the name of the file nor the DownloadLink, even if we can redirect
a click on an ExternalLink given to the LinkTree.

We hope our explanations were clear, and will permit you helping us.
-- 
View this message in context: http://www.nabble.com/Can%27t-include-DownloadLink-in-LinkTree-tp19220120p19220120.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: Can't include DownloadLink in LinkTree

Posted by leroudav <da...@hotmail.com>.
Thanks for the help. We just tried your solution, but had a problem again.
The panel needs a wicket:id, but we can't provide it. We will try again
monday morning (that's the end of the day in Europe).

Thanks again. We hope that will help us!


Matej Knopp-2 wrote:
> 
> You might want to try putting the link to a panel and returning panel
> from newContentComponent();
> 
> -Matej
> 
> 

-- 
View this message in context: http://www.nabble.com/Can%27t-include-DownloadLink-in-LinkTree-tp19220120p19221801.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: Can't include DownloadLink in LinkTree

Posted by Matej Knopp <ma...@gmail.com>.
You might want to try putting the link to a panel and returning panel
from newContentComponent();

-Matej

On Fri, Aug 29, 2008 at 3:38 PM, leroudav <da...@hotmail.com> wrote:
>
> Hi everyone!
> First of all, thanks for helping 2 french wicket padawan developers :-)
>
> We tried to make a Tree for our wicket application, but we encountered a
> problem.
> The tree is created, with simple file names, but we can't redirect the click
> to the download link, and that's a big problem. We saw that if we try to add
> an ExternalLink to the Tree, it works (see comments in code).
>
> This is the source (simplified for the post):
>
> LinkTree tree = new LinkTree( "tree", new DefaultTreeModel( root ) ) {
>
>                        @Override
>                        protected Component newNodeComponent( String id, IModel model ) {
>                                return new LinkIconPanel( id, model, this ) {
>                                        @Override
>                                        protected Component newContentComponent( String componentId, BaseTree
> tree, IModel model ) {
>                                                Object obj = ( ( DefaultMutableTreeNode )model.getObject()
> ).getUserObject();
>                                                if( obj instanceof AbstractLink ) {
>                                                        // return new ExternalLink( componentId, "http://www.google.fr",
> "Example ExternalLink" );
>                                                        DownloadLink dl = new DownloadLink( componentId, new File(
> "toto-example.png" ), "Example DownloadLink" );
>                                                        return dl;
>                                                }
>                                                return new Label( componentId, model.getObject().toString() );
>                                        }
>                                };
>                        }
>                };
>
> As you can see, we override the method newNodeComponent(.,.) for allowing
> overriding the method newContentComponent(.,.,.). The problem is that we
> can't see the name of the file nor the DownloadLink, even if we can redirect
> a click on an ExternalLink given to the LinkTree.
>
> We hope our explanations were clear, and will permit you helping us.
> --
> View this message in context: http://www.nabble.com/Can%27t-include-DownloadLink-in-LinkTree-tp19220120p19220120.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