List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.core.web.component.customfield.form.DetailForm.java
License:Open Source License
@Override protected void processErrors(AjaxRequestTarget target) { target.add(feedBackPanel); }
From source file:au.org.theark.core.web.component.customfield.form.DetailForm.java
License:Open Source License
protected void onDeleteConfirmed(AjaxRequestTarget target, String selection) { try {/* w w w. j a va 2 s. com*/ iArkCommonService.deleteCustomField(getModelObject()); this.info("Field " + getModelObject().getCustomField().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.core.web.component.customfield.form.SearchForm.java
License:Open Source License
/** * initialize Custom Filed Types./*from w w w .ja v a2 s . co m*/ */ private void initCustomFieldTypeDdc() { Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); java.util.Collection<CustomFieldType> customFieldTypeCollection = iArkCommonService .getCustomFieldTypes(arkModule); ChoiceRenderer customfieldTypeRenderer = new ChoiceRenderer(Constants.CUSTOM_FIELD_TYPE_NAME, Constants.CUSTOM_FIELD_TYPE_ID); customFieldTypeDdc = new DropDownChoice<CustomFieldType>(Constants.FIELDVO_CUSTOMFIELD_CUSTOM_FIELD_TYPE, (List) customFieldTypeCollection, customfieldTypeRenderer); customFieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { cpModel.getObject().getCustomField().setCustomFieldType(customFieldTypeDdc.getModelObject()); Collection<CustomFieldCategory> customFieldCategoryCollection = getCategoriesListInCustomFieldsByCustomFieldType(); categoryPanel.remove(customeFieldCategoryDdc); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID); customeFieldCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY, (List) customFieldCategoryCollection, customfieldCategoryRenderer); customeFieldCategoryDdc.setOutputMarkupId(true); customeFieldCategoryDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { customFieldCategoryChangeEvent(target); } }); customFieldCategoryChangeEvent(target); categoryPanel.add(customeFieldCategoryDdc); target.add(customeFieldCategoryDdc); target.add(categoryPanel); } }); }
From source file:au.org.theark.core.web.component.customfield.form.SearchForm.java
License:Open Source License
/** * //from www .ja v a 2 s .co m * @param target */ private void customFieldCategoryChangeEvent(AjaxRequestTarget target) { cpModel.getObject().getCustomField().setCustomFieldCategory(customeFieldCategoryDdc.getModelObject()); orderNumberPanel.remove(customeFieldCategoryOrderNoTxtFld); customeFieldCategoryOrderNoTxtFld = new TextField<Long>( Constants.FIELDVO_CUSTOMFIELD_CUSTOEMFIELDCATEGORY_ORDERNUMBER); customeFieldCategoryOrderNoTxtFld.setOutputMarkupId(true); customeFieldCategoryOrderNoTxtFld.setEnabled(false); orderNumberPanel.add(customeFieldCategoryOrderNoTxtFld); target.add(customeFieldCategoryOrderNoTxtFld); target.add(orderNumberPanel); }
From source file:au.org.theark.core.web.component.customfield.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().getCustomField().setStudy(study); long count = iArkCommonService.getCustomFieldCount(getModelObject().getCustomField()); if (count <= 0L) { this.info("No records match the specified criteria."); target.add(feedbackPanel);/* w ww. ja v a 2 s . co m*/ } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.core.web.component.customfield.form.SearchForm.java
License:Open Source License
@Override /**/* www.j a v a 2s . co m*/ * * @param target */ protected void onNew(AjaxRequestTarget target) { target.add(feedbackPanel); // Instead of having to reset the criteria, we just copy the criteria // across CustomField cf = getModelObject().getCustomField(); CompoundPropertyModel<CustomFieldVO> newModel = new CompoundPropertyModel<CustomFieldVO>( new CustomFieldVO()); CustomField newCF = newModel.getObject().getCustomField(); // Copy all the customField attributes across from the SearchForm newCF.setStudy(cf.getStudy()); newCF.setArkFunction(cf.getArkFunction()); newCF.setCustomFieldType(cf.getCustomFieldType()); newCF.setCustomFieldCategory(cf.getCustomFieldCategory()); newCF.setName(cf.getName()); newCF.setFieldType(cf.getFieldType()); newCF.setDescription(cf.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). */ newCF.setMinValue(cf.getMinValue()); newCF.setMaxValue(cf.getMaxValue()); newModel.getObject().setUseCustomFieldDisplay(getModelObject().isUseCustomFieldDisplay()); 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) cf = new CustomField(); cf.setStudy(newCF.getStudy()); cf.setArkFunction(newCF.getArkFunction()); getModelObject().setCustomField(cf); preProcessDetailPanel(target); }
From source file:au.org.theark.core.web.component.customfield.SearchResultListPanel.java
License:Open Source License
private WebMarkupContainer buildLinkWMC(final Item<CustomField> item) { WebMarkupContainer customfieldLinkWMC = new WebMarkupContainer("customfieldLinkWMC", item.getModel()); ArkBusyAjaxLink link = new ArkBusyAjaxLink(Constants.CUSTOMFIELD_NAME) { @Override//from www .j a v a 2s . co m public void onClick(AjaxRequestTarget target) { // Sets the selected object into the model CustomField cf = (CustomField) (getParent().getDefaultModelObject()); CompoundPropertyModel<CustomFieldVO> newModel = new CompoundPropertyModel<CustomFieldVO>( new CustomFieldVO()); newModel.getObject().setCustomField(cf); newModel.getObject().setUseCustomFieldDisplay(cpModel.getObject().isUseCustomFieldDisplay()); DetailPanel detailPanel = new DetailPanel("detailPanel", feedbackPanel, newModel, arkCrudContainerVO); arkCrudContainerVO.getDetailPanelContainer().addOrReplace(detailPanel); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); //Added on 2016-05-26 to stop showing the previous feed back message when deleting or updating in the form. //This will clear the feedback message. Session.get().cleanupFeedbackMessages(); target.add(feedbackPanel); } }; // Add the label for the link CustomField field = item.getModelObject(); Label nameLinkLabel = new Label("nameLbl", field.getName()); link.add(nameLinkLabel); customfieldLinkWMC.add(link); return customfieldLinkWMC; }
From source file:au.org.theark.core.web.component.customfieldcategory.CustomFieldCategoryContainerPanel.java
License:Open Source License
protected WebMarkupContainer initialiseSearchResults() { SearchResultListPanel searchResultListPanel = new SearchResultListPanel("resultListPanel", cpModel, arkCrudContainerVO, feedBackPanel); // Data providor to paginate resultList customFieldCategoryProvider = new ArkDataProvider2<CustomFieldCategory, CustomFieldCategory>() { private static final long serialVersionUID = 1L; public int size() { if (criteriaModel.getObject().getArkFunction().getName() .equalsIgnoreCase(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY)) { criteriaModel.getObject().setArkFunction( iArkCommonService.getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION)); return (int) iArkCommonService.getCustomFieldCategoryCount(criteriaModel.getObject());//todo safe int conversion } else { return (int) iArkCommonService.getCustomFieldCategoryCount(criteriaModel.getObject());//todo safe int conversion }/*ww w.j a va 2s. co m*/ } public Iterator<CustomFieldCategory> iterator(int first, int count) { List<CustomFieldCategory> listCustomFieldCategories = new ArrayList<CustomFieldCategory>(); if (isActionPermitted()) { //if(criteriaModel.getObject().getArkFunction().getName().equalsIgnoreCase(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY)){ //listCustomFields = iArkCommonService.searchPageableCustomFieldsForPheno(criteriaModel.getObject(), first, count); //} //else{ listCustomFieldCategories = iArkCommonService .searchPageableCustomFieldCategories(criteriaModel.getObject(), first, count); //} } return CustomFieldCategoryOrderingHelper.getInstance() .orderHierarchicalyCustomFieldCategories(listCustomFieldCategories).iterator(); //return orderHierarchicalyCustomFieldCategories(listCustomFieldCategories).iterator(); } }; // Set the criteria for the data provider customFieldCategoryProvider .setCriteriaModel(new PropertyModel<CustomFieldCategory>(cpModel, "customFieldCategory")); dataView = searchResultListPanel.buildDataView(customFieldCategoryProvider); 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.core.web.component.customfieldcategory.form.DetailForm.java
License:Open Source License
/** * initialize Custom Filed Types./* ww w . j a v a 2 s .c o m*/ */ private void initCustomFieldTypeDdc() { parentPanel = new WebMarkupContainer("parentPanel"); parentPanel.setOutputMarkupId(true); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = iArkCommonService.getArkModuleById(sessionModuleId); java.util.Collection<CustomFieldType> customFieldTypeCollection = iArkCommonService .getCustomFieldTypes(arkModule); ChoiceRenderer customfieldTypeRenderer = new ChoiceRenderer(Constants.CUSTOM_FIELD_TYPE_NAME, Constants.CUSTOM_FIELD_TYPE_ID); customFieldTypeDdc = new DropDownChoice<CustomFieldType>( Constants.FIELDVO_CUSTOMFIELDCATEGORY_CUSTOM_FIELD_TYPE, (List) customFieldTypeCollection, customfieldTypeRenderer); //if custom field(s) assigned to the categories custom field type can not be edited. //or //if the custom field category has child/ren then you can not changed the type. if (!isNew()) { customFieldTypeDdc.setEnabled( !(iArkCommonService.isCustomFieldCategoryBeingUsed(getModelObject().getCustomFieldCategory()) || iArkCommonService.isThisCustomCategoryWasAParentCategoryOfAnother( getModelObject().getCustomFieldCategory()))); } customFieldTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { cpModel.getObject().getCustomFieldCategory() .setCustomFieldType(customFieldTypeDdc.getModelObject()); Collection<CustomFieldCategory> customFieldCategoryCollection = getAvailableCategoryCollectionFromModel(); parentPanel.remove(parentCategoryDdc); ChoiceRenderer customfieldCategoryRenderer = new ChoiceRenderer(Constants.CUSTOMFIELDCATEGORY_NAME, Constants.CUSTOMFIELDCATEGORY_ID); parentCategoryDdc = new DropDownChoice<CustomFieldCategory>( Constants.FIELDVO_CUSTOMFIELDCATEGORY_PARENTCATEGORY, (List) customFieldCategoryCollection, customfieldCategoryRenderer); parentCategoryDdc.setOutputMarkupId(true); parentPanel.add(parentCategoryDdc); target.add(parentCategoryDdc); target.add(parentPanel); } }); }
From source file:au.org.theark.core.web.component.customfieldcategory.form.DetailForm.java
License:Open Source License
protected void onDeleteConfirmed(AjaxRequestTarget target, String selection) { try {/* w w w . j a v a 2 s . c om*/ iArkCommonService.deleteCustomFieldCategory(getModelObject()); this.info("Field " + getModelObject().getCustomFieldCategory().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) }