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.core.web.component.customfieldupload.form.SearchForm.java

License:Open Source License

@Override
protected void onSearch(AjaxRequestTarget target) {
    target.add(feedbackPanel);

    // Set study in context
    Long studyId = (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(studyId);

    Upload searchUpload = getModelObject().getUpload();
    searchUpload.setStudy(study);//from  w ww .  j ava2s.  c om
    searchUpload.setArkFunction(
            iArkCommonService.getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY));

    Collection<Upload> uploadCollection = iArkCommonService.searchUploads(searchUpload);

    if (uploadCollection != null && uploadCollection.size() == 0) {
        this.info("Uploads with the specified criteria does not exist in the system.");
        target.add(feedbackPanel);
    }

    getModelObject().setUploadCollection(uploadCollection);

    listView.removeAll();
    arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);
    target.add(arkCrudContainerVO.getSearchResultPanelContainer());
}

From source file:au.org.theark.core.web.component.customfieldupload.form.SearchForm.java

License:Open Source License

@Override
protected void onNew(AjaxRequestTarget target) {
    // NB: Should not be possible to get here (GUI should be using Wizard for new)
    // Due to ARK-108 :: No longer reset the VO onNew(..)
    CustomFieldUploadVO uploadVo = getModelObject();
    uploadVo.setMode(au.org.theark.core.Constants.MODE_NEW);
    uploadVo.getUpload().setId(null); // must ensure Id is blank onNew
    setModelObject(uploadVo);//from w  ww .  j av  a2  s .com

    arkCrudContainerVO.getSearchResultPanelContainer().setVisible(false);
    arkCrudContainerVO.getSearchPanelContainer().setVisible(false);

    // Explicitly Show Wizard panel
    arkCrudContainerVO.getWizardPanelContainer().setVisible(true);
    arkCrudContainerVO.getWizardPanelContainer().setEnabled(true);

    target.add(arkCrudContainerVO.getSearchResultPanelContainer());
    target.add(arkCrudContainerVO.getSearchPanelContainer());
    target.add(arkCrudContainerVO.getDetailPanelFormContainer());
    target.add(arkCrudContainerVO.getWizardPanelContainer());
}

From source file:au.org.theark.core.web.component.listeditor.AjaxListDeleteButton.java

License:Open Source License

@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    int idx = getItem().getIndex();

    for (int i = idx + 1; i < getItem().getParent().size(); i++) {
        ListItem<?> item = (ListItem<?>) getItem().getParent().get(i);
        item.setIndex(item.getIndex() - 1);
    }//w  ww . j av  a2s .  c  o  m

    getList().remove(idx);
    getEditor().remove(getItem());

    // only repaint ListDetailPanels
    target.add(getEditor());
    onDeleteConfirmed(target, form);
}

From source file:au.org.theark.core.web.component.navigator.ArkAjaxPagingNavigator.java

License:Open Source License

@Override
protected void onAjaxEvent(AjaxRequestTarget target) {
    target.add(this);

    // Refresh the specified component
    target.add(component);//w  ww  .  j a  v a2  s.  c o  m
    // refresh the jQuery dirtyForm script
    target.add(label);
}

From source file:au.org.theark.core.web.component.panel.collapsiblepanel.CollapsiblePanel.java

License:Open Source License

/**
 * Construct the panel/*from  ww w  .j  a  v  a  2  s  .com*/
 * 
 * @param id
 *           Panel ID
 * @param titleModel
 *           Model used to get the panel title
 * @param defaultOpen
 *           Is the default state open
 */
public CollapsiblePanel(String id, IModel<String> titleModel, boolean defaultOpen) {
    super(id);
    this.visible = defaultOpen;
    innerPanel = getInnerPanel("innerPanel");
    innerPanel.setVisible(visible);
    innerPanel.setOutputMarkupId(true);
    innerPanel.setOutputMarkupPlaceholderTag(true);
    add(innerPanel);

    final Image showHideImage = new Image("showHideIcon") {
        private static final long serialVersionUID = 8638737301579767296L;

        @Override
        public ResourceReference getImageResourceReference() {
            return visible ? open : closed;
        }
    };
    showHideImage.setOutputMarkupId(true);
    IndicatingAjaxLink<String> showHideLink = new IndicatingAjaxLink<String>("showHideLink") {
        private static final long serialVersionUID = -1929927616508773911L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            visible = !visible;
            innerPanel.setVisible(visible);
            target.add(innerPanel);
            target.add(showHideImage);
        }
    };
    showHideLink.add(showHideImage);
    add(new Label("titlePanel", titleModel));
    add(showHideLink);
}

From source file:au.org.theark.core.web.component.tabbedPanel.AjaxDynamicTabbedPanel.java

License:Open Source License

