List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
License:Open Source License
private void initBarcodeLabelTemplateDdc() { ChoiceRenderer<BarcodeLabel> choiceRenderer = new ChoiceRenderer<BarcodeLabel>("nameAndVersion", Constants.ID);//from w w w.jav a 2 s .c o m barcodeLabelTemplateDdc = new DropDownChoice<BarcodeLabel>("barcodeLabelTemplate") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(isNew()); List<BarcodeLabel> choices = iLimsAdminService.getBarcodeLabelTemplates(); this.setChoices(choices); } }; barcodeLabelTemplateDdc.setOutputMarkupPlaceholderTag(true); barcodeLabelTemplateDdc.setChoiceRenderer(choiceRenderer); barcodeLabelTemplateDdc.add(new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { // Clone data from other BarcodeLabel if (barcodeLabelTemplateDdc.getModelObject() != null) { String labelPrefix = barcodeLabelTemplateDdc.getModelObject().getLabelPrefix(); String labelSuffix = barcodeLabelTemplateDdc.getModelObject().getLabelSuffix(); Long version = barcodeLabelTemplateDdc.getModelObject().getVersion(); // Set default/required values containerForm.getModelObject().setLabelPrefix(labelPrefix); containerForm.getModelObject().setLabelSuffix(labelSuffix); containerForm.getModelObject().setVersion(version); exampleBarcodeDataFile.setModelObject( iLimsAdminService.getBarcodeLabelTemplate(barcodeLabelTemplateDdc.getModelObject())); exampleBarcodeDataFile.setVisible(true); target.add(exampleBarcodeDataFile); nameTxtFld.setModelObject(barcodeLabelTemplateDdc.getModelObject().getName()); target.add(nameTxtFld); versionTxtFld.setModelObject(version); target.add(versionTxtFld); } } }); }
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<BarcodeLabel> containerForm, AjaxRequestTarget target) { if (barcodePrinterName == null) { this.error("Barcode Printer is required"); } else {/*from w w w . java2 s . co m*/ containerForm.getModelObject().setBarcodePrinterName(barcodePrinterName.toString()); if (isNew()) { if (barcodeLabelTemplateDdc.getModelObject() != null) { List<BarcodeLabelData> cloneBarcodeLabelDataList = iLimsAdminService .getBarcodeLabelDataByBarcodeLabel(barcodeLabelTemplateDdc.getModelObject()); List<BarcodeLabelData> barcodeLabelDataList = new ArrayList<BarcodeLabelData>(0); for (Iterator<BarcodeLabelData> iterator = cloneBarcodeLabelDataList.iterator(); iterator .hasNext();) { BarcodeLabelData clonebarcodeLabelData = (BarcodeLabelData) iterator.next(); BarcodeLabelData barcodeLabelData = new BarcodeLabelData(); // Copy parent details to new barcodeLabelData try { PropertyUtils.copyProperties(barcodeLabelData, clonebarcodeLabelData); } catch (IllegalAccessException e) { log.error(e.getMessage()); } catch (InvocationTargetException e) { log.error(e.getMessage()); } catch (NoSuchMethodException e) { log.error(e.getMessage()); } barcodeLabelData.setId(null); barcodeLabelDataList.add(barcodeLabelData); } containerForm.getModelObject().setBarcodeLabelData(barcodeLabelDataList); } iLimsAdminService.createBarcodeLabel(containerForm.getModelObject()); } else { iLimsAdminService.updateBarcodeLabel(containerForm.getModelObject()); } this.info("Barcode label: " + containerForm.getModelObject().getName() + " was created/updated successfully."); } target.add(feedBackPanel); onSavePostProcess(target); }
From source file:au.org.theark.lims.web.component.barcodelabel.form.SearchForm.java
License:Open Source License
public SearchForm(String id, CompoundPropertyModel<BarcodeLabel> cpmModel, final ArkCrudContainerVO arkCrudContainerVO, FeedbackPanel feedBackPanel) { super(id, cpmModel, feedBackPanel, arkCrudContainerVO); this.feedbackPanel = feedBackPanel; initialiseSearchForm();//from www . j av a2 s . c o m newButton = new ArkBusyAjaxButton(Constants.NEW) { private static final long serialVersionUID = 1666656098281624401L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // Make the details panel visible, disabling delete button (if found) // AjaxButton ajaxButton = (AjaxButton) editButtonContainer.get("delete"); AjaxButton ajaxButton = (AjaxButton) arkCrudContainerVO.getEditButtonContainer().get("delete"); if (ajaxButton != null) { ajaxButton.setEnabled(false); target.add(ajaxButton); } // Call abstract method onNew(target); } @Override public boolean isVisible() { return true; } @Override protected void onError(final AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }; addOrReplace(newButton); }
From source file:au.org.theark.lims.web.component.barcodelabel.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); long count = iLimsAdminService.getBarcodeLabelCount(getModelObject()); if (count == 0L) { this.info("There are no records that matched your query. Please modify your filter"); target.add(feedbackPanel);//from w w w .ja v a 2 s. com } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.lims.web.component.barcodelabel.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) private AjaxLink buildLink(final BarcodeLabel barcodeLabel) { ArkBusyAjaxLink link = new ArkBusyAjaxLink("link") { private static final long serialVersionUID = 1L; @Override//from w ww . ja va2s .com public void onClick(AjaxRequestTarget target) { BarcodeLabel barcodeLabelFromDb = iLimsAdminService.searchBarcodeLabel(barcodeLabel); barcodeLabelFromDb.setBarcodeLabelData( iLimsAdminService.getBarcodeLabelDataByBarcodeLabel(barcodeLabelFromDb)); containerForm.setModelObject(barcodeLabelFromDb); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVo); // Refresh base container form to remove any feedBack messages target.add(containerForm); } }; // Add the label for the link Label linkLabel = new Label("id", barcodeLabel.getId().toString()); link.add(linkLabel); return link; }
From source file:au.org.theark.lims.web.component.biocollectioncustomdata.BioCollectionCustomDataEditorPanel.java
License:Open Source License
public BioCollectionCustomDataEditorPanel initialisePanel() { dataViewPanel = new BioCollectionCustomDataDataViewPanel("dataViewPanel", cpModel).initialisePanel( iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); customDataEditorForm = new CustomDataEditorForm("customDataEditorForm", cpModel, feedbackPanel) .initialiseForm();//from ww w. j av a2 s . c o m AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(customDataEditorForm.getDataViewWMC()); target.add(this); } }; pageNavigator.setOutputMarkupId(true); customDataEditorForm.getDataViewWMC().add(dataViewPanel); this.add(customDataEditorForm); this.add(pageNavigator); return this; }
From source file:au.org.theark.lims.web.component.biocollectioncustomdata.form.CustomDataEditorForm.java
License:Open Source License
public void onEditSave(AjaxRequestTarget target, Form<?> form) { List<BioCollectionCustomFieldData> errorList = iLimsService .createOrUpdateBioCollectionCustomFieldData(cpModel.getObject().getCustomFieldDataList()); if (errorList.size() > 0) { for (BioCollectionCustomFieldData bioCollectionCustomFieldData : errorList) { CustomField cf = bioCollectionCustomFieldData.getCustomFieldDisplay().getCustomField(); String fieldType = cf.getFieldType().getName(); if (fieldType.equals(au.org.theark.core.web.component.customfield.Constants.DATE_FIELD_TYPE_NAME)) { this.error("Unable to save this data: " + cf.getFieldLabel() + " = " + bioCollectionCustomFieldData.getDateDataValue()); } else { this.error("Unable to save this data: " + cf.getFieldLabel() + " = " + bioCollectionCustomFieldData.getTextDataValue()); }/*from www . ja va2 s .com*/ } } else { this.info("Successfully saved all edits"); } /* * Need to update the dataView, which forces a refresh of the model objects from backend. * This is because deleted fields still remain in the model, and are stale objects if we * try to use them for future saves. */ target.add(dataViewWMC); target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.biolocation.form.BioModalAllocateDetailForm.java
License:Open Source License
protected void repaintGridBoxPanel(AjaxRequestTarget target) { gridBoxPanel = new GridBoxPanel("gridBoxPanel", cpModel.getObject(), modalWindow, true); gridBoxPanel.setVisible(true);//from www. jav a 2 s .co m addOrReplace(gridBoxPanel); target.add(gridBoxPanel); }
From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java
License:Open Source License
public void initialiseForm() { numberToCreateTxtFld = new TextField<Number>("numberToCreate", new PropertyModel(getModelObject(), "numberToCreate")) { /**/*ww w .j a va 2s. c o m*/ * */ private static final long serialVersionUID = 1L; @Override public boolean isVisible() { // Only visible on first instantation of form, once entered and saved, hidden by enclosure return getModelObject() == null; } }; add(numberToCreateTxtFld); add(new AjaxButton("numberToCreateButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (numberToCreateTxtFld.getDefaultModelObject() != null) { int numberToCreate = ((Integer) numberToCreateTxtFld.getDefaultModelObject()); for (int i = 0; i < numberToCreate; i++) { Biospecimen biospecimen = new Biospecimen(); listEditor.addItem(biospecimen); listEditor.updateModel(); target.add(form); } } else { error("Please enter a valid number."); onError(target, form); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }); add(buildListEditor()); add(new Label("parentBiospecimen.biospecimenUid", new PropertyModel(getModelObject(), "parentBiospecimen.biospecimenUid"))); parentQtyLbl = new Label("parentBiospecimen.quantity", new PropertyModel(getModelObject(), "parentBiospecimen.quantity")) { /** * */ private static final long serialVersionUID = 1L; @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; add(parentQtyLbl); add(new Label("parentBiospecimen.unit.name", new PropertyModel(getModelObject(), "parentBiospecimen.unit.name"))); add(new AjaxEditorButton(Constants.NEW) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Biospecimen biospecimen = new Biospecimen(); copyBiospecimen = false; listEditor.addItem(biospecimen); target.add(form); } }.setDefaultFormProcessing(false)); add(new AjaxButton(Constants.SAVE) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onSave(target); target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override public boolean isVisible() { return false; } }); add(new AjaxButton(Constants.SAVEANDCLOSE) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (onSave(target)) { modalWindow.close(target); } target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }); add(new AjaxButton(Constants.CANCEL) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { modalWindow.close(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } }.setDefaultFormProcessing(false)); }
From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java
License:Open Source License
/** * /*from www. j a v a 2 s . com*/ * @return the listEditor of Biospecimens to aliquot */ public AbstractListEditor<Biospecimen> buildListEditor() { listEditor = new AbstractListEditor<Biospecimen>("aliquots", new PropertyModel(getModelObject(), "aliquots")) { private static final long serialVersionUID = 1L; @SuppressWarnings("serial") @Override protected void onPopulateItem(final ListItem<Biospecimen> item) { item.setOutputMarkupId(true); Biospecimen parentBiospecimen = BatchAliquotBiospecimenForm.this.getModelObject() .getParentBiospecimen(); try { PropertyUtils.copyProperties(item.getModelObject(), parentBiospecimen); } catch (IllegalAccessException e1) { log.error(e1.getMessage()); } catch (InvocationTargetException e1) { log.error(e1.getMessage()); } catch (NoSuchMethodException e1) { log.error(e1.getMessage()); } if (copyBiospecimen) { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(biospecimenToCopy.getQuantity()); item.getModelObject().setTreatmentType(biospecimenToCopy.getTreatmentType()); item.getModelObject().setConcentration(biospecimenToCopy.getConcentration()); } else { item.getModelObject().setParent(parentBiospecimen); item.getModelObject().setParentUid(parentBiospecimen.getBiospecimenUid()); item.getModelObject().setQuantity(null); item.getModelObject().setConcentration(null); } biospecimenUidTxtFld = new TextField<String>("biospecimenUid", new PropertyModel(item.getModelObject(), "biospecimenUid")); if (parentBiospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimenUidTxtFld.setEnabled(false); biospecimenUidTxtFld.setModelObject(Constants.AUTO_GENERATED); } else { biospecimenUidTxtFld.setEnabled(true); biospecimenUidTxtFld.setModelObject(null); } quantityTxtFld = new TextField<Double>("quantity", new PropertyModel(item.getModelObject(), "quantity")) { private static final long serialVersionUID = 1L; @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; initTreatmentTypeDdc(item); concentrationTxtFld = new TextField<Number>("concentration", new PropertyModel(item.getModelObject(), "concentration")); item.add(biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!item.getModelObject().getStudy().getAutoGenerateBiospecimenUid()) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, item.getModelObject().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } } target.add(feedbackPanel); biospecimenToCopy.setBiospecimenUid(getComponent().getDefaultModelObject().toString()); } })); item.add(quantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (!totalQuantityLessThanParentQuantity()) { target.focusComponent(getComponent()); } target.add(feedbackPanel); biospecimenToCopy.setQuantity((Double) getComponent().getDefaultModelObject()); item.getModelObject().setQuantity((Double) getComponent().getDefaultModelObject()); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { target.add(feedbackPanel); } })); item.add(treatmentTypeDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); item.getModelObject() .setTreatmentType((TreatmentType) getComponent().getDefaultModelObject()); } })); item.add(concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { biospecimenToCopy.setConcentration((Double) getComponent().getDefaultModelObject()); item.getModelObject().setConcentration((Double) getComponent().getDefaultModelObject()); } })); // Copy button allows entire row details to be copied item.add(new AjaxEditorButton(Constants.COPY) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Biospecimen biospecimen = new Biospecimen(); copyBiospecimen = true; try { PropertyUtils.copyProperties(biospecimen, getItem().getModelObject()); PropertyUtils.copyProperties(biospecimenToCopy, getItem().getModelObject()); listEditor.addItem(biospecimen); target.add(form); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } }.setDefaultFormProcessing(false)); item.add(new AjaxEditorButton(Constants.DELETE) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(feedbackPanel); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { listEditor.removeItem(item); target.add(form); } }.setDefaultFormProcessing(false).setVisible(item.getIndex() > 0)); 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; } })); } }; return listEditor; }