DownloadLink problem
Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say: target.addComponent(theLink); the link name is still invisible, and when I click on the small clickable area, Wicket comes up with: WicketMessage: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = exported_file_link]] threw an exception Root cause: java.lang.IllegalStateException: org.apache.wicket.markup.html.link.DownloadLink failed to retrieve a File object from model at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:141) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:224) at java.lang.reflect.Method.invoke(Method.java:597) I thought I've made everything perfect, but it seems that I haven't. Any help is appreciated! Best regards, Martin
Re: DownloadLink problem
Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member variable? This way file will be refreshed. Best, Ernnesto On Tue, Mar 2, 2010 at 1:14 PM, Martin Asenov mase...@velti.com wrote: Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say: target.addComponent(theLink); the link name is still invisible, and when I click on the small clickable area, Wicket comes up with: WicketMessage: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = exported_file_link]] threw an exception Root cause: java.lang.IllegalStateException: org.apache.wicket.markup.html.link.DownloadLink failed to retrieve a File object from model at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:141) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:224) at java.lang.reflect.Method.invoke(Method.java:597) I thought I've made everything perfect, but it seems that I haven't. Any help is appreciated! Best regards, Martin
RE: DownloadLink problem
Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member variable? This way file will be refreshed. Best, Ernnesto On Tue, Mar 2, 2010 at 1:14 PM, Martin Asenov mase...@velti.com wrote: Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say: target.addComponent(theLink); the link name is still invisible, and when I click on the small clickable area, Wicket comes up with: WicketMessage: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = exported_file_link]] threw an exception Root cause: java.lang.IllegalStateException: org.apache.wicket.markup.html.link.DownloadLink failed to retrieve a File object from model at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:141) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:224) at java.lang.reflect.Method.invoke(Method.java:597) I thought I've made everything perfect, but it seems that I haven't. Any help is appreciated! Best regards, Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DownloadLink problem
Use a LoadableDetachableModelFile? On Tue, Mar 2, 2010 at 8:24 AM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member variable? This way file will be refreshed. Best, Ernnesto On Tue, Mar 2, 2010 at 1:14 PM, Martin Asenov mase...@velti.com wrote: Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say: target.addComponent(theLink); the link name is still invisible, and when I click on the small clickable area, Wicket comes up with: WicketMessage: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = exported_file_link]] threw an exception Root cause: java.lang.IllegalStateException: org.apache.wicket.markup.html.link.DownloadLink failed to retrieve a File object from model at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:141) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:224) at java.lang.reflect.Method.invoke(Method.java:597) I thought I've made everything perfect, but it seems that I haven't. Any help is appreciated! Best regards, Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: DownloadLink problem
Weird. Just try this example: import java.io.File; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestDownLoadLink extends Panel { private static final long serialVersionUID = 1L; private File test = null; private DownloadLink download; /** * @param id */ public TestDownLoadLink(String id) { super(id); this.download = new DownloadLink(download, new AbstractReadOnlyModelFile(){ private static final long serialVersionUID = 1L; @Override public File getObject() { return test; } },TestDownLoadLink.html) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return test != null; } }; download.setOutputMarkupId(true); add(download); AjaxLinkVoid update = new AjaxLinkVoid(update) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { test = new File(TestDownLoadLink.class.getResource(TestDownLoadLink.html).getFile()); if(target != null) { target.addComponent(TestDownLoadLink.this.download); } } }; add(update); } } and the HTML html xmlns:wicket=org.apache.wicket head /head body wicket:panel a wicket:id=downloaddownload/a a wicket:id=updateClick me to update download/a /wicket:panel /body /html Just place them somewhere and do new TestDownLoadLink(xxx); It works for me. First time the download link is disable and when you click on the AJAX link file is assigned, link is refreshed and you can download your file;-) Best, Ernesto On Tue, Mar 2, 2010 at 2:24 PM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member variable? This way file will be refreshed. Best, Ernnesto On Tue, Mar 2, 2010 at 1:14 PM, Martin Asenov mase...@velti.com wrote: Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say: target.addComponent(theLink); the link name is still invisible, and when I click on the small clickable area, Wicket comes up with: WicketMessage: Method onLinkClicked of interface org.apache.wicket.markup.html.link.ILinkListener targeted at component [MarkupContainer [Component id = exported_file_link]] threw an exception Root cause: java.lang.IllegalStateException: org.apache.wicket.markup.html.link.DownloadLink failed to retrieve a File object from model at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:141) at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:224) at java.lang.reflect.Method.invoke(Method.java:597) I thought I've made everything perfect, but it seems that I haven't. Any help is appreciated! Best regards, Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: DownloadLink problem
Thanks Ernesto! But I want to have the link invisible on startup (because the file's empty). So I have this: (doesn't work, but has to) exportedFileLink = new DownloadLink(exported_file_link, new LoadableDetachableModelFile() { private static final long serialVersionUID = 1L; @Override protected File load() { return exportedFile; } }, PhonebookExporter.OUTPUT_FILE_NAME) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return exportedFile != null; } }; final WebMarkupContainer exportedFileLinkHolder = new WebMarkupContainer(link_holder); exportedFileLinkHolder.setOutputMarkupId(true); exportedFileLinkHolder.add(exportedFileLink); rightForm.add(exportedFileLinkHolder); rightForm.add(new AjaxButton(export_button) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { PhonebookExporter exporter = getExporter(); exportedFile = exporter.export(uploadFolder); if (exportedFile == null) { error(getString(not_exported)); } else { info(getString(exported)); } target.addComponent(exportedFileLinkHolder); target.addComponent(feed); } }); I really start to get pissed off by this one!!! g Regards, Martin -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 3:50 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Weird. Just try this example: import java.io.File; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestDownLoadLink extends Panel { private static final long serialVersionUID = 1L; private File test = null; private DownloadLink download; /** * @param id */ public TestDownLoadLink(String id) { super(id); this.download = new DownloadLink(download, new AbstractReadOnlyModelFile(){ private static final long serialVersionUID = 1L; @Override public File getObject() { return test; } },TestDownLoadLink.html) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return test != null; } }; download.setOutputMarkupId(true); add(download); AjaxLinkVoid update = new AjaxLinkVoid(update) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { test = new File(TestDownLoadLink.class.getResource(TestDownLoadLink.html).getFile()); if(target != null) { target.addComponent(TestDownLoadLink.this.download); } } }; add(update); } } and the HTML html xmlns:wicket=org.apache.wicket head /head body wicket:panel a wicket:id=downloaddownload/a a wicket:id=updateClick me to update download/a /wicket:panel /body /html Just place them somewhere and do new TestDownLoadLink(xxx); It works for me. First time the download link is disable and when you click on the AJAX link file is assigned, link is refreshed and you can download your file;-) Best, Ernesto On Tue, Mar 2, 2010 at 2:24 PM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member variable? This way file will be refreshed. Best, Ernnesto On Tue, Mar 2, 2010 at 1:14 PM, Martin Asenov mase...@velti.com wrote: Hi, guys! I experience some DownloadLink problem - I have these fields: File linkModel; DownloadLink theLink = new DownloadLink(link_id, new ModelFile(linkModel)); theLink.setOutputMarkupId(true); After another button click I have the linkModel field pointing to real file on the file system. And then I say
RE: DownloadLink problem
Oh my God!!! The problem was that the button that is supposed to do the export was of type submit and it reloads the page, instead of refreshing components. I changed to type=button and everything's fine... As people say - there is no patch for human stupidity... Thank you all for the help! Best, Martin -Original Message- From: Martin Asenov [mailto:mase...@velti.com] Sent: Tuesday, March 02, 2010 4:34 PM To: users@wicket.apache.org Subject: RE: DownloadLink problem Thanks Ernesto! But I want to have the link invisible on startup (because the file's empty). So I have this: (doesn't work, but has to) exportedFileLink = new DownloadLink(exported_file_link, new LoadableDetachableModelFile() { private static final long serialVersionUID = 1L; @Override protected File load() { return exportedFile; } }, PhonebookExporter.OUTPUT_FILE_NAME) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return exportedFile != null; } }; final WebMarkupContainer exportedFileLinkHolder = new WebMarkupContainer(link_holder); exportedFileLinkHolder.setOutputMarkupId(true); exportedFileLinkHolder.add(exportedFileLink); rightForm.add(exportedFileLinkHolder); rightForm.add(new AjaxButton(export_button) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { PhonebookExporter exporter = getExporter(); exportedFile = exporter.export(uploadFolder); if (exportedFile == null) { error(getString(not_exported)); } else { info(getString(exported)); } target.addComponent(exportedFileLinkHolder); target.addComponent(feed); } }); I really start to get pissed off by this one!!! g Regards, Martin -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 3:50 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Weird. Just try this example: import java.io.File; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestDownLoadLink extends Panel { private static final long serialVersionUID = 1L; private File test = null; private DownloadLink download; /** * @param id */ public TestDownLoadLink(String id) { super(id); this.download = new DownloadLink(download, new AbstractReadOnlyModelFile(){ private static final long serialVersionUID = 1L; @Override public File getObject() { return test; } },TestDownLoadLink.html) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return test != null; } }; download.setOutputMarkupId(true); add(download); AjaxLinkVoid update = new AjaxLinkVoid(update) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { test = new File(TestDownLoadLink.class.getResource(TestDownLoadLink.html).getFile()); if(target != null) { target.addComponent(TestDownLoadLink.this.download); } } }; add(update); } } and the HTML html xmlns:wicket=org.apache.wicket head /head body wicket:panel a wicket:id=downloaddownload/a a wicket:id=updateClick me to update download/a /wicket:panel /body /html Just place them somewhere and do new TestDownLoadLink(xxx); It works for me. First time the download link is disable and when you click on the AJAX link file is assigned, link is refreshed and you can download your file;-) Best, Ernesto On Tue, Mar 2, 2010 at 2:24 PM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink(link_id, new AbstractReadOnlyModelFile(){ public File getObject() { return this.linkModel; }; },myfile.xxx); downloadLink.setOutputMarkupId(true); and make linkModel a member
Re: DownloadLink problem
Martin, If it makes you feel any better, it would have been a week or longer before I thought to change that, good fine :) -R On Tue, Mar 2, 2010 at 9:32 AM, Martin Asenov mase...@velti.com wrote: Oh my God!!! The problem was that the button that is supposed to do the export was of type submit and it reloads the page, instead of refreshing components. I changed to type=button and everything's fine... As people say - there is no patch for human stupidity... Thank you all for the help! Best, Martin -Original Message- From: Martin Asenov [mailto:mase...@velti.com] Sent: Tuesday, March 02, 2010 4:34 PM To: users@wicket.apache.org Subject: RE: DownloadLink problem Thanks Ernesto! But I want to have the link invisible on startup (because the file's empty). So I have this: (doesn't work, but has to) exportedFileLink = new DownloadLink(exported_file_link, new LoadableDetachableModelFile() { private static final long serialVersionUID = 1L; @Override protected File load() { return exportedFile; } }, PhonebookExporter.OUTPUT_FILE_NAME) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return exportedFile != null; } }; final WebMarkupContainer exportedFileLinkHolder = new WebMarkupContainer(link_holder); exportedFileLinkHolder.setOutputMarkupId(true); exportedFileLinkHolder.add(exportedFileLink); rightForm.add(exportedFileLinkHolder); rightForm.add(new AjaxButton(export_button) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { PhonebookExporter exporter = getExporter(); exportedFile = exporter.export(uploadFolder); if (exportedFile == null) { error(getString(not_exported)); } else { info(getString(exported)); } target.addComponent(exportedFileLinkHolder); target.addComponent(feed); } }); I really start to get pissed off by this one!!! g Regards, Martin -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 3:50 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Weird. Just try this example: import java.io.File; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestDownLoadLink extends Panel { private static final long serialVersionUID = 1L; private File test = null; private DownloadLink download; /** * @param id */ public TestDownLoadLink(String id) { super(id); this.download = new DownloadLink(download, new AbstractReadOnlyModelFile(){ private static final long serialVersionUID = 1L; @Override public File getObject() { return test; } },TestDownLoadLink.html) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return test != null; } }; download.setOutputMarkupId(true); add(download); AjaxLinkVoid update = new AjaxLinkVoid(update) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { test = new File(TestDownLoadLink.class.getResource(TestDownLoadLink.html).getFile()); if(target != null) { target.addComponent(TestDownLoadLink.this.download); } } }; add(update); } } and the HTML html xmlns:wicket=org.apache.wicket head /head body wicket:panel a wicket:id=downloaddownload/a a wicket:id=updateClick me to update download/a /wicket:panel /body /html Just place them somewhere and do new TestDownLoadLink(xxx); It works for me. First time the download link is disable and when you click on the AJAX link file is assigned, link is refreshed and you can download your file;-) Best, Ernesto On Tue, Mar 2, 2010 at 2:24 PM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 2:31 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Not sure... but could you try something like: DownloadLink downloadLink = new DownloadLink
RE: DownloadLink problem
It doesn't... :-) Thank you anyway! :-) -Original Message- From: Riyad Kalla [mailto:rka...@gmail.com] Sent: Tuesday, March 02, 2010 6:35 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Martin, If it makes you feel any better, it would have been a week or longer before I thought to change that, good fine :) -R On Tue, Mar 2, 2010 at 9:32 AM, Martin Asenov mase...@velti.com wrote: Oh my God!!! The problem was that the button that is supposed to do the export was of type submit and it reloads the page, instead of refreshing components. I changed to type=button and everything's fine... As people say - there is no patch for human stupidity... Thank you all for the help! Best, Martin -Original Message- From: Martin Asenov [mailto:mase...@velti.com] Sent: Tuesday, March 02, 2010 4:34 PM To: users@wicket.apache.org Subject: RE: DownloadLink problem Thanks Ernesto! But I want to have the link invisible on startup (because the file's empty). So I have this: (doesn't work, but has to) exportedFileLink = new DownloadLink(exported_file_link, new LoadableDetachableModelFile() { private static final long serialVersionUID = 1L; @Override protected File load() { return exportedFile; } }, PhonebookExporter.OUTPUT_FILE_NAME) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return exportedFile != null; } }; final WebMarkupContainer exportedFileLinkHolder = new WebMarkupContainer(link_holder); exportedFileLinkHolder.setOutputMarkupId(true); exportedFileLinkHolder.add(exportedFileLink); rightForm.add(exportedFileLinkHolder); rightForm.add(new AjaxButton(export_button) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form? form) { PhonebookExporter exporter = getExporter(); exportedFile = exporter.export(uploadFolder); if (exportedFile == null) { error(getString(not_exported)); } else { info(getString(exported)); } target.addComponent(exportedFileLinkHolder); target.addComponent(feed); } }); I really start to get pissed off by this one!!! g Regards, Martin -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier...@gmail.com] Sent: Tuesday, March 02, 2010 3:50 PM To: users@wicket.apache.org Subject: Re: DownloadLink problem Weird. Just try this example: import java.io.File; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.link.DownloadLink; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.AbstractReadOnlyModel; /** * @author Ernesto Reinaldo Barreiro (reier...@gmail.com) * */ public class TestDownLoadLink extends Panel { private static final long serialVersionUID = 1L; private File test = null; private DownloadLink download; /** * @param id */ public TestDownLoadLink(String id) { super(id); this.download = new DownloadLink(download, new AbstractReadOnlyModelFile(){ private static final long serialVersionUID = 1L; @Override public File getObject() { return test; } },TestDownLoadLink.html) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return test != null; } }; download.setOutputMarkupId(true); add(download); AjaxLinkVoid update = new AjaxLinkVoid(update) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { test = new File(TestDownLoadLink.class.getResource(TestDownLoadLink.html).getFile()); if(target != null) { target.addComponent(TestDownLoadLink.this.download); } } }; add(update); } } and the HTML html xmlns:wicket=org.apache.wicket head /head body wicket:panel a wicket:id=downloaddownload/a a wicket:id=updateClick me to update download/a /wicket:panel /body /html Just place them somewhere and do new TestDownLoadLink(xxx); It works for me. First time the download link is disable and when you click on the AJAX link file is assigned, link is refreshed and you can download your file;-) Best, Ernesto On Tue, Mar 2, 2010 at 2:24 PM, Martin Asenov mase...@velti.com wrote: Unfortunately doesn't work this way... The model is never refreshed... -Original Message- From: Ernesto Reinaldo Barreiro [mailto:reier