Anna,

Third parameter ( "Example DownloadLink" in your case) is just an
alternative fine name: see onClick() method to see how it is used. Can
you try following panel?

import java.io.File;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.DownloadLink;
import org.apache.wicket.markup.html.panel.Panel;

public class DownLoadLinkPanel extends Panel {

        private static final long serialVersionUID = 1L;

        /**
         * @param id
         */
        public DownLoadLinkPanel(String id) {
                super(id);
                DownloadLink dl = new DownloadLink( "download", new File(
                "wat-application/images/addmore.jpg" ), "AddMore.jpg" );        
                add(dl);
                dl.add(new Label("text", "Example DownloadLink"));
        }

}

----

DownLoadLinkPanel.html

<wicket:panel>
<a wicket:id="download"><span wicket:id="text"></span></a>
</wicket:panel>

-------------------

and then

return new DownLoadLinkPanel(componentId);

Ernesto

On Tue, Jun 22, 2010 at 10:43 PM, Anna Simbirtsev <[email protected]> wrote:
> I think the problem is in this: DownloadLink dl = new DownloadLink( id, new
> File( "wat-application/images/addmore.jpg" ), "Example DownloadLink" );
>
> This does not produce any output.
>
> On Tue, Jun 22, 2010 at 4:18 PM, Ernesto Reinaldo Barreiro <
> [email protected]> wrote:
>
>> Not sure but I think if you put Link on a <span> you will have a
>> generated markup <span onclick=""></span> which might not be visible.
>> Why don't you use a panel like following?
>>
>> <wicket:panel>
>>   <a wicket:id="download"><span wicket:id="text"></span></a>
>> </wicket:panel>
>>
>> Ernesto
>>
>>
>> On Tue, Jun 22, 2010 at 9:09 PM, Anna Simbirtsev <[email protected]>
>> wrote:
>> > Thanks
>> >
>> > Do you know why if I add DownloadLink directly without the panel, its
>> > invisible?
>> >
>> > On Tue, Jun 22, 2010 at 2:55 PM, Ernesto Reinaldo Barreiro <
>> > [email protected]> wrote:
>> >
>> >> Your MyPanel extends Form and Form should be applied to <form> tag not
>> >> <span> tag.
>> >>
>> >> Ernesto
>> >>
>> >> On Tue, Jun 22, 2010 at 7:50 PM, Anna Simbirtsev <[email protected]
>> >
>> >> wrote:
>> >> > Hi,
>> >> >
>> >> > I am trying to extend newNodeComponent on a LinkTree to make nodes
>> >> > DownLoadLink.
>> >> >
>> >> > tree = new LinkTree("tree", createTreeModel()){
>> >> >
>> >> > private static final long serialVersionUID = 1L;
>> >> >
>> >> > @Override
>> >> >             protected Component newNodeComponent( String id, IModel
>> model
>> >> )
>> >> > {
>> >> >                     return new LinkIconPanel( id, model, this ) {
>> >> >
>> >> >                        private static final long serialVersionUID =
>> 1L;
>> >> >
>> >> > @Override
>> >> >                             protected Component newContentComponent(
>> >> String
>> >> > componentId, BaseTree tree, IModel model ) {
>> >> >                                     Object obj = ( (
>> >> DefaultMutableTreeNode
>> >> > )model.getObject() ).getUserObject();
>> >> >                                     if( !obj.equals("1:subtree...,
>> >> > 2:subtree..., 3:subtree...") ) {
>> >> >                                     LOGGER.debug("link");
>> >> >                                     return new MyPanel(componentId);
>> >> >                                     }
>> >> >
>> >> >                                     return new Label( componentId,
>> >> > model.getObject().toString() );
>> >> >                             }
>> >> >
>> >> >                     };
>> >> >             }
>> >> >  };
>> >> >     form.add(tree);
>> >> >     tree.getTreeState().collapseAll();
>> >> >
>> >> >
>> >> >
>> >> >       public class MyPanel extends Form   {
>> >> >
>> >> >
>> >> >         private static final long serialVersionUID = 1L;
>> >> >
>> >> >         MyPanel(String id) {
>> >> >         super(id);
>> >> >
>> >> >         DownloadLink dl = new DownloadLink( id, new File(
>> >> > "wat-application/images/addmore.jpg" ), "Example DownloadLink" );
>> >> >         add(dl);
>> >> >         }
>> >> >  }
>> >> >
>> >> >
>> >> > I copied the example from:
>> >> > http://www.wicket-library.com/wicket-examples/ajax/tree/simple.0
>> >> >
>> >> >
>> >> > But i get the following error:
>> >> > WicketMessage: Component content must be applied to a tag of type
>> 'form',
>> >> > not '<span wicket:id="content" class="content" id="content21">' (line
>> 0,
>> >> > column 0)
>> >> >
>> >> >
>> >> > <wicket:panel>
>> >> > <table class="icon-panel"><tr><td wicket:id="iconLink"><img
>> >> wicket:id="icon"
>> >> > class="icon"/></td><td class="content"><a
>> wicket:id="contentLink"><span
>> >> > wicket:id="content" class="content"></span></a></td></tr></table>
>> >> > </wicket:panel>, index = 8, current = '<span wicket:id="content"
>> >> > class="content">' (line 19, column 144)]
>> >> >
>> >> > Thanks
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [email protected]
>> >> For additional commands, e-mail: [email protected]
>> >>
>> >>
>> >
>> >
>> > --
>> > Anna Simbirtsev
>> > (416) 729-7331
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> Anna Simbirtsev
> (416) 729-7331
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to