Example usage for org.apache.wicket.ajax AjaxRequestTarget add

List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxRequestTarget add.

Prototype

void add(Component... components);

Source Link

Document

Adds components to the list of components to be rendered.

Usage

From source file:au.org.theark.report.web.component.viewReport.ReportSelectPanel.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
private AjaxLink buildLink(final ReportTemplate reportTemplate) {

    AjaxLink link = new AjaxLink("reportTemplate.link") {

        private static final long serialVersionUID = 1L;

        @Override/*from ww  w. j  a va  2 s . c o  m*/
        public void onClick(AjaxRequestTarget target) {
            // Perform security check upon selection of the report
            Subject subject = SecurityUtils.getSubject();
            boolean securityCheckOk = false;
            try {
                String userRole = iArkCommonService.getUserRole(subject.getPrincipal().toString(),
                        reportTemplate.getFunction(), reportTemplate.getModule(),
                        reportSelectCPM.getObject().getStudy());
                if (userRole.length() > 0) {
                    securityCheckOk = true;
                }
            } catch (EntityNotFoundException e) {
                // TODO I don't like this kind of code - if there isn't a record, we should just return NULL.
                // Only if it really is an error to not have a record, then we should throw an exception.
            }

            if (securityCheckOk == false) {
                this.error(
                        "You do not have enough privileges to access this report.  If you believe this is incorrect, then please contact your administrator.");
            } else if (reportTemplate.getName().equals(Constants.STUDY_SUMMARY_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudySummaryReportContainer selectedReportPanel = new StudySummaryReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_LEVEL_CONSENT_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyLevelConsentReportContainer selectedReportPanel = new StudyLevelConsentReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_COMP_CONSENT_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    ConsentDetailsReportContainer selectedReportPanel = new ConsentDetailsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.PHENO_FIELD_DETAILS_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    PhenoFieldDetailsReportContainer selectedReportPanel = new PhenoFieldDetailsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.STUDY_USER_ROLE_PERMISSIONS)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyUserRolePermissionsReportContainer selectedReportPanel = new StudyUserRolePermissionsReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    WorkResearcherCostReportContainer selectedReportPanel = new WorkResearcherCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_RESEARCHER_DETAIL_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    WorkResearcherDetailCostReportContainer selectedReportPanel = new WorkResearcherDetailCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.WORK_STUDY_DETAIL_COST_REPORT_NAME)) {
                if (reportSelectCPM.getObject().getStudy() == null) {
                    this.error("This report requires a study in context. Please put a study in context first.");
                } else {
                    StudyCostReportContainer selectedReportPanel = new StudyCostReportContainer(
                            "selectedReportContainerPanel");
                    selectedReportPanel.setOutputMarkupId(true);
                    // Replace the old selectedReportPanel with this new one
                    reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                    reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                    selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                    target.add(reportContainerVO.getSelectedReportContainerWMC());
                    this.info(reportTemplate.getName() + " template selected.");
                }
            } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_SUMMARY_REPORT_NAME)) {
                BiospecimenSummaryReportContainer selectedReportPanel = new BiospecimenSummaryReportContainer(
                        "selectedReportContainerPanel");
                selectedReportPanel.setOutputMarkupId(true);
                // Replace the old selectedReportPanel with this new one
                reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                target.add(reportContainerVO.getSelectedReportContainerWMC());
                this.info(reportTemplate.getName() + " template selected.");

            } else if (reportTemplate.getName().equals(Constants.LIMS_BIOSPECIMEN_DETAIL_REPORT_NAME)) {
                BiospecimenDetailsReportContainer selectedReportPanel = new BiospecimenDetailsReportContainer(
                        "selectedReportContainerPanel");
                selectedReportPanel.setOutputMarkupId(true);
                // Replace the old selectedReportPanel with this new one
                reportContainerVO.getSelectedReportPanel().replaceWith(selectedReportPanel);
                reportContainerVO.setSelectedReportPanel(selectedReportPanel);
                selectedReportPanel.initialisePanel(reportContainerVO.getFeedbackPanel(), reportTemplate);
                target.add(reportContainerVO.getSelectedReportContainerWMC());
                this.info(reportTemplate.getName() + " template selected.");

            } else {
                this.error("System error: " + reportTemplate.getName()
                        + " has no implementation or has been deprecated.");
            }
            target.add(reportContainerVO.getFeedbackPanel());
        }
    };

    // Add the label for the link
    Label nameLinkLabel = new Label("reportTemplate.name", reportTemplate.getName());
    link.add(nameLinkLabel);
    return link;

}

