Re: Customizing RadioChoice
Hi Martijn, > I'm +1 on removing final from the get*fix methods on the RadioChoice > component. Anyone else reading along and objecting? +1 - and please consider the same for the CheckBoxMultipleChoice. :-) Best regards, --- Jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to NOT cause a hot redeploy with Jetty when HTML files change
Thanks for the tips. This is working much better for me now and I'm now much more productive. -- Jason Martijn Dashorst wrote: > > Not recommended per se, but it works for me. However, it will not > reload structural changes, you'll need to restart jetty when you add a > property, method, or change the signature of a method, etc. > > The debugger can only modify the contents of methods, not add them > (unfortunately). The reloading filter should mitigate that, but I > haven't used it. > > Martijn > > On 10/5/07, Jason Mihalick <[EMAIL PROTECTED]> wrote: >> >> Thanks Eelco. However, I am using the Maven Jetty plugin >> (http://www.mortbay.org/maven-plugin/index.html) for jetty usage under >> Maven. Perhaps that is what you meant. I am also using the Maven2 >> eclipse >> plugin (http://m2eclipse.codehaus.org/) for dependency management within >> eclipse, but that plugin is not affecting this problem. >> >> So is using Martin's suggestion the preferred way to develop with Wicket >> under Eclipse and it will avoid my reloading issues? >> >> Thanks for the replies. I'm really enjoying development with Wicket. >> >> -- >> Jason >> >> >> Eelco Hillenius wrote: >> > >> >> I think most developers have given up on using the eclipse jetty >> >> plugin, and use an embedded container instead. >> > >> > Jason uses the Maven Eclipse plugin, which is a completely different >> > bird, and which actually is used by quite a few developers from what I >> > hear. >> > >> > Eelco >> > >> > - >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> > For additional commands, e-mail: [EMAIL PROTECTED] >> > >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13057239 >> Sent from the Wicket - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Buy Wicket in Action: http://manning.com/dashorst > Apache Wicket 1.3.0-beta3 is released > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0-beta3/ > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/How-to-NOT-cause-a-hot-redeploy-with-Jetty-when-HTML-files-change-tf4571849.html#a13072479 Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
TabbedPanel with image tabs
Good day, I would like to have a possibility to have a small image next to the text in tab in the TabbedPanel. How can I contribute this feature to Wicket? To have a constructor like public AbstractTab(IModel title, ResourceReference image)? Vitek - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding to response header (filename)?
Well, I still don't see a way to get around this error. I'll have to live with it for now until I can look into it deeper. Has anyone else had this error? Stanczak Group wrote: Instead of "setRequestTarget(rsrt)" I use this "rsrt.respond(getRequestCycle());", is that correct? It does work, but I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to redirect to: ?wicket:interface=:2, HTTP Response has already been committed.". It works, but I wouldn't mind fixing that error, just to keep things clean. Johan Compagner wrote: or something like this: new Link() { onclick() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv")); rsrt.setFileName(name); setRequestTarget(rsrt) } } Maybe we should give ResourceStreanRequestTarget 1 extra constructor with the file name.. setRequestTarget(new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv",name))) On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: What do you use for the export? You probably should use a resource. For instance: public class DiscountsExport extends WebResource { public static class Initializer implements IInitializer { public void init(Application application) { SharedResources res = application.getSharedResources(); res.add("discounts", new DiscountsExport()); } } public DiscountsExport() { setCacheable(false); } @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance().exportDiscounts(); return new StringResourceStream(discounts, "text/plain"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } } Sorry, this might be easier to understand: WebResource export = new WebResource() { @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); return new StringResourceStream(discounts, "text/csv"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } }; export.setCacheable(false); add(new ResourceLink("exportLink", export)); Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding to response header (filename)?
On 10/6/07, Stanczak Group <[EMAIL PROTECTED]> wrote: > Well, I still don't see a way to get around this error. I'll have to > live with it for now until I can look into it deeper. Has anyone else > had this error? But you shouldn't call respond yourself. That's for Wicket to do. The only thing you should do is the the request target on the request cycle. Eelco > Stanczak Group wrote: > > Instead of "setRequestTarget(rsrt)" I use this > > "rsrt.respond(getRequestCycle());", is that correct? It does work, but > > I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to > > redirect to: ?wicket:interface=:2, HTTP Response has already been > > committed.". It works, but I wouldn't mind fixing that error, just to > > keep things clean. > > > > > > Johan Compagner wrote: > >> or something like this: > >> > >> new Link() > >> { > >> onclick() > >> { > >> CharSequence discounts = DataBase.getInstance() > >>.exportDiscounts(); > >> > >> > >> ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new > >> StringResourceStream(discounts, "text/csv")); > >> rsrt.setFileName(name); > >> setRequestTarget(rsrt) > >> } > >> } > >> > >> Maybe we should give ResourceStreanRequestTarget 1 extra constructor > >> with > >> the file name.. > >> > >> setRequestTarget(new ResourceStreamRequestTarget(new > >> StringResourceStream(discounts, "text/csv",name))) > >> > >> > >> On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > >> > >>> On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: > >>> > What do you use for the export? You probably should use a resource. > For instance: > > public class DiscountsExport extends WebResource { > > public static class Initializer implements IInitializer { > > public void init(Application application) { > SharedResources res = application.getSharedResources(); > res.add("discounts", new DiscountsExport()); > } > } > > public DiscountsExport() { > > setCacheable(false); > } > > @Override > public IResourceStream getResourceStream() { > CharSequence discounts = DataBase.getInstance().exportDiscounts(); > return new StringResourceStream(discounts, "text/plain"); > } > > @Override > protected void setHeaders(WebResponse response) { > super.setHeaders(response); > response.setAttachmentHeader("discounts.csv"); > } > } > > >>> Sorry, this might be easier to understand: > >>> > >>>WebResource export = new WebResource() { > >>> > >>> @Override > >>> public IResourceStream getResourceStream() { > >>>CharSequence discounts = DataBase.getInstance() > >>>.exportDiscounts(); > >>>return new StringResourceStream(discounts, "text/csv"); > >>> } > >>> > >>> @Override > >>> protected void setHeaders(WebResponse response) { > >>>super.setHeaders(response); > >>>response.setAttachmentHeader("discounts.csv"); > >>> } > >>>}; > >>>export.setCacheable(false); > >>> > >>>add(new ResourceLink("exportLink", export)); > >>> > >>> > >>> Eelco > >>> > >>> - > >>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>> For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >> > >> > > > > -- > Justin Stanczak > Stanczak Group > 812-735-3600 > > "All that is necessary for the triumph of evil is that good men do nothing." > Edmund Burke > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding to response header (filename)?
What do you mean? This is all I'm doing, but still get the "HTTP Response has already been committed." error. Is there something there that wrong? SimpleDateFormat formatFile = new SimpleDateFormat("MM-dd--HH-MM"); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(out, "text/csv")); rsrt.setFileName("export_" + formatFile.format(Calendar.getInstance().getTime()) + ".csv"); rsrt.respond(getRequestCycle()); Eelco Hillenius wrote: On 10/6/07, Stanczak Group <[EMAIL PROTECTED]> wrote: Well, I still don't see a way to get around this error. I'll have to live with it for now until I can look into it deeper. Has anyone else had this error? But you shouldn't call respond yourself. That's for Wicket to do. The only thing you should do is the the request target on the request cycle. Eelco Stanczak Group wrote: Instead of "setRequestTarget(rsrt)" I use this "rsrt.respond(getRequestCycle());", is that correct? It does work, but I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to redirect to: ?wicket:interface=:2, HTTP Response has already been committed.". It works, but I wouldn't mind fixing that error, just to keep things clean. Johan Compagner wrote: or something like this: new Link() { onclick() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv")); rsrt.setFileName(name); setRequestTarget(rsrt) } } Maybe we should give ResourceStreanRequestTarget 1 extra constructor with the file name.. setRequestTarget(new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv",name))) On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: On 10/5/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote: What do you use for the export? You probably should use a resource. For instance: public class DiscountsExport extends WebResource { public static class Initializer implements IInitializer { public void init(Application application) { SharedResources res = application.getSharedResources(); res.add("discounts", new DiscountsExport()); } } public DiscountsExport() { setCacheable(false); } @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance().exportDiscounts(); return new StringResourceStream(discounts, "text/plain"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } } Sorry, this might be easier to understand: WebResource export = new WebResource() { @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); return new StringResourceStream(discounts, "text/csv"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } }; export.setCacheable(false); add(new ResourceLink("exportLink", export)); Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding to response header (filename)?
On 10/6/07, Stanczak Group <[EMAIL PROTECTED]> wrote: > What do you mean? This is all I'm doing, but still get the "HTTP > Response has already been committed." error. Is there something there > that wrong? > > SimpleDateFormat formatFile = new SimpleDateFormat("MM-dd--HH-MM"); > ResourceStreamRequestTarget rsrt = new > ResourceStreamRequestTarget(new StringResourceStream(out, "text/csv")); > rsrt.setFileName("export_" + > formatFile.format(Calendar.getInstance().getTime()) + ".csv"); > rsrt.respond(getRequestCycle()); This last line, rsrt.respond is what you shouldn't do. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
creating datatable with dynamical columns
Hi, I need to create AjaxFallbackDefaultDataTable with dynamical columns. I am reading columns from database and creating AjaxFallbackDefaultDataTable with this info. I have classes DataTable and DataRow like .net's data layer structure. DataTable have DataRows in ArrayList and DataRows have DataColumns in ArrayList. I am defining DataRow as modelObject. I am reaching column value like this: ((DataRow)dataTable.getRow(rowIndex)).get/String/Decimal/Date("columnName");. Wicket searching set/getColumnName() in the modelObject and these classes and functions have been finalized. It looks like, there is no way to create dataTable with dynamical columns. If any way you know can you explain? --- I am taking this error: WicketMessage: No get method defined for class: class com.elf.data.DataRow expression: id Root cause: org.apache.wicket.WicketRuntimeException: No get method defined for class: class com.elf.data.DataRow expression: id I have codes like these: ElfAjaxDataGrid helpDataGrid = new ElfAjaxDataGrid("helpDataGrid",help.columns(),help.dataProvider(),50); public ArrayList columns(){ //normally I am reading from db ArrayList columns = new ArrayList(); columns.add(new PropertyColumn(new Model("ID"), "id")); columns.add(new PropertyColumn(new Model("First Name"), "firstName", "firstName")); return columns; } public HelpDataProvider dataProvider()throws Exception{ //normally I am reading from db DataTable dataTable = new DataTable("helpDataTable"); dataTable.checkAndAddColumn(new StringDataColumn(dataTable,"id")); dataTable.checkAndAddColumn(new StringDataColumn(dataTable,"firstName")); DataRow dataRow = dataTable.NewRow(); dataRow.set("id", "1"); dataRow.set("firstName", "test"); dataTable.AddRow(dataRow); return new HelpDataProvider(dataTable); } public class HelpDataProvider extends SortableDataProvider{ private static final long serialVersionUID = 1L; DataTable dataTable = null; public HelpDataProvider(DataTable dataTable) { this.dataTable = dataTable; } public Iterator iterator(int first, int count) { return dataTable.rows().iterator(); } public IModel model(Object object) { return new HelpDetachableModel(dataTable); } public int size() { return dataTable.Count(); } } public class HelpDetachableModel extends LoadableDetachableModel{ private static final long serialVersionUID = 1L; private int index = 0; private DataTable dataTable; public HelpDetachableModel(DataTable dataTable) { this.dataTable = dataTable; } protected Object load() { return dataTable.getRow(index); } } - Yahoo! kullaniyor musunuz? Istenmeyen postadan biktiniz mi? Istenmeyen postadan en iyi korunma Yahoo! Posta'da http://tr.mail.yahoo.com
Yanıt: Re: Adding to response header (filename )?
I dont know the subject, I didnt follow up, but this code is working. downloadLink = new Link("downloadFile"){ private static final long serialVersionUID = 1L; public void onClick(){ String tableCode = sourceCode; BufferedInputStream bis = null; BufferedOutputStream bos = null; try { String ContentType = "text"; getResponse().setContentType(ContentType); ((WebResponse)getResponse()).setHeader("Content-Disposition","inline; filename=\""+fileName+".java\""); ByteArrayInputStream bais = new ByteArrayInputStream(tableCode.getBytes()); bis = new BufferedInputStream(bais); bos=new BufferedOutputStream(getResponse().getOutputStream()); byte[] buff=new byte[2048]; int bytesread; while((bytesread=bis.read(buff,0,buff.length)) != -1) { bos.write(buff,0,bytesread); } bos.flush(); } catch (Exception e) { e.printStackTrace(); } finally{ try { bos.close();bos=null; bis.close();bis=null; } catch (Exception e) { } } } }; Eelco Hillenius <[EMAIL PROTECTED]> wrote: On 10/6/07, Stanczak Group wrote: > Well, I still don't see a way to get around this error. I'll have to > live with it for now until I can look into it deeper. Has anyone else > had this error? But you shouldn't call respond yourself. That's for Wicket to do. The only thing you should do is the the request target on the request cycle. Eelco > Stanczak Group wrote: > > Instead of "setRequestTarget(rsrt)" I use this > > "rsrt.respond(getRequestCycle());", is that correct? It does work, but > > I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to > > redirect to: ?wicket:interface=:2, HTTP Response has already been > > committed.". It works, but I wouldn't mind fixing that error, just to > > keep things clean. > > > > > > Johan Compagner wrote: > >> or something like this: > >> > >> new Link() > >> { > >> onclick() > >> { > >> CharSequence discounts = DataBase.getInstance() > >> .exportDiscounts(); > >> > >> > >> ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new > >> StringResourceStream(discounts, "text/csv")); > >> rsrt.setFileName(name); > >> setRequestTarget(rsrt) > >> } > >> } > >> > >> Maybe we should give ResourceStreanRequestTarget 1 extra constructor > >> with > >> the file name.. > >> > >> setRequestTarget(new ResourceStreamRequestTarget(new > >> StringResourceStream(discounts, "text/csv",name))) > >> > >> > >> On 10/5/07, Eelco Hillenius wrote: > >> > >>> On 10/5/07, Eelco Hillenius wrote: > >>> > What do you use for the export? You probably should use a resource. > For instance: > > public class DiscountsExport extends WebResource { > > public static class Initializer implements IInitializer { > > public void init(Application application) { > SharedResources res = application.getSharedResources(); > res.add("discounts", new DiscountsExport()); > } > } > > public DiscountsExport() { > > setCacheable(false); > } > > @Override > public IResourceStream getResourceStream() { > CharSequence discounts = DataBase.getInstance().exportDiscounts(); > return new StringResourceStream(discounts, "text/plain"); > } > > @Override > protected void setHeaders(WebResponse response) { > super.setHeaders(response); > response.setAttachmentHeader("discounts.csv"); > } > } > > >>> Sorry, this might be easier to understand: > >>> > >>> WebResource export = new WebResource() { > >>> > >>> @Override > >>> public IResourceStream getResourceStream() { > >>> CharSequence discounts = DataBase.getInstance() > >>> .exportDiscounts(); > >>> return new StringResourceStream(discounts, "text/csv"); > >>> } > >>> > >>> @Override > >>> protected void setHeaders(WebResponse response) { > >>> super.setHeaders(response); > >>> response.setAttachmentHeader("discounts.csv"); > >>> } > >>> }; > >>> export.setCacheable(false); > >>> > >>> add(new ResourceLink("exportLink", export)); > >>> > >>> > >>> Eelco > >>> > >>> - > >>> To unsubscribe, e-mail: [EMAIL PROTECTED] > >>> For additional commands, e-mail: [EMAIL PROTECTED] > >>> > >>> > >>> > >> > >> > > > > -- > Justin Stanczak > Stanczak Group > 812-735-3600 > > "All that is necessary for the triumph of evil is that good men do nothing." > Edmund Burke > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Yahoo! kullaniyor musunuz? Istenmeyen postadan biktiniz mi? Istenmeyen postadan en iyi korunma Yahoo! Posta'da http://tr.mail.yahoo.com
Re: Yanıt: Re: Adding to response header (filename)?
That's what I used to use, but it gives the same error. Do you not get the error in the logs. The error doesn't stop it from working, but I still would like to do it correctly according to Wicket. Ramazan Pekin wrote: I dont know the subject, I didnt follow up, but this code is working. downloadLink = new Link("downloadFile"){ private static final long serialVersionUID = 1L; public void onClick(){ String tableCode = sourceCode; BufferedInputStream bis = null; BufferedOutputStream bos = null; try { String ContentType = "text"; getResponse().setContentType(ContentType); ((WebResponse)getResponse()).setHeader("Content-Disposition","inline; filename=\""+fileName+".java\""); ByteArrayInputStream bais = new ByteArrayInputStream(tableCode.getBytes()); bis = new BufferedInputStream(bais); bos=new BufferedOutputStream(getResponse().getOutputStream()); byte[] buff=new byte[2048]; int bytesread; while((bytesread=bis.read(buff,0,buff.length)) != -1) { bos.write(buff,0,bytesread); } bos.flush(); } catch (Exception e) { e.printStackTrace(); } finally{ try { bos.close();bos=null; bis.close();bis=null; } catch (Exception e) { } } } }; Eelco Hillenius <[EMAIL PROTECTED]> wrote: On 10/6/07, Stanczak Group wrote: Well, I still don't see a way to get around this error. I'll have to live with it for now until I can look into it deeper. Has anyone else had this error? But you shouldn't call respond yourself. That's for Wicket to do. The only thing you should do is the the request target on the request cycle. Eelco Stanczak Group wrote: Instead of "setRequestTarget(rsrt)" I use this "rsrt.respond(getRequestCycle());", is that correct? It does work, but I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to redirect to: ?wicket:interface=:2, HTTP Response has already been committed.". It works, but I wouldn't mind fixing that error, just to keep things clean. Johan Compagner wrote: or something like this: new Link() { onclick() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv")); rsrt.setFileName(name); setRequestTarget(rsrt) } } Maybe we should give ResourceStreanRequestTarget 1 extra constructor with the file name.. setRequestTarget(new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv",name))) On 10/5/07, Eelco Hillenius wrote: On 10/5/07, Eelco Hillenius wrote: What do you use for the export? You probably should use a resource. For instance: public class DiscountsExport extends WebResource { public static class Initializer implements IInitializer { public void init(Application application) { SharedResources res = application.getSharedResources(); res.add("discounts", new DiscountsExport()); } } public DiscountsExport() { setCacheable(false); } @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance().exportDiscounts(); return new StringResourceStream(discounts, "text/plain"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } } Sorry, this might be easier to understand: WebResource export = new WebResource() { @Override public IResourceStream getResourceStream() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); return new StringResourceStream(discounts, "text/csv"); } @Override protected void setHeaders(WebResponse response) { super.setHeaders(response); response.setAttachmentHeader("discounts.csv"); } }; export.setCacheable(false); add(new ResourceLink("exportLink", export)); Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Yahoo! kullaniyor musunuz? Istenmeyen postadan biktiniz mi? Istenmeyen postadan en iyi korunma Yahoo! Posta'da http://tr.mail.yahoo.com -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Adding to response header (filename)?
Oh, then what should I do? Sorry if I'm missing the obvious here. Eelco Hillenius wrote: On 10/6/07, Stanczak Group <[EMAIL PROTECTED]> wrote: What do you mean? This is all I'm doing, but still get the "HTTP Response has already been committed." error. Is there something there that wrong? SimpleDateFormat formatFile = new SimpleDateFormat("MM-dd--HH-MM"); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(out, "text/csv")); rsrt.setFileName("export_" + formatFile.format(Calendar.getInstance().getTime()) + ".csv"); rsrt.respond(getRequestCycle()); This last line, rsrt.respond is what you shouldn't do. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Justin Stanczak Stanczak Group 812-735-3600 "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Yanıt: Re: Yanıt: Re: Adding to response header (filename)?
No, There is no error at logs. I have tried to do with wicket but I cant. So I have done with this way. This link is org.apache.wicket.markup.html.link.Link and in the org.apache.wicket.markup.html.panel.Panel. And the panel in the org.apache.wicket.markup.html.WebPage Stanczak Group <[EMAIL PROTECTED]> wrote: That's what I used to use, but it gives the same error. Do you not get the error in the logs. The error doesn't stop it from working, but I still would like to do it correctly according to Wicket. Ramazan Pekin wrote: > I dont know the subject, I didnt follow up, but this code is working. > > downloadLink = new Link("downloadFile"){ > private static final long serialVersionUID = 1L; > public void onClick(){ > String tableCode = sourceCode; > BufferedInputStream bis = null; > BufferedOutputStream bos = null; > try { > String ContentType = "text"; > getResponse().setContentType(ContentType); > ((WebResponse)getResponse()).setHeader("Content-Disposition","inline; > filename=\""+fileName+".java\""); > ByteArrayInputStream bais = new ByteArrayInputStream(tableCode.getBytes()); > bis = new BufferedInputStream(bais); > bos=new BufferedOutputStream(getResponse().getOutputStream()); > byte[] buff=new byte[2048]; > int bytesread; > while((bytesread=bis.read(buff,0,buff.length)) != -1) { > bos.write(buff,0,bytesread); > } > bos.flush(); > } catch (Exception e) { > e.printStackTrace(); > } finally{ > try { > bos.close();bos=null; > bis.close();bis=null; > } catch (Exception e) { > > } > } > } > }; > > Eelco Hillenius wrote: > On 10/6/07, Stanczak Group wrote: > >> Well, I still don't see a way to get around this error. I'll have to >> live with it for now until I can look into it deeper. Has anyone else >> had this error? >> > > But you shouldn't call respond yourself. That's for Wicket to do. The > only thing you should do is the the request target on the request > cycle. > > Eelco > > >> Stanczak Group wrote: >> >>> Instead of "setRequestTarget(rsrt)" I use this >>> "rsrt.respond(getRequestCycle());", is that correct? It does work, but >>> I get this in the logs "08:53:03,277 ERROR WebResponse:190 - Unable to >>> redirect to: ?wicket:interface=:2, HTTP Response has already been >>> committed.". It works, but I wouldn't mind fixing that error, just to >>> keep things clean. >>> >>> >>> Johan Compagner wrote: >>> or something like this: new Link() { onclick() { CharSequence discounts = DataBase.getInstance() .exportDiscounts(); ResourceStreamRequestTarget rsrt = new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv")); rsrt.setFileName(name); setRequestTarget(rsrt) } } Maybe we should give ResourceStreanRequestTarget 1 extra constructor with the file name.. setRequestTarget(new ResourceStreamRequestTarget(new StringResourceStream(discounts, "text/csv",name))) On 10/5/07, Eelco Hillenius wrote: > On 10/5/07, Eelco Hillenius wrote: > > >> What do you use for the export? You probably should use a resource. >> For instance: >> >> public class DiscountsExport extends WebResource { >> >> public static class Initializer implements IInitializer { >> >> public void init(Application application) { >> SharedResources res = application.getSharedResources(); >> res.add("discounts", new DiscountsExport()); >> } >> } >> >> public DiscountsExport() { >> >> setCacheable(false); >> } >> >> @Override >> public IResourceStream getResourceStream() { >> CharSequence discounts = DataBase.getInstance().exportDiscounts(); >> return new StringResourceStream(discounts, "text/plain"); >> } >> >> @Override >> protected void setHeaders(WebResponse response) { >> super.setHeaders(response); >> response.setAttachmentHeader("discounts.csv"); >> } >> } >> >> > Sorry, this might be easier to understand: > > WebResource export = new WebResource() { > > @Override > public IResourceStream getResourceStream() { > CharSequence discounts = DataBase.getInstance() > .exportDiscounts(); > return new StringResourceStream(discounts, "text/csv"); > } > > @Override > protected void setHeaders(WebResponse response) { > super.setHeaders(response); > response.setAttachmentHeader("discounts.csv"); > } > }; > export.setCacheable(false); > > add(new ResourceLink("exportLink", export)); > > > Eelco > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > >> -- >> Justin Stanczak >> Stanczak Group >> 812-735-3600 >> >> "All that is necessary for the triumph of evil is that good men do nothing." >>
Re: Adding to response header (filename)?
hi, see here: http://www.nabble.com/Download-link-from-DynamicWebResource--tf4353363.html#a12404601 regards, --- jan. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]