Hello Ian,
you will need to override newNodeComponent(final String id, final
IModel model) on the LinkTree to return your own panel with the
downloadlink for the nodes which should trigger a download and
super.newNodeComponent... for all others.
regards,
roland
On 9/26/07, Ian Godman <[EMAIL PROTECTED]> wrote:
> I have looked at the DownloadLink class and it does seem to do what i need.
>
> The issue I have now is that I am using a link tree which uses ajax to load
> the directory contents as the tree is traversed. This works fine.
>
> What I think I need to do is change the behavior of the tree node for the
> files such that it does not use ajax. I have looked at doing this but just
> cant work it out.
>
> I have extended LinkIconPanel to determine if the node is a directory or a
> file depending on the type of the user object in the model and not on if the
> node has any children.
>
> I think this is were I need to make changes but I cant find out where the
> ajax behavior is being added.
>
> The code I have derived from DownloadLink is
>
> IResourceStream resourceStream = new FileResourceStream(new
> org.apache.wicket.util.file.File(file));
> getRequestCycle().setRequestTarget(new
> ResourceStreamRequestTarget(resourceStream) {
> public String getFileName()
> {
> log.debug("returning: " + fileItem.getFileName() ) ;
> return fileItem.getFileName();
> }
> });
>
>
> I have this on the onNodeLinkClicked of my tree (extends LinkTree).
>
> To my understanding the download redirects the request to the file to be
> downloaded, dont think this will work with an ajax request.
>
>
>
> ----- Original Message ----
> From: Andrew Klochkov <[EMAIL PROTECTED]>
> To: [email protected]
> Sent: Wednesday, 26 September, 2007 11:55:07 AM
> Subject: Re: File downloading with Wicket
>
> Have a look at the DownloadLink class
>
> Ian Godman wrote:
> > Can any one give me a pointer or 2 on how to download a file from a wicket
> > page?
> >
> > I have a LinkTree representing a directory tree which is lazy loaded via
> > ajax. When the user clicks on a file node I need to download the file to
> > them. However the file is stored with a different name (allows for
> > versioning etc) so it needs to arrive at the browser as a file with the
> > name as displayed in the tree not as saved on the hard disk.
> >
> > This was previously implemented in a Tapestry system using a servelet but I
> > just cant get my head around the issues of using a servlet in Wicket (does
> > not seem the right way to me).
> >
> > Any help in clearing the fog most appreciated, example code even more so
> >
> >
> > Ian
> >
> >
> >
> >
> >
> > ___________________________________________________________
> > Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
> > now.
> > http://uk.answers.yahoo.com/
> >
>
>
> --
> Andrew Klochkov
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>
>
>
>
> ___________________________________________________________
> Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
> now.
> http://uk.answers.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]