Example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setOutputMarkupId

List of usage examples for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setOutputMarkupId

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink setOutputMarkupId.

Prototype

public final Component setOutputMarkupId(final boolean output) 

Source Link

Document

Sets whether or not component will output id attribute into the markup.

Usage

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceAttributeEditor.java

License:Apache License

@Override
protected void initLayout() {
    Label label = new Label(ID_LABEL, new AbstractReadOnlyModel<String>() {

        @Override//from  w  w  w  . j  a  v a 2 s.  co m
        public String getObject() {
            ResourceAttributeDefinitionType attribute = getModelObject();

            if (attribute.getRef() == null || attribute.getRef().equals(new ItemPathType())) {
                return getString("ResourceAttributeEditor.label.new");
            } else {
                return getString("ResourceAttributeEditor.label.edit",
                        ItemPathUtil.getOnlySegmentQName(attribute.getRef()).getLocalPart());
            }
        }
    });
    add(label);

    QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            "SchemaHandlingStep.attribute.label.attributeName",
            "SchemaHandlingStep.attribute.tooltip.attributeLocalPart",
            "SchemaHandlingStep.attribute.label.attributeNamespace",
            "SchemaHandlingStep.attribute.tooltip.attributeNamespace");

    nonSchemaRefPanel.setOutputMarkupId(true);
    nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);
    nonSchemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return nonSchemaRefValueAllowed;
        }
    });
    add(nonSchemaRefPanel);

    WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL);
    schemaRefPanel.setOutputMarkupId(true);
    schemaRefPanel.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !nonSchemaRefValueAllowed;
        }

    });
    add(schemaRefPanel);

    Label refTooltip = new Label(ID_T_REF);
    refTooltip.add(new InfoTooltipBehavior());
    refTooltip.setOutputMarkupId(true);
    refTooltip.setOutputMarkupId(true);
    schemaRefPanel.add(refTooltip);

    DropDownChoice refSelect = new DropDownChoice<ItemPathType>(ID_REFERENCE_SELECT,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            new AbstractReadOnlyModel<List<ItemPathType>>() {

                @Override
                public List<ItemPathType> getObject() {
                    return loadObjectReferences();
                }
            }, new IChoiceRenderer<ItemPathType>() {

                @Override
                public Object getDisplayValue(ItemPathType object) {
                    return prepareReferenceDisplayValue(object);
                }

                @Override
                public String getIdValue(ItemPathType object, int index) {
                    return Integer.toString(index);
                }
            }) {

        @Override
        protected boolean isSelected(ItemPathType object, int index, String selected) {
            if (getModelObject() == null || getModelObject().equals(new ItemPathType())) {
                return false;
            }

            QName referenceQName = ItemPathUtil.getOnlySegmentQName(getModelObject());
            QName optionQName = ItemPathUtil.getOnlySegmentQName(object);

            return referenceQName.equals(optionQName);
        }
    };
    refSelect.setNullValid(false);

    refSelect.setOutputMarkupId(true);
    refSelect.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(refSelect);

    CheckBox allowNonSchema = new CheckBox(ID_REFERENCE_ALLOW,
            new PropertyModel<Boolean>(this, "nonSchemaRefValueAllowed"));
    allowNonSchema.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_NON_SCHEMA_REF_PANEL), get(ID_SCHEMA_REF_PANEL));
        }
    });
    add(allowNonSchema);

    TextField displayName = new TextField<>(ID_DISPLAY_NAME,
            new PropertyModel<String>(getModel(), "displayName"));
    add(displayName);

    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    add(description);

    AjaxLink limitations = new AjaxLink(ID_BUTTON_LIMITATIONS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);

    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG,
            new PropertyModel<Boolean>(getModel(), "exclusiveStrong"));
    add(exclusiveStrong);

    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<Boolean>(getModel(), "tolerant"));
    add(tolerant);

    MultiValueTextPanel tolerantVP = new MultiValueTextPanel<>(ID_TOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "tolerantValuePattern"));
    add(tolerantVP);

    MultiValueTextPanel intolerantVP = new MultiValueTextPanel<>(ID_INTOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "intolerantValuePattern"));
    add(intolerantVP);

    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    fetchStrategy.setNullValid(true);
    add(fetchStrategy);

    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE,
            new PropertyModel<QName>(getModel(), "matchingRule"), new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return WebMiscUtil.getMatchingRuleList();
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return object.getLocalPart();
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    matchingRule.setNullValid(true);
    add(matchingRule);

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceAttributeDefinitionType attributeDefinition = getModel().getObject();

            if (attributeDefinition == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(attributeDefinition.getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_BUTTON_OUTBOUND) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    Label allowTooltip = new Label(ID_T_ALLOW);
    allowTooltip.add(new InfoTooltipBehavior());
    add(allowTooltip);

    Label limitationsTooltip = new Label(ID_T_LIMITATIONS);
    limitationsTooltip.add(new InfoTooltipBehavior());
    add(limitationsTooltip);

    Label exclusiveStrongTooltip = new Label(ID_T_EXCLUSIVE_STRONG);
    exclusiveStrongTooltip.add(new InfoTooltipBehavior());
    add(exclusiveStrongTooltip);

    Label tolerantTooltip = new Label(ID_T_TOLERANT);
    tolerantTooltip.add(new InfoTooltipBehavior());
    add(tolerantTooltip);

    Label tolerantVPTooltip = new Label(ID_T_TOLERANT_VP);
    tolerantVPTooltip.add(new InfoTooltipBehavior());
    add(tolerantVPTooltip);

    Label intolerantVPTooltip = new Label(ID_T_INTOLERANT_VP);
    intolerantVPTooltip.add(new InfoTooltipBehavior());
    add(intolerantVPTooltip);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label matchingRuleTooltip = new Label(ID_T_MATCHING_RULE);
    matchingRuleTooltip.add(new InfoTooltipBehavior());
    add(matchingRuleTooltip);

    Label outboundTooltip = new Label(ID_T_OUTBOUND);
    outboundTooltip.add(new InfoTooltipBehavior());
    add(outboundTooltip);

    Label inboundTooltip = new Label(ID_T_INBOUND);
    inboundTooltip.add(new InfoTooltipBehavior());
    add(inboundTooltip);

    initModals();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceCredentialsEditor.java

License:Apache License

@Override
protected void initLayout() {
    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "password.fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    add(fetchStrategy);// ww  w .  j  ava 2 s .  com

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceCredentialsDefinitionType credentials = getModel().getObject();

            if (credentials == null || credentials.getPassword() == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(credentials.getPassword().getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_OUTBOUND_BUTTON) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "password.inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    DropDownChoice passwordPolicy = new DropDownChoice<>(ID_PASS_POLICY,
            new PropertyModel<ObjectReferenceType>(getModel(), "password.passwordPolicyRef"),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return passPolicyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            });
    add(passwordPolicy);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label outTooltip = new Label(ID_T_OUT);
    outTooltip.add(new InfoTooltipBehavior());
    add(outTooltip);

    Label inTooltip = new Label(ID_T_IN);
    inTooltip.add(new InfoTooltipBehavior());
    add(inTooltip);

    Label passPolicyTooltip = new Label(ID_T_PASS_POLICY);
    passPolicyTooltip.add(new InfoTooltipBehavior());
    add(passPolicyTooltip);

    initModals();
}

