ResourceStreamRequestTarget implements IRequestTarget -- are you
suggesting that instead of instantiating an anonymous class that
implements IRequestTarget that I construct an instance of
ResourceStreamRequestTarget?
If so, its constructor requires an implementation of IResourceStream and
a string that contains the responseType. I suppose I could use
"text/plain" as the responseType, but where do I get the implementation
of IResourceStream? (That interface has a whole bunch of methods to
implement.)
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Johan
Compagner
Sent: Thursday, January 04, 2007 3:59 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] Letting users download flat file
you can use the ResourceStreamRequestTarget for that now and use
setFileName() for setting the filename.
johan
On 1/4/07, Frank Silbermann < [EMAIL PROTECTED]> wrote:
I am trying to make a button responde by downloading text to the
user which is saved as a .txt file. Igor suggested I look at
DownloadLink, which downloads a file when clicked.
The code of DownloadLink does not seem to set the content type;
does the system make an assumption based on the file's suffix?
Trying to adapt the code in DownloadLink, I came up with the
following event for my Button subclass:
public void onClick() {
getRequestCycle().setRequestTarget(
new IRequestTarget() {
public void detach(RequestCycle requestCycle) {}
public Object getLock(RequestCycle requestCycle) {
return null; }
public void respond(RequestCycle requestCycle) {
WebResponse r =
(WebResponse)requestCycle.getResponse();
r.setAttachmentHeader("myFilename.txt");
r.setContentType( "text/plain; name=myFileName.txt" );
PrintStream printStream = new
PrintStream(r.getOutputStream());
printStream.println("Line 1");
printStream.println("Line 2"); }
}
);
}
I expect that when I run it and click the button, the browser
should pop-up a box asking me if I wish to save file "myFileName.txt"
-- a file that should contain two lines of text. But when I run
it and click my button, it goes back to the server, but then nothing
happens --the browser does not prompt me to save anything.
Do you see anything wrong with what I've done?
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Igor
Vaynberg
Sent: Wednesday, January 03, 2007 11:35 AM
To: wicket-user@lists.sourceforge.net
Subject: Re: [Wicket-user] Letting users download flat file
the proper approach is to push a new request target into the
request cycle, see DownloadLink
-igor
On 1/3/07, Frank Silbermann < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
In my project, I have a button that lets the user
download the contents of a datatable in a form that MSExcel can
interpret:
Button button = new Button("excelExport") {
protected void onSubmit() {
getRequestCycle().setRequestTarget(new
ComponentRequestTarget(dataTable));
WebResponse wr=(WebResponse)getResponse();
wr.setContentType( "excel/ms-excel;
name=myFilename.xls" );
wr.setHeader("content-disposition",
"attachment;filename=myFilename.xls");
}
};
Suppose I want the button to download a text file
containing some arbitrary text (not necessarily the contents of a
DataTable). Would I do something like this?
Button button = new Button("textfileExport") {
protected void onSubmit() {
StringResponse response = new StringResponse();
response.write(
"Whatever I want contained in the output
text file..."
);
getRequestCycle().setResponse(response);
WebResponse wr=(WebResponse)getResponse();
wr.setContentType( "text/plain;
name=myFilename.txt" );
wr.setHeader("content-disposition",
"attachment;filename=myFilename.txt");
}
};
If not, what is the proper approach?
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the
chance to share your
opinions on IT & business topics through brief surveys -
and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance
to share your
opinions on IT & business topics through brief surveys - and
earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user