From source file:au.org.theark.report.web.component.viewReport.studyLevelConsent.filterForm.StudyLevelConsentDetailsFilterForm.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 consentType = "Study-level Consent";
    String reportTitle = study.getName() + " - Consent Details Report - " + consentType;

    ReportTemplate reportTemplate = cpModel.getObject().getSelectedReportTemplate();
    ReportOutputFormat reportOutputFormat = cpModel.getObject().getSelectedOutputFormat();

    // show report
    ServletContext context = ((WebApplication) getApplication()).getServletContext();
    File reportFile = null;//from w  w w.ja va2 s.com

    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);
    StudyLevelConsentReportDataSource reportDS = new StudyLevelConsentReportDataSource(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);
        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);
        reportResource = csvResource;
    }
    if (reportResource != null) {
        reportOutputPanel.setReportResource(reportResource);
        JRResource other = generateOtherIDResource(target);
        if (other != null) {
            reportOutputPanel.setOtherIDReportResource(generateOtherIDResource(target));
        }
        reportOutputPanel.setVisible(true);
        target.add(reportOutputPanel);
    }
}

From source file:au.org.theark.report.web.component.viewReport.studySummary.filterForm.StudySummaryFilterForm.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);

    String reportTitle = study.getName() + " - Study Summary Report";

    ReportTemplate reportTemplate = cpModel.getObject().getSelectedReportTemplate();
    ReportOutputFormat reportOutputFormat = cpModel.getObject().getSelectedOutputFormat();

    // show report
    ServletContext context = ((WebApplication) getApplication()).getServletContext();
    File reportFile = null;//  www.  j ava  2 s  .  c  om

    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);
    StudySummaryReportDataSource reportDS = new StudySummaryReportDataSource(reportService, study);

    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.studyUserRolePermissions.filterForm.StudyUserRolePermissionsFilterForm.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);

    String reportTitle = study.getName() + " - Study User Role Permissions Report";

    ReportTemplate reportTemplate = cpModel.getObject().getSelectedReportTemplate();

    ReportOutputFormat reportOutputFormat = cpModel.getObject().getSelectedOutputFormat();

    // show report
    ServletContext context = ((WebApplication) getApplication()).getServletContext();
    File reportFile = null;//from w w w  . ja v a2  s.c  o  m

    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);
    StudyUserRolePermissionsReportDataSource reportDS = new StudyUserRolePermissionsReportDataSource(
            reportService, study);

    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.study.web.component.address.form.DetailForm.java

License:Open Source License

private void initialiaseCountryDropDown() {
    List<Country> countryList = iArkCommonService.getCountries();
    ChoiceRenderer<Country> defaultChoiceRenderer = new ChoiceRenderer<Country>(Constants.NAME, Constants.ID);
    countryChoice = new DropDownChoice<Country>("address.country", countryList, defaultChoiceRenderer);

    // Attach a behavior, so when it changes it does something
    countryChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = 1L;

        @Override/*w  ww . ja v a2  s  .c o  m*/
        protected void onUpdate(AjaxRequestTarget target) {
            updateStateChoices(countryChoice.getModelObject());
            target.add(stateSelector);
        }
    });
}

From source file:au.org.theark.study.web.component.address.form.DetailForm.java

License:Open Source License

@Override
protected void processErrors(AjaxRequestTarget target) {
    target.add(otherStateInvalidError);
    target.add(feedBackPanel);

}

From source file:au.org.theark.study.web.component.address.form.SearchForm.java

License:Open Source License