From source file:com.userweave.pages.configuration.project.invitation.InviteUserToProjectPage.java

License:Open Source License

@Override
protected WebMarkupContainer getAcceptButton(String componentId, final ModalWindow window) {
    final AjaxSubmitLink link = new AjaxSubmitLink(componentId, getForm()) {
        private static final long serialVersionUID = 1L;

        @Override/*  w w  w  .  j av  a 2 s. c om*/
        protected void onError(AjaxRequestTarget target, Form form) {
            // add the feedback panel of the invitation form panel.
            target.addComponent(((InvitationFormPanel) displayComponent).getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            InvitationFormPanel panel = (InvitationFormPanel) displayComponent;

            String addressee = panel.getInvitaitonAddressee().toLowerCase();

            User recipant = userDao.findByEmail(addressee);

            if (recipant == null) // user is not a registered user
            {
                if (verifyEmailAddress(addressee)) {
                    if (project == null) {
                        triggerError("projectDoesNotExists", panel, target);
                    } else if (userHasBeenInvited(addressee, project)) {
                        triggerError("userAlreadyInvited", panel, target);
                    } else // send new invitation
                    {
                        projectInvitationDao.sendInvitation(addressee, user, project,
                                roleDao.findByName(panel.getRole().getRoleName()), panel.getSelectedLocale(),
                                InviteUserToProjectPage.this);

                        window.close(target);

                        //replaceDisplayComponentAndHideLink(target);
                    }
                } else // email address incorect
                {
                    triggerError("emailAddressIncorrectPattern", panel, target);
                }
            } else {
                if (project == null) {
                    triggerError("projectDoesNotExists", panel, target);
                } else {
                    if (isUserAlreadyInProject(recipant, project)) {
                        triggerError("userAlreadyInProject", panel, target);
                    } else if (userHasBeenInvited(recipant, project)) {
                        triggerError("userAlreadyInvited", panel, target);
                    } else {
                        projectInvitationDao.sendInvitation(user, recipant, project,
                                roleDao.findByName(panel.getRole().getRoleName()));

                        window.close(target);

                        //replaceDisplayComponentAndHideLink(target);
                    }
                }

            }
        }
    };

    link.setOutputMarkupId(true);

    return link;
}

From source file:com.visural.stereotyped.ui.prototype.TreePanel.java

License:Mozilla Public License

public TreePanel(String id, final OperableTreeNode node) {
    super(id);/*from   www  .  jav  a 2s . co  m*/
    WebMarkupContainer container = new WebMarkupContainer("container");
    add(container);
    if (node.getComponent() != null && !Stereotype.class.isAssignableFrom(node.getComponent().getClass())) {
        container.add(new DragSource(Operation.MOVE) {
            @Override
            public void onBeforeDrop(Component drag, Transfer transfer) throws Reject {
                if (!allowDragAndDrop()) {
                    transfer.reject();
                } else {
                    transfer.setData(node);
                }
            }
        }.drag("a"));
    }
    DropTarget componentDrop = null;
    if (node.getSlot() != null
            || (node.getComponent().getSlots() != null && node.getComponent().getSlots().size() == 1)) {
        DropTarget newDt = new DropTarget(Operation.MOVE) {
            @Override
            public void onDrop(AjaxRequestTarget target, Transfer transfer, Location location) throws Reject {
                Slot slot = node.getSlot() != null ? node.getSlot() : node.getComponent().getSlots().get(0);
                OperableTreeNode otn = transfer.getData();
                if (otn != null && otn.getComponent() != null && slot.acceptComponent(otn.getComponent())) {
                    if (otn.getComponent().contains(slot)) {
                        transfer.reject(); // drop component on self or child of self
                    } else {
                        com.visural.stereotyped.core.Component com = otn.getComponent();
                        com.delete();
                        slot.addComponent(com);
                        updateTree(target);
                        invokePreviewRefresh(target);
                    }
                } else {
                    transfer.reject();
                }
            }
        };
        if (node.getSlot() != null) {
            container.add(newDt.dropCenter("a"));
        } else {
            componentDrop = newDt;
        }
    }
    if (node.getComponent() != null && !Stereotype.class.isAssignableFrom(node.getComponent().getClass())) {
        final DropTarget dtComp = componentDrop;
        DropTarget dtNew = new DropTarget(Operation.MOVE) {
            @Override
            public void onDrop(AjaxRequestTarget target, Transfer transfer, Location location) throws Reject {
                Slot slot = node.getComponent().getParentSlot();
                if (location.getAnchor().equals(Anchor.CENTER)) {
                    dtComp.onDrop(target, transfer, location);
                } else {
                    OperableTreeNode otn = transfer.getData();
                    if (otn != null && otn.getComponent() != null && slot.acceptComponent(otn.getComponent())) {
                        com.visural.stereotyped.core.Component com = otn.getComponent();
                        if (com.getUuid().equals(node.getComponent().getUuid())) {
                            transfer.reject(); // drop component next to self
                        } else if (com.contains(slot)) {
                            transfer.reject(); // drop component on self or child of self
                        } else {
                            switch (location.getAnchor()) {
                            case TOP:
                            case LEFT: {
                                com.delete();
                                int idx = slot.getContent().indexOf(node.getComponent());
                                if (idx < 0) {
                                    throw new IllegalStateException("Drop component was not in expected slot.");
                                }
                                slot.addComponent(idx, com);
                                updateTree(target);
                                invokePreviewRefresh(target);
                            }
                                break;
                            case BOTTOM:
                            case RIGHT: {
                                com.delete();
                                int idx = slot.getContent().indexOf(node.getComponent());
                                if (idx < 0) {
                                    throw new IllegalStateException("Drop component was not in expected slot.");
                                }
                                if (idx == slot.getContent().size() - 1) {
                                    slot.addComponent(com);
                                } else {
                                    slot.addComponent(idx + 1, com);
                                }
                                updateTree(target);
                                invokePreviewRefresh(target);
                            }
                                break;
                            default:
                                transfer.reject();
                            }
                        }
                    } else {
                        transfer.reject();
                    }
                }
            }
        }.dropTopAndBottom("a");
        if (componentDrop != null) {
            dtNew.dropCenter("a");
        }
        container.add(dtNew);
    }

    AjaxSubmitLink link = new AjaxSubmitLink("link") {

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

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (isSelected()) {
                tag.put("class", "selected");
            }
            tag.put("onmouseover",
                    "doHighlight('" + ComponentRenderer.STCOM_UUID_PREFIX + node.getUuid().toString() + "');");
            tag.put("onmouseout", "removeHighlight();");
        }
    };
    container.add(link);
    if (node.getComponent() != null) {
        link.add(new Image("icon", node.getComponent().getIcon()));
        link.add(new Label("label", new AbstractReadOnlyModel() {
            @Override
            public Object getObject() {
                return node.getComponent().getName() + (node.getComponent().isHide() ? " [hidden]" : "");
            }
        }));
    } else {
        link.add(new Image("icon", new SlotIcon()));
        link.add(new Label("label", new AbstractReadOnlyModel() {
            @Override
            public Object getObject() {
                return Function.nvl(node.getSlot().getDisplayName(), node.getSlot().getName());
            }
        }));
    }

    final Slot slot = node.getSlot() != null ? node.getSlot()
            : (node.getComponent() != null && node.getComponent().getSlots() != null
                    && node.getComponent().getSlots().size() == 1 ? node.getComponent().getSlots().get(0)
                            : null);

    if (slot == null) {
        container.add(new WebMarkupContainer("addComp").setVisible(false));
    } else {
        AjaxSubmitLink addComp;
        container.add(addComp = new AjaxSubmitLink("addComp") {
            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                invokeAdd(target, slot);
            }
        });
        addComp.setOutputMarkupId(true);
        container.add(
                new SimpleAttributeModifier("onmouseover", "jQuery('#" + addComp.getMarkupId() + "').show();"));
        container.add(
                new SimpleAttributeModifier("onmouseout", "jQuery('#" + addComp.getMarkupId() + "').hide();"));
    }
}

