Would some one care to comment this?

 

Regards Nino

 

  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nino Wael
Sent: 12. december 2006 11:55
To: wicket-user@lists.sourceforge.net
Subject: [Wicket-user] Download file/ trying to use webresource using wicket1.2 
plain

 

Hi I've trying to use the this example:

 

 

http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html#BestPracticesandGotchas-Startingdownloadafterformsubmission%2528Wicket1.2%2529

 

WebResource export = new WebResource() {
       @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");
       }
     };
     export.setCacheable(false);
 
     new ResourceLink(this, "exportLink", export);

 

 

 

My implementation (I am using wicket 1.2):

                                            String path = 
req.getSession(false).getServletContext()

                                            .getRealPath("/report");

                                            
path+="\\"+uiResult.getUrlWord().replaceAll("report/","");

 

                                            final File myFile = new File(path);

                                            WebResource export = new 
WebResource() {

                                                   

                                                   public IResourceStream 
getResourceStream() {

                                                     

                                                     return new  
FileResourceStream(myFile);

                                                   }

 

                                                   

                                                   protected void 
setHeaders(WebResponse response) {

                                                     super.setHeaders(response);

                                                     

                                                     
response.setAttachmentHeader(uiResult.getUrlWord().replaceAll("report/",""));

                                                   }

                                                 };

                                                 export.setCacheable(false);

 

                                                 form.add( new 
ResourceLink("word", export));

 

This does nothing but a page reload.

 

Does it only work with wicket 1.2.3, what should I do then? Use the wicket 1.1 
example or ?

 

 

Regards Nino

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

Reply via email to