@Override
protected WebMarkupContainer newLink(final String linkId, final int index) {
    return new AjaxFallbackLink<Void>(linkId) {

        private static final long serialVersionUID = 1L;

        @Override//from   w w  w .  j a v a  2  s .  c o  m
        public void onClick(final AjaxRequestTarget target) {
            setSelectedTab(index);
            if (target != null) {
                target.add(AjaxDynamicTabbedPanel.this);
            }
            onAjaxUpdate(target);
        }

    };
}

From source file:au.org.theark.core.web.component.tabbedPanel.ArkAjaxTabbedPanel.java

License:Open Source License

protected WebMarkupContainer newLink(final String linkId, final int index) {
    ArkBusyAjaxLink<String> tabLink = new ArkBusyAjaxLink<String>(linkId) {

        private static final long serialVersionUID = 1L;

        @Override/*  ww  w .  j  a  v  a2 s.  co  m*/
        public void onClick(AjaxRequestTarget target) {
            if (mainTabs.size() == 0 || (mainTabs.size() > 0 && mainTabs.get(index).isAccessible())) {
                setSelectedTab(index);

                if (mainTabs.size() > 0 && mainTabs.get(index).getTitle().getObject()
                        .equalsIgnoreCase(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT)) {
                    // Clear Subject session objects (ie force a new search)
                    SecurityUtils.getSubject().getSession()
                            .removeAttribute(au.org.theark.core.Constants.SUBJECTUID);
                    SecurityUtils.getSubject().getSession()
                            .removeAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID);
                    SecurityUtils.getSubject().getSession()
                            .removeAttribute(au.org.theark.core.Constants.PERSON_TYPE);
                    arkContextPanelMarkup.get("subjectLabel")
                            .replaceWith(new Label("subjectLabel", new Model("")));
                    target.add(arkContextPanelMarkup);
                }
            }

            if (target != null) {
                target.add(ArkAjaxTabbedPanel.this);
            }
            onAjaxUpdate(target);
        }
    };

    return tabLink;
}

From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java

License:Open Source License

private void addAjax(final WizardButton button) {
    button.add(new AjaxFormSubmitBehavior("onclick") {
        private static final long serialVersionUID = 1L;

        @Override//from  ww w .  ja  v  a  2  s .c o m
        protected CharSequence getEventHandler() {
            AppendingStringBuffer handler = new AppendingStringBuffer();
            handler.append(super.getEventHandler());
            handler.append("; return false;");
            return handler;
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return AjaxWizardButtonBar.this.getAjaxCallDecorator();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            target.add(wizard);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(wizard);
        }
    });

    add(button);
}

From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java

License:Open Source License

private void addAjaxCancel(final WizardButton button) {
    button.add(new AjaxFormSubmitBehavior("onclick") {
        private static final long serialVersionUID = 1L;

        @Override/*from   www . j  ava2s  . c  o  m*/
        protected CharSequence getEventHandler() {
            AppendingStringBuffer handler = new AppendingStringBuffer();
            handler.append(super.getEventHandler());
            handler.append("; return false;");
            return handler;
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return AjaxWizardButtonBar.this.getAjaxCallDecorator();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            wizard.getWizardModel().cancel();
            wizard = new ArkCommonWizard(wizard.getId(), wizard.getWizardSteps(),
                    wizard.getResultListContainer(), wizard.getWizardPanelContainer(),
                    wizard.getWizardPanelFormContainer(), wizard.getSearchPanelContainer(), wizard.getTarget());

            wizard.getSearchPanelContainer().setVisible(true);
            wizard.getResultListContainer().setVisible(true);
            wizard.getWizardPanelContainer().setVisible(true);

            cancelWizard(target);

            target.add(wizard.getSearchPanelContainer());
            target.add(wizard.getResultListContainer());
            target.add(wizard.getWizardPanelContainer());
            target.add(wizard);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(wizard);
        }
    });

    add(button);
}

From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java

License:Open Source License

private void addAjaxFinish(final WizardButton button) {
    button.add(new AjaxFormSubmitBehavior("onclick") {
        private static final long serialVersionUID = 1L;

        @Override/*  ww w  .  ja  v a  2  s. c  om*/
        protected CharSequence getEventHandler() {
            AppendingStringBuffer handler = new AppendingStringBuffer();
            handler.append(super.getEventHandler());
            handler.append("; return false;");
            return handler;
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return AjaxWizardButtonBar.this.getAjaxCallDecorator();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            wizard.getSearchPanelContainer().setVisible(true);
            wizard.getResultListContainer().setVisible(true);
            wizard.getWizardPanelContainer().setVisible(true);

            wizard.getWizardModel().finish();

            target.add(wizard.getSearchPanelContainer());
            target.add(wizard.getResultListContainer());
            target.add(wizard.getWizardPanelContainer());
            target.add(wizard);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(wizard);
        }
    });

    add(button);
}