>From what I've read, the difference between the two browsers is that IE uses
the file name's extension to determine what type of file it is and other
browsers like FireFox use the MIME type provided by the remote server (your
application in this case.)

So, IE is seeing ".csv" and assuming it's a CSV file.  FireFox on the other
hand is looking at the "text/plain" MIME type you provided and assuming it's
a plain text file.  You are using the wrong mime type.


wch2001 wrote:
> 
> thanks, UPBrandon
> 
> I tried your code, for csv, 
> 
> public class CsvRequestTarget extends ByteDataRequestTarget {
>     
>         public CsvRequestTarget(byte[] data, String fileName) {
>                 super("text/plain", data, fileName+".csv");
>         }
>         
> } 
> but it can not work with IE and ff.
> 
> Could you tell me your code about csv ?
> 
> thanks a lot
> 
> UPBrandon wrote:
>> 
>> For a while, we were using a solution that allowed us to download
>> generated PDF's but it only seemed to work in IE and some people had
>> trouble using it from "outside connections."
>> 
>> What I wanted was a way to access dynamic/generated content that:
>> - Doesn't cause Wicket to be come non-responsive after the request
>> - Works in at least IE and FF
>> - Allows a file name to be provided
>> - Allows a mime type to be provided
>> 
>> After taking another stab at it, I was able to get that working.  Here is
>> what I ended up with:
>> 
>> public class ByteDataRequestTarget extends ByteArrayResource implements
>> IRequestTarget {
>>      private String fileName;
>> 
>>      public ByteDataRequestTarget(String mimeType, byte[] data, String
>> fileName) {
>>              super(mimeType, data, fileName);
>>              this.fileName = fileName;
>>      }
>> 
>>      public void detach(RequestCycle requestCycle) { }
>> 
>>      public void respond(RequestCycle requestCycle) {
>>              requestCycle.setRequestTarget(new
>> ResourceStreamRequestTarget(this.getResourceStream() ) {
>>                      public String getFileName() {
>>                              return fileName;
>>                      }
>>              } );
>>      }
>> }
>> 
>> And then I subclassed for different common file types like PDF and CSV. 
>> Those subclasses basically just provide the MIME type for the user and
>> automatically add the file extension.
>> 
>> public class PdfRequestTarget extends ByteDataRequestTarget {
>>      public PdfRequestTarget(byte[] data, String fileName) {
>>              super(Constants.PDF_MIME_TYPE, data, fileName+".pdf");
>>      }
>> }
>> 
>> To use the class, you do something like this:
>> 
>> new Button(buttonId, new Model("My Button") ) {
>>      public void onSubmit() {
>>              getRequestCycle().setRequestTarget(new
>> PdfRequestTarget(getSomePdfData(), "FileName") );
>>      }
>> };
>> 
>> I hope that helps.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Opening-DynamicWebResource-from-Button-AjaxButton--tp15459841p21550916.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to