From source file:eu.uqasar.web.dashboard.DashboardSharePage.java

License:Apache License

private AjaxSubmitLink newShareToSelectedButton(final CheckGroup<User> userGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("shareToSelected") {

        @Override/*  ww  w  .ja  v  a 2  s.  c o  m*/
        protected void onConfigure() {
            super.onConfigure();
            // only enabled if at least one user is selected
            if (userGroup.getModelObject().isEmpty()) {
                add(new CssClassNameAppender(Model.of("disabled")) {

                    /**
                     * 
                     */
                    private static final long serialVersionUID = -3259529293647254883L;

                    // remove css class when component is rendered again
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            } else {
                setEnabled(true);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            shareConfirmationModal.appendShowDialogJavaScript(target);
        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}

From source file:eu.uqasar.web.pages.admin.companies.CompanyListPage.java

License:Apache License

private AjaxSubmitLink newDeleteSelectedButton(final CheckGroup<Company> companyGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("deleteSelected") {

        @Override/* ww  w  .  j ava  2s.  c  o m*/
        protected void onConfigure() {
            super.onConfigure();
            // only enabled if at least one user is selected
            if (companyGroup.getModelObject().isEmpty()) {
                add(new CssClassNameAppender(Model.of("disabled")) {
                    private static final long serialVersionUID = 5588027455196328830L;

                    // remove css class when component is rendered again
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            } else {
                setEnabled(true);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            deleteConfirmationModal.appendShowDialogJavaScript(target);
        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}

From source file:eu.uqasar.web.pages.admin.teams.TeamEditPage.java

License:Apache License

private AjaxSubmitLink newDeleteSelectedButton(final CheckGroup<TeamMembership> teamGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("deleteSelected") {

        @Override//from  ww  w.j  av  a 2 s  . com
        protected void onConfigure() {
            super.onConfigure();
            if (teamGroup.getModelObject().isEmpty()) {
                add(new CssClassNameAppender(Model.of("disabled")) {
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            } else {
                setEnabled(true);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            target.add(deleteConfirmationModal);
            deleteConfirmationModal.appendShowDialogJavaScript(target);
        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}

From source file:eu.uqasar.web.pages.admin.teams.TeamListPage.java

License:Apache License

private AjaxSubmitLink newDeleteSelectedButton(final CheckGroup<Team> teamGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("deleteSelected") {

        @Override//from  w  ww . ja va2 s  .  com
        protected void onConfigure() {
            super.onConfigure();
            // only enabled if at least one user is selected
            if (teamGroup.getModelObject().isEmpty()) {
                add(new CssClassNameAppender(Model.of("disabled")) {
                    private static final long serialVersionUID = 5588027455196328830L;

                    // remove css class when component is rendered again
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            } else {
                setEnabled(true);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            deleteConfirmationModal.appendShowDialogJavaScript(target);
        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}

From source file:eu.uqasar.web.pages.admin.teams.TeamListPage.java

License:Apache License

private AjaxSubmitLink addteamButton(final CheckGroup<Team> teamGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("addSelected") {

        @Override// w w w . j a v a  2  s .  c  o m
        protected void onConfigure() {
            super.onConfigure();
            // only enabled if at least one user is selected
            if (!teamGroup.getModelObject().isEmpty() && project.getId() != null) {

                setEnabled(true);
            } else {
                add(new CssClassNameAppender(Model.of("disabled")) {
                    private static final long serialVersionUID = 5588027455196328830L;

                    // remove css class when component is rendered again
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            addConfirmationModal.appendShowDialogJavaScript(target);

        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}

From source file:eu.uqasar.web.pages.admin.users.UserListPage.java

License:Apache License

private AjaxSubmitLink newDeleteSelectedButton(final CheckGroup<User> userGroup) {
    AjaxSubmitLink submitLink = new AjaxSubmitLink("deleteSelected") {

        @Override/*w w  w.j av a  2s .c  o  m*/
        protected void onConfigure() {
            super.onConfigure();
            // only enabled if at least one user is selected
            if (userGroup.getModelObject().isEmpty()) {
                add(new CssClassNameAppender(Model.of("disabled")) {
                    private static final long serialVersionUID = 5588027455196328830L;

                    // remove css class when component is rendered again
                    @Override
                    public boolean isTemporary(Component component) {
                        return true;
                    }
                });
                setEnabled(false);
            } else {
                setEnabled(true);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            deleteConfirmationModal.appendShowDialogJavaScript(target);
        }
    };
    submitLink.setOutputMarkupId(true);
    return submitLink;
}