List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.report.web.component.dataextraction.form.DetailForm.java
License:Open Source License
public void initialiseDetailForm() { arkCrudContainerVO.getDetailPanelFormContainer().add(modalWindow); searchIdTxtFld = new TextField<String>(Constants.SEARCH_ID); searchIdTxtFld.setEnabled(false);/*from www. ja v a 2 s.c om*/ searchNameTxtFld = new TextField<String>(Constants.SEARCH_NAME); searchNameTxtFld.add(new ArkDefaultFormFocusBehavior()); modalContentPanel = new EmptyPanel("content"); initIncludeGeno(); initDemographicFieldsModulePalette(); initBiospecimenFieldsModulePalette(); initBiocollectionFieldsModulePalette(); initPhenoDataSetFieldDisplaysModulePalette(); initSubjectCustomFieldDisplaysModulePalette(); initBiospecimenCustomFieldDisplaysModulePalette(); initBiocollectionCustomFieldDisplaysModulePalette(); initConsentStatusFieldsModulePalette(); arkCrudContainerVO.getDetailPanelFormContainer().add(subjectListFileUploadField); arkCrudContainerVO.getDetailPanelFormContainer().add(new AjaxLink("downloadSubjectList") { @Override public void onClick(AjaxRequestTarget target) { // TODO Auto-generated method stub target.appendJavaScript("alert('Link clicked');"); } }); clearButton = new AjaxButton("clearButton") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { subjectListFileUploadField.clearInput(); target.add(subjectListFileUploadField); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { subjectListFileUploadField.clearInput(); target.add(subjectListFileUploadField); } }; clearButton.add(new AttributeModifier("title", new Model<String>("Clear Attachment"))); addDetailFormComponents(); attachValidators(); }
From source file:au.org.theark.report.web.component.dataextraction.form.DetailForm.java
License:Open Source License
private void onCreateFilters(AjaxRequestTarget target, SearchVO searchVO) { IModel model = new Model<QueryFilterListVO>(new QueryFilterListVO(searchVO)); // handles for auto-gen biospecimenUid or manual entry modalContentPanel = new QueryFilterPanel("content", feedBackPanel, model, modalWindow); // Set the modalWindow title and content modalWindow.setTitle("Create Basic Filters"); modalWindow.setContent(modalContentPanel); modalWindow.show(target);/* ww w . j av a 2 s .c om*/ // refresh the feedback messages target.add(feedBackPanel); }
From source file:au.org.theark.report.web.component.dataextraction.form.DetailForm.java
License:Open Source License
public void addDetailFormComponents() { arkCrudContainerVO.getDetailPanelFormContainer().add(new AjaxButton("createFilters") { private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { onCreateFilters(target, containerForm.getModelObject()); target.add(feedBackPanel); };//from w w w . j a v a 2 s.c om protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { target.add(feedBackPanel); }; public boolean isVisible() { return true; }; public boolean isEnabled() { return containerForm.getModelObject().getSearch().getId() != null; }; }.setDefaultFormProcessing(false)); /* * item.add(new AttributeModifier(Constants.CLASS, new * AbstractReadOnlyModel() { * * private static final long serialVersionUID = 1L; * * @Override public String getObject() { return (item.getIndex() % 2 == * 1) ? Constants.EVEN : Constants.ODD; } })); */ arkCrudContainerVO.getDetailPanelFormContainer().add(searchIdTxtFld); arkCrudContainerVO.getDetailPanelFormContainer().add(searchNameTxtFld); arkCrudContainerVO.getDetailPanelFormContainer().add(includeGenoChkBox); arkCrudContainerVO.getDetailPanelFormContainer().add(demographicFieldsToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(biocollectionFieldsToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(biospecimenFieldsToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(phenoDatasetFieldDisplaysToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(subjectCustomFieldDisplaysToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(biospecimenCustomFieldDisplaysToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(biocollectionCustomFieldDisplaysToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(consentStatusFieldsToReturnPalette); arkCrudContainerVO.getDetailPanelFormContainer().add(clearButton); }
From source file:au.org.theark.report.web.component.dataextraction.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); // try {/*from w w w . j av a 2 s. c o m*/ //List<Search> resultList = iArkCommonService.getSearchesForThisStudy(getModelObject().getSearch().getStudy()); List<Search> resultList = iArkCommonService.getSearchesForSearch(getModelObject().getSearch()); if (resultList != null && resultList.size() == 0) { this.info("Searches with the specified criteria does not exist in the system."); target.add(feedbackPanel); } getModelObject().setListOfSearchesForResultList(resultList); listView.removeAll(); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); // } // catch (ArkSystemException arkEx) { // this.error("A system error has occured. Please try after sometime."); // } }
From source file:au.org.theark.report.web.component.dataextraction.SearchResultListPanel.java
License:Open Source License
/** * // www . j av a 2s. com * @param id * @param crudContainerVO * @param searchContainerForm */ public SearchResultListPanel(String id, ArkCrudContainerVO crudContainerVO, ContainerForm searchContainerForm) { super(id); arkCrudContainerVO = crudContainerVO; containerForm = searchContainerForm; modalWindow = new AbstractDetailModalWindow("detailModalWindow") { private static final long serialVersionUID = 1L; @Override protected void onCloseModalWindow(AjaxRequestTarget target) { // what to do when modal closed } }; add(modalWindow); AjaxButton ajaxButton = new AjaxButton("refresh") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(SearchResultListPanel.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Could not process download request"); }; }; ajaxButton.setVisible(true); ajaxButton.setDefaultFormProcessing(false); add(ajaxButton); setOutputMarkupId(true); //add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(10))); }
From source file:au.org.theark.report.web.component.dataextraction.SearchResultListPanel.java
License:Open Source License
private AjaxButton buildRunSearchButton(final Search search) { AjaxButton ajaxButton = new AjaxButton(au.org.theark.report.web.Constants.RUN_BATCH_QUERY) { private static final long serialVersionUID = 1L; @Override/*from www .j a v a 2 s . co m*/ protected void onSubmit(AjaxRequestTarget target, Form<?> form) { //TODO ASAP : this will be replaced by call to job //iArkCommonService.runSearch(search.getId()); try { SecurityUtils.getSubject(); search.setStartTime(new java.util.Date(System.currentTimeMillis())); search.setStatus("RUNNING"); search.setFinishTime(null); iArkCommonService.update(search); String currentUser = SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal() .toString(); DataExtractionUploadExecutor task = new DataExtractionUploadExecutor(iArkCommonService, search.getId(), currentUser);//, studyId); task.run(); target.add(SearchResultListPanel.this); target.appendJavaScript( "alert('Data files are being created as a background job. You may download when complete.');"); } catch (Exception e) { // TODO Auto-generated catch block System.out.println("TODO: decent logging and handling" + e.getMessage()); e.printStackTrace(); } finally { } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected Error: Could not process download request"); }; @Override public boolean isVisible() { //TODO return correct status return search.getStatus() != null && !search.getStatus().equalsIgnoreCase("RUNNING"); //return search.getStatus() != null && search.getStatus().equalsIgnoreCase("READY TO RUN") || true; } }; //ajaxButton.setVisible(true); ajaxButton.setDefaultFormProcessing(false); //log.warn("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n how many times is this run?"); //TODO move back //if (upload.getPayload() == null) //if (data == null) //ajaxButton.setVisible(false); return ajaxButton; }
From source file:au.org.theark.report.web.component.viewReport.consentDetails.filterForm.ConsentDetailsFilterForm.java
License:Open Source License
protected void onGenerateProcess(AjaxRequestTarget target) { Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); cpModel.getObject().getLinkSubjectStudy().setStudy(study); String reportTitle = study.getName() + " - Study Component Consent Details Report"; if (cpModel.getObject().getStudyComp() != null) { String studyComponent = cpModel.getObject().getStudyComp().getName(); reportTitle += " - " + studyComponent; }/*from w ww .j a v a 2 s . c o m*/ ReportTemplate reportTemplate = cpModel.getObject().getSelectedReportTemplate(); ReportOutputFormat reportOutputFormat = cpModel.getObject().getSelectedOutputFormat(); // show report ServletContext context = ((WebApplication) getApplication()).getServletContext(); File reportFile = null; reportFile = new File(context.getRealPath("/reportTemplates/" + reportTemplate.getTemplatePath())); JasperDesign design = null; JasperReport report = null; try { design = JRXmlLoader.load(reportFile); // System.out.println(" design -- created " ); if (design != null) { design.setName(reportTitle); // set the output file name to match report title if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.CSV_REPORT_FORMAT)) { design.setIgnorePagination(true); // don't paginate CSVs } report = JasperCompileManager.compileReport(design); // System.out.println(" design -- compiled " ); } } catch (JRException e) { reportFile = null; e.printStackTrace(); } // templateIS = getClass().getResourceAsStream("/reportTemplates/WebappReport.jrxml"); final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("BaseDir", new File(context.getRealPath("/reportTemplates"))); parameters.put("ReportTitle", reportTitle); Subject currentUser = SecurityUtils.getSubject(); String userName = "(unknown)"; if (currentUser.getPrincipal() != null) { userName = (String) currentUser.getPrincipal(); } parameters.put("UserName", userName); ConsentDetailsReportDataSource reportDS = new ConsentDetailsReportDataSource(reportService, cpModel.getObject()); JRResource reportResource = null; if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.PDF_REPORT_FORMAT)) { final JRResource pdfResource = new JRConcreteResource<PdfResourceHandler>(new PdfResourceHandler()); pdfResource.setJasperReport(report); pdfResource.setReportParameters(parameters).setReportDataSource(reportDS); // This code would emulate a file download as if clicked the user // clicked on the download link, but unfortunately it seems to // stuff up the Indicator (not hidden upon completion). // ResourceReference ref = new ResourceReference(study.getName() + "/" + report.getName() + "." + reportOutputFormat.getName()) { // protected Resource newResource() { // return pdfResource; // } // }; // String url = getRequestCycle().urlFor(ref).toString(); // getRequestCycle().setRequestTarget(new RedirectRequestTarget(url)); // add(new ResourceLink<Void>("linkToPdf", pdfResource)); reportResource = pdfResource; } else if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.CSV_REPORT_FORMAT)) { final JRResource csvResource = new JRConcreteResource<CsvResourceHandler>(new CsvResourceHandler()); csvResource.setJasperReport(report); csvResource.setReportParameters(parameters).setReportDataSource(reportDS); // This code would emulate a file download as if clicked the user // clicked on the download link, but unfortunately it seems to // stuff up the Indicator (not hidden upon completion). // ResourceReference ref = new ResourceReference(study.getName() + "/" + report.getName() + "." + reportOutputFormat.getName()) { // protected Resource newResource() { // return csvResource; // } // }; // String url = getRequestCycle().urlFor(ref).toString(); // getRequestCycle().setRequestTarget(new RedirectRequestTarget(url)); // add(new ResourceLink<Void>("linkToCsv", csvResource)); reportResource = csvResource; } if (reportResource != null) { reportOutputPanel.setReportResource(reportResource); reportOutputPanel.setVisible(true); target.add(reportOutputPanel); } }
From source file:au.org.theark.report.web.component.viewReport.form.AbstractReportFilterForm.java
License:Open Source License
private void initialiseComponents() { generateButton = new ArkBusyAjaxButton(Constants.GENERATE_BUTTON) { protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); onGenerateProcess(target);/* www. j a va 2 s. c o m*/ } public void onError(AjaxRequestTarget target, Form<?> form) { onErrorProcess(target); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new AjaxPostprocessingCallDecorator(super.getAjaxCallDecorator()) { private static final long serialVersionUID = 1L; @Override public CharSequence postDecorateScript(Component component, CharSequence script) { return script + "wicketHide('" + reportOutputPanel.getMarkupId() + "');"; } }; } }; initialiseOutputFormatChoice(); initialiseCustomFilterComponents(); this.add(outputFormatChoices); this.add(generateButton); }
From source file:au.org.theark.report.web.component.viewReport.form.AbstractReportFilterForm.java
License:Open Source License
protected void onErrorProcess(AjaxRequestTarget target) { target.add(feedbackPanel); }
From source file:au.org.theark.report.web.component.viewReport.phenoFieldDetails.filterForm.FieldDetailsFilterForm.java
License:Open Source License
protected void onGenerateProcess(AjaxRequestTarget target) { PhenoDataSetFieldDisplay cfd = cpModel.getObject().getPhenoDataSetFieldDisplay(); Study study = cpModel.getObject().getStudy(); String reportTitle = study.getName() + " - Phenotypic Field Details Report"; if (cfd.getPhenoDataSetGroup() != null) { String questionnaire = cfd.getPhenoDataSetGroup().getName(); reportTitle += " - " + questionnaire; }//w w w . j av a 2 s . c om ReportTemplate reportTemplate = cpModel.getObject().getSelectedReportTemplate(); ReportOutputFormat reportOutputFormat = cpModel.getObject().getSelectedOutputFormat(); // show report ServletContext context = ((WebApplication) getApplication()).getServletContext(); File reportFile = null; reportFile = new File(context.getRealPath("/reportTemplates/" + reportTemplate.getTemplatePath())); JasperDesign design = null; JasperReport report = null; try { design = JRXmlLoader.load(reportFile); // System.out.println(" design -- created " ); if (design != null) { design.setName(reportTitle); // set the output file name to match report title if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.CSV_REPORT_FORMAT)) { design.setIgnorePagination(true); // don't paginate CSVs } report = JasperCompileManager.compileReport(design); // System.out.println(" design -- compiled " ); } } catch (JRException e) { reportFile = null; e.printStackTrace(); } // templateIS = getClass().getResourceAsStream("/reportTemplates/WebappReport.jrxml"); final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("BaseDir", new File(context.getRealPath("/reportTemplates"))); parameters.put("ReportTitle", reportTitle); Subject currentUser = SecurityUtils.getSubject(); String userName = "(unknown)"; if (currentUser.getPrincipal() != null) { userName = (String) currentUser.getPrincipal(); } parameters.put("UserName", userName); PhenoDataSetFieldDetailsReportDataSource reportDS = new PhenoDataSetFieldDetailsReportDataSource( reportService, cpModel.getObject()); JRResource reportResource = null; if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.PDF_REPORT_FORMAT)) { final JRResource pdfResource = new JRConcreteResource<PdfResourceHandler>(new PdfResourceHandler()); pdfResource.setJasperReport(report); pdfResource.setReportParameters(parameters).setReportDataSource(reportDS); // This code would emulate a file download as if clicked the user // clicked on the download link, but unfortunately it seems to // stuff up the Indicator (not hidden upon completion). // ResourceReference ref = new ResourceReference(study.getName() + "/" + report.getName() + "." + reportOutputFormat.getName()) { // protected Resource newResource() { // return pdfResource; // } // }; // String url = getRequestCycle().urlFor(ref).toString(); // getRequestCycle().setRequestTarget(new RedirectRequestTarget(url)); // add(new ResourceLink<Void>("linkToPdf", pdfResource)); reportResource = pdfResource; } else if (reportOutputFormat.getName().equals(au.org.theark.report.service.Constants.CSV_REPORT_FORMAT)) { final JRResource csvResource = new JRConcreteResource<CsvResourceHandler>(new CsvResourceHandler()); csvResource.setJasperReport(report); csvResource.setReportParameters(parameters).setReportDataSource(reportDS); // This code would emulate a file download as if clicked the user // clicked on the download link, but unfortunately it seems to // stuff up the Indicator (not hidden upon completion). // ResourceReference ref = new ResourceReference(study.getName() + "/" + report.getName() + "." + reportOutputFormat.getName()) { // protected Resource newResource() { // return csvResource; // } // }; // String url = getRequestCycle().urlFor(ref).toString(); // getRequestCycle().setRequestTarget(new RedirectRequestTarget(url)); // add(new ResourceLink<Void>("linkToCsv", csvResource)); reportResource = csvResource; } if (reportResource != null) { reportOutputPanel.setReportResource(reportResource); reportOutputPanel.setVisible(true); target.add(reportOutputPanel); } }