Search in sources :

Example 1 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class PageWorkItem method initButtons.

private void initButtons(Form mainForm) {
    VisibleBehaviour isAllowedToSubmit = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToSubmit(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToDelegate = new VisibleBehaviour(() -> getWorkflowManager().isCurrentUserAuthorizedToDelegate(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToClaim = new VisibleBehaviour(() -> workItemDtoModel.getObject().getWorkItem().getAssigneeRef() == null && getWorkflowManager().isCurrentUserAuthorizedToClaim(workItemDtoModel.getObject().getWorkItem()));
    VisibleBehaviour isAllowedToRelease = new VisibleBehaviour(() -> {
        WorkItemType workItem = workItemDtoModel.getObject().getWorkItem();
        MidPointPrincipal principal;
        try {
            principal = (MidPointPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        } catch (ClassCastException e) {
            return false;
        }
        String principalOid = principal.getOid();
        return workItem.getAssigneeRef() != null && workItem.getAssigneeRef().stream().anyMatch(ref -> ref.getOid().equals(principalOid)) && (!workItem.getCandidateRef().isEmpty());
    });
    AjaxSubmitButton claim = new DefaultAjaxSubmitButton(ID_CLAIM, createStringResource("pageWorkItem.button.claim"), this, (target, form) -> claimPerformed(target));
    claim.add(isAllowedToClaim);
    mainForm.add(claim);
    AjaxSubmitButton release = new DefaultAjaxSubmitButton(ID_RELEASE, createStringResource("pageWorkItem.button.release"), this, (target, form) -> releasePerformed(target));
    release.add(isAllowedToRelease);
    mainForm.add(release);
    AjaxSubmitButton approve = new DefaultAjaxSubmitButton(ID_APPROVE, createStringResource("pageWorkItem.button.approve"), this, (target, form) -> savePerformed(target, true));
    approve.add(isAllowedToSubmit);
    mainForm.add(approve);
    AjaxSubmitButton reject = new DefaultAjaxSubmitButton(ID_REJECT, createStringResource("pageWorkItem.button.reject"), this, (target, form) -> savePerformed(target, false));
    reject.add(isAllowedToSubmit);
    mainForm.add(reject);
    AjaxSubmitButton delegate = new DefaultAjaxSubmitButton(ID_DELEGATE, createStringResource("pageWorkItem.button.delegate"), this, (target, form) -> delegatePerformed(target));
    delegate.add(isAllowedToDelegate);
    mainForm.add(delegate);
    AjaxButton cancel = new DefaultAjaxButton(ID_CANCEL, createStringResource("pageWorkItem.button.cancel"), this::cancelPerformed);
    mainForm.add(cancel);
}
Also used : DefaultAjaxSubmitButton(com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) DefaultAjaxButton(com.evolveum.midpoint.web.component.DefaultAjaxButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) DefaultAjaxButton(com.evolveum.midpoint.web.component.DefaultAjaxButton) DefaultAjaxSubmitButton(com.evolveum.midpoint.web.component.DefaultAjaxSubmitButton) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 2 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class PageSelfRegistration method initLayout.

private void initLayout() {
    final Form<?> mainForm = new Form<>(ID_MAIN_FORM);
    initAccessBehaviour(mainForm);
    add(mainForm);
    addMultilineLable(ID_WELCOME, "PageSelfRegistration.welcome.message", mainForm);
    addMultilineLable(ID_ADDITIONAL_TEXT, "PageSelfRegistration.additional.message", mainForm);
    initStaticFormLayout(mainForm);
    initDynamicFormLayout(mainForm);
    CaptchaPanel captcha = new CaptchaPanel(ID_CAPTCHA);
    captcha.setOutputMarkupId(true);
    mainForm.add(captcha);
    AjaxSubmitButton register = new AjaxSubmitButton(ID_SUBMIT_REGISTRATION) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            showErrors(target);
        }

        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            submitRegistration(target);
        }
    };
    mainForm.add(register);
    MultiLineLabel label = new MultiLineLabel(ID_REGISTRATION_SUBMITED, createStringResource("PageSelfRegistration.registration.confirm.message"));
    add(label);
    label.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return submited;
        }

        @Override
        public boolean isEnabled() {
            return submited;
        }
    });
    AjaxButton back = new AjaxButton(ID_BACK) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    mainForm.add(back);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(com.evolveum.midpoint.web.component.form.Form) CaptchaPanel(com.evolveum.midpoint.gui.api.component.captcha.CaptchaPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) MultiLineLabel(org.apache.wicket.markup.html.basic.MultiLineLabel)

Example 3 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class UploadDownloadPanel method initLayout.

private void initLayout(final boolean isReadOnly) {
    final FileUploadField fileUpload = new FileUploadField(ID_INPUT_FILE);
    Form form = this.findParent(Form.class);
    fileUpload.add(new AjaxFormSubmitBehavior(form, "change") {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            super.onSubmit(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            super.onError(target);
            UploadDownloadPanel.this.uploadFilePerformed(target);
        }
    });
    fileUpload.setOutputMarkupId(true);
    add(fileUpload);
    final AjaxDownloadBehaviorFromStream downloadBehavior = new AjaxDownloadBehaviorFromStream() {

        @Override
        protected InputStream initStream() {
            return getStream();
        }
    };
    add(downloadBehavior);
    add(new AjaxSubmitButton(ID_BUTTON_DOWNLOAD) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            downloadPerformed(downloadBehavior, target);
        }
    });
    add(new AjaxSubmitButton(ID_BUTTON_DELETE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            removeFilePerformed(target);
        }
    });
    add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) Form(org.apache.wicket.markup.html.form.Form) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField)

Example 4 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class PageTaskAdd method initButtons.

private void initButtons(final Form mainForm) {
    AjaxSubmitButton saveButton = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("PageBase.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    mainForm.setDefaultButton(saveButton);
    mainForm.add(saveButton);
    AjaxButton backButton = new AjaxButton(ID_BUTTON_BACK, createStringResource("PageBase.button.back")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(backButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(org.apache.wicket.markup.html.form.Form)

Example 5 with AjaxSubmitButton

use of com.evolveum.midpoint.web.component.AjaxSubmitButton in project midpoint by Evolveum.

the class PageSystemConfiguration method initButtons.

private void initButtons(Form mainForm) {
    AjaxSubmitButton save = new AjaxSubmitButton(ID_SAVE, createStringResource("PageBase.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) {
            target.add(getFeedbackPanel());
        }
    };
    mainForm.add(save);
    AjaxButton cancel = new AjaxButton(ID_CANCEL, createStringResource("PageBase.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    mainForm.add(cancel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(com.evolveum.midpoint.web.component.form.Form)

Aggregations

AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 Form (org.apache.wicket.markup.html.form.Form)27 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)23 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 ArrayList (java.util.ArrayList)9 List (java.util.List)8 Label (org.apache.wicket.markup.html.basic.Label)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)7 ListItem (org.apache.wicket.markup.html.list.ListItem)5 CheckFormGroup (com.evolveum.midpoint.web.component.form.CheckFormGroup)4 AceEditor (com.evolveum.midpoint.web.component.AceEditor)3 Form (com.evolveum.midpoint.web.component.form.Form)3 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)3 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)3 FeedbackAlerts (com.evolveum.midpoint.web.component.message.FeedbackAlerts)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3