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-yyyy-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]