Dear all,

For some reason, I have 2 dropdownchoice(year and month) , according to year
and month  to decide the filename ,  then click button to download file.

for the ajaxsubmitLink, my code is below, now once the file is existed, that
mean after running: getRequestCycle().setRequestTarget(new
RedirectRequestTarget(url));
, there is one page to select the location and download the file, but after
that, the page stop, i mean i can not click the "uLink" again, 

anyone can give me some suggestion?

thank you very much




        AjaxSubmitLinkWithIndicator uLink = new
AjaxSubmitLinkWithIndicator("uLink", form) {

            protected void onSubmit(AjaxRequestTarget target, Form form) {

                System.out.println("on click
AjaxSubmitLinkWithIndicator...........");
                System.out.println("dobPanel.getDob() :" +
dobPanel.getDob());

                Calendar calendar = Calendar.getInstance();
                calendar.setTime(dobPanel.getDob());
                System.out.println("calendar.get(Calendar.YEAR) :" +
calendar.get(Calendar.YEAR));
                System.out.println("calendar.get(Calendar.MONTH) :" +
calendar.get(Calendar.MONTH));

                final String fn = orgDetailName + "_m_" +
calendar.get(Calendar.YEAR) + "_" + (calendar.get(Calendar.MONTH) + 1) +
".csv";
                logger.error("fn:" + fn);

                path = wholePath + calendar.get(Calendar.YEAR);
                logger.error("path.trim() + '/' + fn):" + path.trim() + "/"
+ fn);

                final File f1 = new File(path.trim() + "/" + fn);
                if (f1.exists()) {
                    ResourceReference rf = new ResourceReference("") {

                        @Override
                        protected WebResource newResource() {
                            return new WebResource() {

                                @Override
                                public IResourceStream getResourceStream() {
                                    //  throw new
UnsupportedOperationException("Not supported yet.");

                                    String endWithString =
fn.substring(fn.indexOf(".") + 1, fn.length());

                                    String contentType =
FileTypeMapping.getInstance().get(endWithString);

                                    if (fn.endsWith("xlsx")) {
                                        FileUtility fileUtil = new
FileUtility();
                                        byte[] bytes =
fileUtil.getBytesFromFile(f1);

                                        return new
ByteArrayResourceStream(bytes, contentType);

                                    } else if (fn.endsWith("csv")) {
                                        CharSequence maps =
generateCsvFile(f1);

                                        return new
StringResourceStream(maps, contentType);

                                    } else {
                                        return null;
                                    }
                                }

                                @Override
                                protected void setHeaders(WebResponse
response) {
                                    super.setHeaders(response);
                                    response.setAttachmentHeader(fn);
                                }
                            };
                        }
                        ;
                    };

                    String url =
getRequestCycle().get().urlFor(rf).toString();
                    logger.error("url:" + url);
                    getRequestCycle().setRequestTarget(new
RedirectRequestTarget(url));

                } else {

                    cfp.info("There is no file for the day.");
                    cfp.setVisible(true);
                    target.addComponent(cfp);
                }
            }

        };
 
-- 
View this message in context: 
http://www.nabble.com/why-AjaxSubmitLink-calling-getRequestCycle%28%29.setRequestTarget%28new-RedirectRequestTarget%28url%29%29-later-%2C-can-not-run-the-form-again--tp21249140p21249140.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