List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.lims.web.component.subjectlims.subject.SubjectContainerPanel.java
License:Open Source License
protected WebMarkupContainer initialiseSearchResults() { searchResultListPanel = new SearchResultListPanel("searchResults", arkContextMarkup, containerForm, arkCrudContainerVO, studyNameMarkup, studyLogoMarkup, treeModel); subjectProvider = new ArkDataProvider2<LimsVO, LinkSubjectStudy>() { private static final long serialVersionUID = 1L; public int size() { // Restrict search if Study selected in Search form List<Study> studyList = new ArrayList<Study>(0); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { Study study = iArkCommonService.getStudy(sessionStudyId); if (criteriaModel.getObject().getStudy() != null && criteriaModel.getObject().getStudy().getId() != null) { // Restrict search to study in drop-down studyList.add(criteriaModel.getObject().getStudy()); } else { if (study.getParentStudy() != null && study.getParentStudy().equals(study)) { studyList = criteriaModel.getObject().getStudyList(); if (studyList.isEmpty()) { studyList = containerForm.getStudyListForUser(); }//from w w w . ja va 2 s . com } else { studyList.add(study); } } } return iLimsSubjectService.getSubjectCount(criteriaModel.getObject(), studyList); } public Iterator<LinkSubjectStudy> iterator(int first, int count) { List<LinkSubjectStudy> listSubjects = new ArrayList<LinkSubjectStudy>(0); // Restrict search if Study selected in Search form List<Study> studyList = new ArrayList<Study>(0); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { Study study = iArkCommonService.getStudy(sessionStudyId); if (criteriaModel.getObject().getStudy() != null && criteriaModel.getObject().getStudy().getId() != null) { // Restrict search to study in drop-down studyList.add(criteriaModel.getObject().getStudy()); } else { if (study.getParentStudy() != null && study.getParentStudy().equals(study)) { studyList = criteriaModel.getObject().getStudyList(); if (studyList.isEmpty()) { studyList = containerForm.getStudyListForUser(); } } else { studyList.add(study); } } } listSubjects = iLimsSubjectService.searchPageableSubjects(criteriaModel.getObject(), studyList, first, count); return listSubjects.iterator(); } }; subjectProvider.setCriteriaModel(this.cpModel); dataView = searchResultListPanel.buildDataView(subjectProvider); dataView.setItemsPerPage( iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(arkCrudContainerVO.getSearchResultPanelContainer()); } }; searchResultListPanel.add(pageNavigator); searchResultListPanel.add(dataView); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultListPanel); return arkCrudContainerVO.getSearchResultPanelContainer(); }
From source file:au.org.theark.phenotypic.web.component.phenodatacategory.form.DetailForm.java
License:Open Source License
protected void onDeleteConfirmed(AjaxRequestTarget target, String selection) { try {// w w w . j a v a2s. c om iPhenotypicService.deletePhenoDataSetCategory(getModelObject()); this.info( "Field " + getModelObject().getPhenoDataSetCategory().getName() + " was deleted successfully"); } catch (ArkSystemException e) { this.error(e.getMessage()); } catch (EntityCannotBeRemoved e) { this.error(e.getMessage()); } // Display delete confirmation message target.add(feedBackPanel); // TODO Implement Exceptions in PhentoypicService // } catch (UnAuthorizedOperation e) { this.error("You are not authorised to manage study components for the given study " + // study.getName()); processFeedback(target); } catch (ArkSystemException e) { // this.error("A System error occured, we will have someone contact you."); processFeedback(target); } // Move focus back to Search form editCancelProcess(target); // this ends up calling onCancel(target) }
From source file:au.org.theark.phenotypic.web.component.phenodatacategory.form.SearchForm.java
License:Open Source License
/** * Get custom field category collection from model. * @return/*from ww w . j av a2 s . c o m*/ */ /*private Collection<PhenoDataSetCategory> getParentCategoryCollectionFromModel(){ PhenoDataSetCategory phenoDataSetCategory=cpModel.getObject().getPhenoDataSetCategory(); Study study=phenoDataSetCategory.getStudy(); ArkFunction arkFunction=phenoDataSetCategory.getArkFunction(); try { //phenoDataSetCategoryCollection = iPhenotypicService.getPhenoParentCategoryList(study, arkFunction); } catch (ArkSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } return phenoDataSetCategoryCollection; }*/ @Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); final Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); // Get a list of all Fields for the Study in context Study study = iArkCommonService.getStudy(sessionStudyId); getModelObject().getPhenoDataSetCategory().setStudy(study); long count = iPhenotypicService.getPhenoDataSetCategoryCount(getModelObject().getPhenoDataSetCategory()); if (count <= 0L) { this.info("No records match the specified criteria."); target.add(feedbackPanel); } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);// Make the WebMarkupContainer that houses the search results visible target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.phenotypic.web.component.phenodatacategory.form.SearchForm.java
License:Open Source License
@Override protected void onNew(AjaxRequestTarget target) { target.add(feedbackPanel); // Instead of having to reset the criteria, we just copy the criteria across PhenoDataSetCategory pdscat = getModelObject().getPhenoDataSetCategory(); CompoundPropertyModel<PhenoDataSetCategoryVO> newModel = new CompoundPropertyModel<PhenoDataSetCategoryVO>( new PhenoDataSetCategoryVO()); PhenoDataSetCategory newModelPDSC = newModel.getObject().getPhenoDataSetCategory(); // Copy all the customField attributes across from the SearchForm newModelPDSC.setStudy(pdscat.getStudy()); newModelPDSC.setArkFunction(pdscat.getArkFunction()); newModelPDSC.setName(pdscat.getName()); //newCF.setFieldType(cf.getFieldType()); newModelPDSC.setDescription(pdscat.getDescription()); /* //w w w .j av a2s. c o m * NB: Do NOT copy unitType across because it is a Textfield on the SearchForm. * If you copy this through, then DetailForm will have transient error during onSave(..). * Also, if the user chooses fieldType==DATE, this and unitType is not a valid combination * (but unitTypeDdc will be disabled, so the user can't make it null for it to be valid). */ //newCF.setMinValue(cf.getMinValue()); //newCF.setMaxValue(cf.getMaxValue()); //newModelPDSC.setOrderNumber(pdscat.getOrderNumber()); //newModelPDSC.setParentCategory(pdscat.getParentCategory()); //newModel.getObject().setUseCustomFieldCategoryDisplay(getModelObject().isUseCustomFieldCategoryDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); // Reset model's CF object (do NOT replace the CustomFieldVO in the model) pdscat = new PhenoDataSetCategory(); pdscat.setStudy(newModelPDSC.getStudy()); pdscat.setArkFunction(newModelPDSC.getArkFunction()); getModelObject().setPhenoDataSetCategory(pdscat); preProcessDetailPanel(target); }
From source file:au.org.theark.phenotypic.web.component.phenodatacategory.PhenoDataCategoryContainerPanel.java
License:Open Source License
protected WebMarkupContainer initialiseSearchResults() { SearchResultListPanel searchResultListPanel = new SearchResultListPanel("resultListPanel", cpModel, arkCrudContainerVO, feedBackPanel); // Data providor to paginate resultList phenoDataSetCategoryProvider = new ArkDataProvider2<PhenoDataSetCategory, PhenoDataSetCategory>() { private static final long serialVersionUID = 1L; public int size() { return (int) iPhenotypicService.getPhenoDataSetCategoryCount(criteriaModel.getObject());//todo safe int conversion }//from w ww . j a v a 2 s . c o m public Iterator<PhenoDataSetCategory> iterator(int first, int count) { List<PhenoDataSetCategory> listCustomFieldCategories = new ArrayList<PhenoDataSetCategory>(); if (isActionPermitted()) { listCustomFieldCategories = iPhenotypicService .searchPageablePhenoDataSetCategories(criteriaModel.getObject(), first, count); } return (listCustomFieldCategories).iterator(); } }; // Set the criteria for the data provider phenoDataSetCategoryProvider .setCriteriaModel(new PropertyModel<PhenoDataSetCategory>(cpModel, "phenoDataSetCategory")); dataView = searchResultListPanel.buildDataView(phenoDataSetCategoryProvider); dataView.setItemsPerPage( iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(arkCrudContainerVO.getSearchResultPanelContainer()); } }; searchResultListPanel.add(pageNavigator); searchResultListPanel.add(dataView); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultListPanel); return arkCrudContainerVO.getSearchResultPanelContainer(); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java
License:Open Source License
/** * initialise Field Types.//from ww w . ja v a2s .c om */ private void initFieldTypeDdc() { List<FieldType> fieldTypeCollection = iArkCommonService.getFieldTypes(); ChoiceRenderer fieldTypeRenderer = new ChoiceRenderer(Constants.FIELDTYPE_NAME, Constants.FIELDTYPE_ID); fieldTypeDdc = new DropDownChoice<FieldType>(Constants.FIELDVO_PHENODATASET_FIELD_TYPE, fieldTypeCollection, fieldTypeRenderer) { @Override protected void onBeforeRender() { if (!isNew()) { // Disable fieldType if data exists for the field setEnabled(!cpModel.getObject().getPhenoDataSetField().getPhenoFieldHasData()); } super.onBeforeRender(); } }; fieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { updateEncodedValueFld(); updateUnitTypeDdc(); initMinMaxValuePnls(); target.add(minMaxValueEntryWMC); target.add(missingValueEntryWMC); target.add(defaultValueEntryWMC); target.add(fieldEncodedValuesTxtFld); target.add(fieldUnitTypeDdc); target.add(fieldUnitTypeTxtFld); target.add(fieldAllowMultiselectChkBox); } }); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java
License:Open Source License
/** * Call this after the constructor is finished in detail panel. *///from w w w.jav a 2 s .com public void initialiseDetailForm() { Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); fieldIdTxtFld = new TextField<String>(Constants.FIELDVO_PHENODATASET_ID); fieldNameTxtFld = new TextField<String>(Constants.FIELDVO_PHENODATASET_NAME); fieldNameTxtFld.add(new ArkDefaultFormFocusBehavior()); fieldDescriptionTxtAreaFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_DESCRIPTION); fieldLabelTxtAreaFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_FIELD_LABEL); //fieldMissingValueTxtFld = new TextField<String>(Constants.FIELDVO_CUSTOMFIELD_MISSING_VALUE); fieldDisplayRequiredChkBox = new CheckBox(Constants.FIELDVO_PHENODATASET_REQUIRED); fieldAllowMultiselectChkBox = new CheckBox(Constants.FIELDVO_PHENODATASET_ALLOW_MULTIPLE_SELECTION) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return (fieldEncodedValuesTxtFld.getModelObject() != null); } }; /*if (getModelObject().isUsePhenoDataSetFieldDisplay()) { // TODO: Have not implemented position support right now phenoDataSetDisplayPositionPanel = new EmptyPanel("phenoDataSetFieldDisplayPositionPanel"); }*/ // else { phenoDataSetDisplayPositionPanel = new EmptyPanel("phenoDataSetFieldDisplayPositionPanel"); //} // Initialise Drop Down Choices initFieldTypeDdc(); initUnitTypeDdc(); // Min and Max Value panels rely on fieldTypeDdc being already established minMaxValueEntryWMC = new WebMarkupContainer("minMaxValueEntryWMC"); minMaxValueEntryWMC.setOutputMarkupPlaceholderTag(true); missingValueEntryWMC = new WebMarkupContainer("missingValueEntryWMC"); missingValueEntryWMC.setOutputMarkupPlaceholderTag(true); defaultValueEntryWMC = new WebMarkupContainer("defaultValueEntryWMC"); defaultValueEntryWMC.setOutputMarkupPlaceholderTag(true); // unitType and encodedValues rely on fieldTypeDdc being already established fieldEncodedValuesTxtFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_ENCODED_VALUES); fieldEncodedValuesTxtFld.setOutputMarkupId(true); fieldEncodedValuesTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(fieldAllowMultiselectChkBox); } }); updateEncodedValueFld(); updateUnitTypeDdc(); // Have to Edit, before allowing delete deleteButton.setEnabled(false); //defaultValueTextArea = new TextArea<String>(Constants.FIELDVO_PHENODATASET_DEFAULT_VALUE); addDetailFormComponents(); attachValidators(); initMinMaxValuePnls(); historyButtonPanel = new HistoryButtonPanel(this, arkCrudContainerVO.getEditButtonContainer(), arkCrudContainerVO.getDetailPanelFormContainer()); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java
License:Open Source License
protected void onDeleteConfirmed(AjaxRequestTarget target, String selection) { try {/*from ww w . j ava 2 s . c o m*/ iPhenotypicService.deletePhenoDataSetField(getModelObject()); this.info("Field " + getModelObject().getPhenoDataSetField().getName() + " was deleted successfully"); } catch (ArkSystemException e) { this.error(e.getMessage()); } catch (EntityCannotBeRemoved e) { this.error(e.getMessage()); } // Display delete confirmation message target.add(feedBackPanel); // TODO Implement Exceptions in PhentoypicService // } catch (UnAuthorizedOperation e) { this.error("You are not authorised to manage study components for the given study " + // study.getName()); processFeedback(target); } catch (ArkSystemException e) { // this.error("A System error occured, we will have someone contact you."); processFeedback(target); } // Move focus back to Search form editCancelProcess(target); // this ends up calling onCancel(target) }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); final Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); // Get a list of all Fields for the Study in context Study study = iArkCommonService.getStudy(sessionStudyId); getModelObject().getPhenoDataSetField().setStudy(study); long count = iPhenotypicService.getPhenoFieldCount(getModelObject().getPhenoDataSetField()); if (count <= 0L) { this.info("No records match the specified criteria."); target.add(feedbackPanel);/* w ww . ja v a 2 s . com*/ } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.SearchForm.java
License:Open Source License
@Override /**/*from ww w . j av a2 s . c o m*/ * * @param target */ protected void onNew(AjaxRequestTarget target) { target.add(feedbackPanel); // Instead of having to reset the criteria, we just copy the criteria // across PhenoDataSetField phenoField = getModelObject().getPhenoDataSetField(); CompoundPropertyModel<PhenoDataSetFieldVO> newModel = new CompoundPropertyModel<PhenoDataSetFieldVO>( new PhenoDataSetFieldVO()); PhenoDataSetField newPhenoDataSet = newModel.getObject().getPhenoDataSetField(); // Copy all the phenoDataSetField attributes across from the SearchForm newPhenoDataSet.setStudy(phenoField.getStudy()); newPhenoDataSet.setArkFunction(phenoField.getArkFunction()); newPhenoDataSet.setName(phenoField.getName()); newPhenoDataSet.setFieldType(phenoField.getFieldType()); newPhenoDataSet.setDescription(phenoField.getDescription()); /* * NB: Do NOT copy unitType across because it is a Textfield on the * SearchForm. If you copy this through, then DetailForm will have * transient error during onSave(..). Also, if the user chooses * fieldType==DATE, this and unitType is not a valid combination (but * unitTypeDdc will be disabled, so the user can't make it null for it * to be valid). */ newPhenoDataSet.setMinValue(phenoField.getMinValue()); newPhenoDataSet.setMaxValue(phenoField.getMaxValue()); //newModel.getObject().setUsePhenoDataSetFieldDisplay(getModelObject().isUsePhenoDataSetFieldDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); //this.unitTypeDropDownOn, this.subjectCustomField); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); // Reset model's CF object (do NOT replace the CustomFieldVO in the // model) phenoField = new PhenoDataSetField(); phenoField.setStudy(newPhenoDataSet.getStudy()); phenoField.setArkFunction(newPhenoDataSet.getArkFunction()); getModelObject().setPhenoDataSetField(phenoField); preProcessDetailPanel(target); }