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]

Reply via email to