private void initialiaseCountryDropDown() {

    List<Country> countryList = iArkCommonService.getCountries();
    ChoiceRenderer<Country> defaultChoiceRenderer = new ChoiceRenderer<Country>(Constants.NAME, Constants.ID);
    countryChoice = new DropDownChoice<Country>("address.country", countryList, defaultChoiceRenderer);
    // Attach a behavior, so when it changes it does something
    countryChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = 1L;

        @Override//from   w  w w  .jav a 2  s.  c  o m
        protected void onUpdate(AjaxRequestTarget target) {
            updateStateChoices(countryChoice.getModelObject());
            target.add(stateSelector);
        }
    });
}

From source file:au.org.theark.study.web.component.address.form.SearchForm.java

License:Open Source License

@Override
protected void onSearch(AjaxRequestTarget target) {
    target.add(feedbackPanel);
    // Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession().getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
    Long sessionPersonId = (Long) SecurityUtils.getSubject().getSession()
            .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
    // String sessionPersonType = (String) SecurityUtils.getSubject().getSession().getAttribute(au.org.theark.core.Constants.PERSON_TYPE);// Subject
    // or contact placed insession
    try {//from  w  ww  . j ava2s. com

        // if(sessionPersonType.equalsIgnoreCase(au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)){
        //
        // }else if(sessionPersonType.equalsIgnoreCase(au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_CONTACT)){
        //
        // }
        Address address = getModelObject().getAddress();
        address.setPerson(studyService.getPerson(sessionPersonId));
        Collection<Address> addressList = studyService.getPersonAddressList(sessionPersonId, address);
        if (addressList != null && addressList.size() == 0) {
            this.info("No records match the specified criteria.");
            target.add(feedbackPanel);
        }

        getModelObject().setAddresses(addressList);
        listView.removeAll();
        arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);
        target.add(arkCrudContainerVO.getSearchResultPanelContainer());
    } catch (EntityNotFoundException entityNotFoundException) {
        this.warn("There are no addresses available for the specified criteria.");
        target.add(feedbackPanel);

    } catch (ArkSystemException arkException) {
        this.error("The Ark Application has encountered a system error.");
        target.add(feedbackPanel);
    }

}

From source file:au.org.theark.study.web.component.attachments.form.DetailForm.java

License:Open Source License

protected void onDeleteConfirmed(AjaxRequestTarget target, String selection) {
    // Display delete confirmation message
    target.add(feedBackPanel);
    // Move focus back to Search form
    SubjectVO subjectVO = new SubjectVO();
    setModelObject(subjectVO);//from  ww w  .  j  a v  a  2  s.  c om
    onCancel(target);
}

From source file:au.org.theark.study.web.component.attachments.form.SearchForm.java

License:Open Source License

@Override
protected void onSearch(AjaxRequestTarget target) {
    target.add(feedbackPanel);
    SubjectFile subjectFile = new SubjectFile();
    subjectFile = getModelObject().getSubjectFile();
    Collection<SubjectFile> subjectFileList = new ArrayList<SubjectFile>();

    try {/*ww  w .  ja  v a2 s  .c  o  m*/
        LinkSubjectStudy linkSubjectStudy = null;
        Long sessionPersonId = (Long) SecurityUtils.getSubject().getSession()
                .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
        Long studyId = (Long) SecurityUtils.getSubject().getSession()
                .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
        Study study = iArkCommonService.getStudy(studyId);
        linkSubjectStudy = iArkCommonService.getSubject(sessionPersonId, study);
        subjectFile.setLinkSubjectStudy(linkSubjectStudy);
    } catch (EntityNotFoundException e1) {
        this.error("There is no subject in context.");
        target.add(feedbackPanel);
    }

    try {
        // Look up based on criteria via back end.
        subjectFileList = iStudyService.searchSubjectFile(subjectFile);

        if (subjectFileList != null && subjectFileList.size() == 0) {
            this.info("There are no subject files for the specified criteria.");
            target.add(feedbackPanel);
        }

        getModelObject().setSubjectFileList(subjectFileList);
        pageableListView.removeAll();
        arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);
        target.add(arkCrudContainerVO.getSearchResultPanelContainer());

    } catch (EntityNotFoundException e) {
        log.error(e.getMessage());
    } catch (ArkSystemException e) {
        log.error(e.getMessage());
    }
}