Hello, I currently am using a downloadLink to export a csv file to the user. What I am currently doing is using a worker thread to handle the creation of the csv file while an AjaxSelfUpdatingTimerBehavior updates the GUI of its progress.. Then at completion the intent is to call downloadLink.onClick() to invoke the behind the scenes work and get the user the dialog box automatically to download the file. I get everything running fine until downloadLink.onClick() is called I get an ajax error:
"Wicket.Ajax.Call.failure: Error while parsing response: Error: Invalid XML: ��ࡱ�;�� ...`��Page 1�����=Bems_ID First_NameMiddle_Name Last_NameUser_Status" it looks like the csv file is being outputted to the ajax debugger. What is the best way to invoke the onClick method automatically of the DownloadLink class? Here is a snippet of what I am doing: private void setupDownloadLink() { IModel excelFileModel = new AbstractReadOnlyModel() { public Object getObject() { if(excelFile == null) { excelFile = new File("Error getting File"); } return excelFile; } }; auditDownloadlink = new DownloadLink("auditDownloadlink", excelFileModel) { public void onClick() { downLoadLinkClicked = true; if (newSearchWasInitialized) { newSearchWasInitialized = false; if (!extractionIsRunning) { worker = new CreateExcelExtractionWorker(); thread = new Thread(worker); thread.start(); extractionIsRunning = true; excelFile = null; return; } } if(!newSearchWasInitialized) { if (!extractionIsRunning) { super.onClick(); } } } }; auditDownloadlink.add(new Label("excelLabel", "Excel")); auditDownloadlink.setOutputMarkupPlaceholderTag(true); auditDownloadlink.setDeleteAfterDownload(true); auditDownloadlink.setCacheDuration(Duration.ONE_SECOND); auditDownloadlink.setVisible(false); findUserForm.add(auditDownloadlink); } Here basically when the user selects the button, it starts the worker thread.. Then when completed, the AjaxSelfUpdatingTimerBehavior will call the onClick() method, where in turn after each check is made then super.onClick() is called to process the downloading of the file as normal: public void onPostProcessTarget(AjaxRequestTarget target) { System.out.println("isRunning"); if(!extractionIsRunning) { if(downLoadLinkClicked) { System.out.println("refreshed"); progressModel.setObject("Extraction to Excel file complete. Click Download"); auditDownloadlink.addOrReplace(new Label("excelLabel", "Download")); target.add(findUserForm); target.add(progress); stop(target); System.out.println("isStopped"); downLoadLinkClicked = false; auditDownloadlink.onClick(); } } } }; progress.add(progressUpdateBehavior); progress.setOutputMarkupId(true); Do I have to attach it back to the requestCycle? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/calling-downloadLink-onClick-directly-tp4665125.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org