List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.core.web.form.AbstractWizardForm.java
License:Open Source License
protected void onCancelClick(AjaxRequestTarget target) { cancelled = true;//ww w . ja v a 2s.c om previousLink.setVisible(false); previousLink.setEnabled(false); nextButton.setVisible(true); nextButton.setEnabled(true); finishButton.setVisible(true); finishButton.setEnabled(false); resultListContainer.setVisible(true); target.add(wizardPanelFormContainer); target.add(wizardButtonContainer); target.add(resultListContainer); onCancel(target); }
From source file:au.org.theark.core.web.form.AbstractWizardForm.java
License:Open Source License
/** * Warn the current step panel we are going out by next, and ask which is the next step. * //from w w w . j av a 2s .c om * @param target */ protected void gotoNext(AjaxRequestTarget target) { // Wizard steps are contained within a WebMarkupContainer WebMarkupContainer wmc = (WebMarkupContainer) get("wizardFormContainer"); AbstractWizardStepPanel currentStep = (AbstractWizardStepPanel) wmc.get("step"); log.debug("gotoNext.currentStep={}", currentStep.getClass().getName()); // Handle wizard step state on Next press currentStep.onStepOutNext(AbstractWizardForm.this, target); currentStep.handleWizardState(this, target); AbstractWizardStepPanel next = currentStep.getNextStep(); if (next != null) { next.onStepInNext(AbstractWizardForm.this, target); currentStep.replaceWith(next); // If no more steps, on final step if (next.getNextStep() == null) { nextButton.setEnabled(false); cancelLink.setEnabled(false); finishButton.setEnabled(true); arkExcelWorkSheetAsGrid.setEnabled(false); target.add(arkExcelWorkSheetAsGrid); } target.add(wizardButtonContainer); } target.add(wmc); target.add(feedBackPanel); }
From source file:au.org.theark.core.web.form.AbstractWizardForm.java
License:Open Source License
/** * Warn the current step panel we are going out by previous, and ask which is the previous step. * //from w w w . j a v a2 s.co m * @param target */ protected void gotoPrevious(AjaxRequestTarget target) { WebMarkupContainer wmc = (WebMarkupContainer) get("wizardFormContainer"); AbstractWizardStepPanel currentStep = (AbstractWizardStepPanel) wmc.get("step"); log.debug("gotoPrevious.currentStep={}", currentStep.getClass().getName()); currentStep.onStepOutPrevious(AbstractWizardForm.this, target); AbstractWizardStepPanel previous = currentStep.getPreviousStep(); if (previous != null) { currentStep.replaceWith(previous); previous.onStepInPrevious(this, target); previous.handleWizardState(this, target); } target.add(wmc); target.add(feedBackPanel); }
From source file:au.org.theark.core.web.form.AbstractWizardStepPanel.java
License:Open Source License
protected void setContent(AjaxRequestTarget target, Component content) { if (!content.getId().equals(getContentId())) throw new IllegalArgumentException( "Expected content id is " + getContentId() + " but " + content.getId() + " was found."); Component current = get(getContentId()); if (current == null) { add(content);/*from ww w. j a v a 2s .c om*/ } else { current.replaceWith(content); if (target != null) { target.add(get(getContentId())); } } }
From source file:au.org.theark.core.web.StudyHelper.java
License:Open Source License
public void setStudyLogo(Study study, AjaxRequestTarget target, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup) { // Set the study logo Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null && study.getStudyLogoBlob() != null) { setStudyLogoImage(study, "studyLogoImage", studyLogoMarkup); studyNameMarkup.setVisible(false); studyLogoMarkup.setVisible(true); } else {//from w ww .j a v a 2 s . co m // Only show study name, no logo studyNameLabel = new Label("studyNameLabel", new Model<String>(study.getName())); studyNameMarkup.replace(studyNameLabel); studyNameMarkup.setVisible(true); studyLogoMarkup.setVisible(false); } target.add(studyNameMarkup); target.add(studyLogoMarkup); }
From source file:au.org.theark.core.web.StudyHelper.java
License:Open Source License
public void setStudyContextLabel(AjaxRequestTarget target, String studyName, WebMarkupContainer arkContextMarkup) { studyLabel = new Label("studyLabel", new Model<String>("Study: " + studyName)); arkContextMarkup.addOrReplace(studyLabel); target.add(arkContextMarkup); }
From source file:au.org.theark.disease.web.component.affection.form.DetailForm.java
License:Open Source License
@SuppressWarnings("unchecked") public void initialiseDetailForm() { initDiseaseDDC();/*from w ww . j av a 2 s . c o m*/ initAffectionStatusDDC(); detachableModel = new LoadableDetachableModel<List<Position>>() { @Override protected List<Position> load() { List<Position> positions = iArkDiseaseService .getPositions(containerForm.getModelObject().getAffection()); return positions; } }; positionListEditor = new ListView<Position>("positionListEditor", detachableModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Position> item) { final Position position = item.getModelObject(); if (position != null) { position_storage.put(item.getIndex(), position); } List<Gene> availableGenes = new ArrayList<Gene>(); if (containerForm.getModelObject().getAffection().getDisease() != null && containerForm.getModelObject().getAffection().getDisease().getGenes() != null) { availableGenes = new ArrayList<Gene>( containerForm.getModelObject().getAffection().getDisease().getGenes()); } final DropDownChoice<Gene> geneDDC = new DropDownChoice<Gene>("affection.disease.genes", new Model<Gene>(position.getGene()), availableGenes, new ChoiceRenderer<Gene>("name", "id")); geneDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { Gene selectedGene = iArkDiseaseService.getGeneByID(Long.parseLong(geneDDC.getValue())); positionDDC.setChoices(new ArrayList<Position>(selectedGene.getPositions())); target.add(positionDDC); } }); geneDDC.setOutputMarkupId(true); item.add(geneDDC); List<Position> availablePositions = new ArrayList<Position>(); if (geneDDC.getModelObject() != null) { availablePositions = new ArrayList<Position>(geneDDC.getModelObject().getPositions()); } LoadableDetachableModel<Position> positionModel = new LoadableDetachableModel<Position>(position) { @Override protected Position load() { return position; } }; if (position != null) { positionModel.setObject(position); } positionDDC = new DropDownChoice<Position>("affection.positions", positionModel, availablePositions, new ChoiceRenderer<Position>("name", "id")) { @Override protected void onBeforeRender() { if (geneDDC.getModelObject() != null && geneDDC.getModelObject().getId() != null && !geneDDC.getModelObject().getPositions().isEmpty()) { this.setChoices(new ArrayList<Position>(geneDDC.getModelObject().getPositions())); } if (this.getModelObject().getName() != null) { position_storage.put(item.getIndex(), this.getModelObject()); } super.onBeforeRender(); } }; positionDDC.setOutputMarkupId(true); positionDDC.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; protected void onUpdate(AjaxRequestTarget target) { Position selectedPosition = positionDDC.getModelObject(); if (selectedPosition.getName() != null) { position_storage.put(item.getIndex(), selectedPosition); } } }); item.add(positionDDC); item.add(new AjaxDeleteButton(Constants.DELETE, new Model<String>("Are you sure?"), new Model<String>("Delete")) { private static final long serialVersionUID = 1L; protected void onDeleteConfirmed(AjaxRequestTarget target, Form<?> form) { try { //need to remove save containerform post position removal position_storage.remove(item.getIndex()); positionListEditor.getModelObject().remove(position); containerForm.getModelObject().setAffection(iArkDiseaseService .getAffectionByID(containerForm.getModelObject().getAffection().getId())); save(containerForm, target); target.add(dataViewPanel); deleteCompleted("Row '" + position.getName() + "' deleted successfully.", true); } catch (Exception e) { e.printStackTrace(); target.add(form); deleteCompleted("Error deleting row '" + position.getName() + "'. Row has data associated with it.", false); } } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onDeleteConfirmed(target, form); target.add(form); target.add(feedBackPanel); } }); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; positionListEditor.setOutputMarkupId(true); newPositionBtn = new AjaxEditorButton(Constants.NEW) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.add(form); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { positionListEditor.getModelObject().add(new Position()); target.add(form); } }.setDefaultFormProcessing(false); arkCrudContainerVO.getDetailPanelFormContainer().add(newPositionBtn); PropertyModel<Date> recordDateModel = new PropertyModel<Date>(containerForm.getModel(), "affection.recordDate"); recordDateTxtFld = new DateTextField("recordDate", recordDateModel) { @Override protected void onBeforeRender() { this.setModel(new PropertyModel<Date>(containerForm.getModel(), "affection.recordDate")); super.onBeforeRender(); } }; ArkDatePicker recordDatePicker = new ArkDatePicker(); recordDatePicker.bind(recordDateTxtFld); recordDateTxtFld.add(recordDatePicker); AffectionCustomDataVO affectionCustomDataVO = new AffectionCustomDataVO(); affectionCustomDataVO.setCustomFieldDataList(new ArrayList<AffectionCustomFieldData>( cpModel.getObject().getAffection().getAffectionCustomFieldDataSets())); final CompoundPropertyModel<AffectionCustomDataVO> affectionCustomDataModel = new CompoundPropertyModel<AffectionCustomDataVO>( affectionCustomDataVO); dataViewPanel = new AffectionCustomDataDataViewPanel("dataViewPanel", affectionCustomDataModel) .initialisePanel( iArkCommonService.getUserConfig(Constants.CONFIG_CUSTOM_FIELDS_PER_PAGE).getIntValue()); customFieldForm = new AbstractCustomDataEditorForm<AffectionCustomDataVO>("customFieldForm", affectionCustomDataModel, feedBackPanel) { private static final long serialVersionUID = 1L; @Override public void onEditSave(AjaxRequestTarget target, Form<?> form) { for (AffectionCustomFieldData acfd : this.cpModel.getObject().getCustomFieldDataList()) { iArkDiseaseService.save(acfd); } } @Override public void onBeforeRender() { if (!isNew()) { this.setModelObject(new AffectionCustomDataVO(iArkDiseaseService .getAffectionCustomFieldData(containerForm.getModelObject().getAffection()))); } this.buttonsPanelWMC.setVisible(false); super.onBeforeRender(); } }.initialiseForm(); pageNavigator = new AjaxPagingNavigator("navigator", dataViewPanel.getDataView()) { @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(customFieldForm.getDataViewWMC()); target.add(this); } }; pageNavigator.setOutputMarkupId(true); customFieldForm.getDataViewWMC().add(dataViewPanel); arkCrudContainerVO.getDetailPanelFormContainer().add(pageNavigator); attachValidators(); addDetailFormComponents(); deleteButton.setVisible(false); }
From source file:au.org.theark.disease.web.component.affection.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<AffectionVO> containerForm, AjaxRequestTarget target) { Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (studyId == null) { // No study in context this.error("There is no study in Context. Please select a study to manage diseases."); processErrors(target);//from ww w. j a v a 2 s .co m } else { try { save(containerForm, target); customFieldForm.onEditSave(target, containerForm); target.add(this); } catch (DataIntegrityViolationException e) { this.error(getString("duplicate.keys.error")); processErrors(target); } } }
From source file:au.org.theark.disease.web.component.disease.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<DiseaseVO> containerForm, AjaxRequestTarget target) { Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (studyId == null) { // No study in context this.error("There is no study in Context. Please select a study to manage diseases."); processErrors(target);/*from w w w. j a va 2 s.co m*/ } else { Disease disease = containerForm.getModelObject().getDisease(); disease.setStudy(iArkCommonService.getStudy(studyId)); disease.setGenes(new HashSet<Gene>(containerForm.getModelObject().getSelectedGenes())); disease.setCustomFields( new HashSet<CustomField>(containerForm.getModelObject().getSelectedCustomFields())); if (isNew()) { iArkDiseaseService.save(disease); } else { iArkDiseaseService.update(disease); } //Populating containerForm's Model Object for next render. List<Gene> availableGenes = iArkDiseaseService.getAvailableGenesForStudy(disease.getStudy()); List<Gene> selectedGenes = new ArrayList<Gene>(disease.getGenes()); CustomField criteria = new CustomField(); criteria.setStudy(disease.getStudy()); criteria.setArkFunction(iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_DISEASE_CUSTOM_FIELDS)); List<CustomField> selectedCustomFields = new ArrayList<CustomField>(disease.getCustomFields()); List<CustomField> availableCustomFields = iArkCommonService.getCustomFieldList(criteria); containerForm.getModelObject().setAvailableGenes(availableGenes); containerForm.getModelObject().setSelectedGenes(selectedGenes); containerForm.getModelObject().setAvailableCustomFields(availableCustomFields); containerForm.getModelObject().setSelectedCustomFields(selectedCustomFields); target.add(arkCrudContainerVO.getDetailPanelContainer()); } }
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
License:Open Source License
private void initStudyDdc() { List<Study> studyListForUser = new ArrayList<Study>(0); studyListForUser = getStudyListForUser(); ChoiceRenderer<Study> choiceRenderer = new ChoiceRenderer<Study>(Constants.NAME, Constants.ID); studyDdc = new DropDownChoice<Study>("study", studyListForUser, choiceRenderer) { private static final long serialVersionUID = 1L; @Override/*from w ww . j ava 2 s . c o m*/ protected void onBeforeRender() { super.onBeforeRender(); studyDdc.setEnabled(isNew()); studyDdc.setChoices(getStudyListForUser()); } }; studyDdc.add(new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(barcodeLabelTemplateDdc); } }); }