Search in sources :

Example 11 with AjaxButton

use of org.apache.wicket.ajax.markup.html.form.AjaxButton in project syncope by apache.

the class ActionDataTablePanel method addCancelButton.

public void addCancelButton(final BaseModal<?> modal) {
    final AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {

        private static final long serialVersionUID = -4804368561204623354L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            modal.close(target);
        }
    };
    cancel.setDefaultFormProcessing(false);
    bulkActionForm.addOrReplace(cancel);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IndicatingAjaxButton(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton) AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) Form(org.apache.wicket.markup.html.form.Form) ResourceModel(org.apache.wicket.model.ResourceModel) IndicatingAjaxButton(org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton)

Example 12 with AjaxButton

use of org.apache.wicket.ajax.markup.html.form.AjaxButton in project gitblit by gitblit.

the class CommentPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    Form<String> form = new Form<String>("editorForm");
    add(form);
    form.add(new AjaxButton("submit", new Model<String>(getString("gb.comment")), form) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
            String txt = markdownEditor.getText();
            if (change == null) {
                // new comment
                Change newComment = new Change(user.username);
                newComment.comment(txt);
                if (!ticket.isWatching(user.username)) {
                    newComment.watch(user.username);
                }
                RepositoryModel repository = app().repositories().getRepositoryModel(ticket.repository);
                TicketModel updatedTicket = app().tickets().updateTicket(repository, ticket.number, newComment);
                if (updatedTicket != null) {
                    app().tickets().createNotifier().sendMailing(updatedTicket);
                    redirectTo(pageClass, WicketUtils.newObjectParameter(updatedTicket.repository, "" + ticket.number));
                } else {
                    error("Failed to add comment!");
                }
            } else {
            // TODO update comment
            }
        }

        /**
         * Steal from BasePage to realize redirection.
         *
         * @see BasePage
         * @author krulls@GitHub; ECG Leipzig GmbH, Germany, 2015
         *
         * @param pageClass
         * @param parameters
         * @return
         */
        private void redirectTo(Class<? extends BasePage> pageClass, PageParameters parameters) {
            String relativeUrl = urlFor(pageClass, parameters).toString();
            String canonicalUrl = RequestUtils.toAbsolutePath(relativeUrl);
            getRequestCycle().setRequestTarget(new RedirectRequestTarget(canonicalUrl));
        }
    }.setVisible(ticket != null && ticket.number > 0));
    final IModel<String> markdownPreviewModel = Model.of();
    markdownPreview = new Label("markdownPreview", markdownPreviewModel);
    markdownPreview.setEscapeModelStrings(false);
    markdownPreview.setOutputMarkupId(true);
    add(markdownPreview);
    markdownEditor = new MarkdownTextArea("markdownEditor", markdownPreviewModel, markdownPreview);
    markdownEditor.setRepository(repositoryName);
    WicketUtils.setInputPlaceholder(markdownEditor, getString("gb.leaveComment"));
    add(markdownEditor);
}
Also used : Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) TicketModel(com.gitblit.models.TicketModel) Change(com.gitblit.models.TicketModel.Change) RepositoryModel(com.gitblit.models.RepositoryModel) PageParameters(org.apache.wicket.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) RedirectRequestTarget(org.apache.wicket.request.target.basic.RedirectRequestTarget) BasePage(com.gitblit.wicket.pages.BasePage)

Example 13 with AjaxButton

use of org.apache.wicket.ajax.markup.html.form.AjaxButton in project hippo by NHS-digital-website.

the class EarlyAccessKeyPlugin method getDisabledForm.

private Form getDisabledForm() {
    Form htmlForm = new Form("form");
    htmlForm.setEnabled(false);
    htmlForm.setVisible(false);
    htmlForm.add(new AjaxButton("generate") {
    });
    htmlForm.add(new AjaxButton("delete") {
    });
    return htmlForm;
}
Also used : AjaxButton(org.apache.wicket.ajax.markup.html.form.AjaxButton) Form(org.apache.wicket.markup.html.form.Form)

Aggregations

AjaxButton (org.apache.wicket.ajax.markup.html.form.AjaxButton)13 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)12 Form (org.apache.wicket.markup.html.form.Form)10 Label (org.apache.wicket.markup.html.basic.Label)5 ArrayList (java.util.ArrayList)3 UserModel (com.gitblit.models.UserModel)2 RepositoryException (javax.jcr.RepositoryException)2 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)2 Form (com.evolveum.midpoint.web.component.form.Form)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AccessPermission (com.gitblit.Constants.AccessPermission)1 Transport (com.gitblit.Constants.Transport)1 GitBlitException (com.gitblit.GitBlitException)1 RepositoryModel (com.gitblit.models.RepositoryModel)1 TicketModel (com.gitblit.models.TicketModel)1 Change (com.gitblit.models.TicketModel.Change)1 SshKey (com.gitblit.transport.ssh.SshKey)1 BasePage (com.gitblit.wicket.pages.BasePage)1 BooleanOption (com.gitblit.wicket.panels.BooleanOption)1 TextOption (com.gitblit.wicket.panels.TextOption)1