Search in sources :

Example 51 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class ACAttributeValuePanel method initLayout.

private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
    ACValueConstructionDto dto = getModel().getObject();
    PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
    InputPanel input = createTypedInputComponent(ID_INPUT, definition);
    for (FormComponent comp : input.getFormComponents()) {
        comp.setLabel(new PropertyModel<>(dto.getAttribute(), ACAttributeDto.F_NAME));
        if (!ignoreMandatoryAttributes) {
            comp.setRequired(definition.getMinOccurs() > 0);
        }
        comp.add(new AjaxFormComponentUpdatingBehavior("blur") {

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
            }
        });
    }
    add(input);
    AjaxLink<Void> addLink = new AjaxLink<Void>(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addPerformed(target);
        }
    };
    add(addLink);
    addLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isAddVisible();
        }
    });
    AjaxLink<Void> removeLink = new AjaxLink<Void>(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removePerformed(target);
        }
    };
    add(removeLink);
    removeLink.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isRemoveVisible();
        }
    });
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FormComponent(org.apache.wicket.markup.html.form.FormComponent) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 52 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project gitblit by gitblit.

the class BooleanChoiceOption method setup.

private void setup() {
    add(checkbox);
    add(choice.setMarkupId("choice").setEnabled(choice.getChoices().size() > 0));
    choice.setEnabled(checkbox.getModelObject());
    checkbox.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            choice.setEnabled(checkbox.getModelObject());
            target.addComponent(choice);
            if (!choice.isEnabled()) {
                choice.setModelObject(null);
            }
        }
    });
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Aggregations

AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)52 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)51 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)26 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)25 TextField (org.apache.wicket.markup.html.form.TextField)20 Label (org.apache.wicket.markup.html.basic.Label)18 List (java.util.List)16 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)16 IModel (org.apache.wicket.model.IModel)16 ArrayList (java.util.ArrayList)15 ListItem (org.apache.wicket.markup.html.list.ListItem)13 ListView (org.apache.wicket.markup.html.list.ListView)13 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)10 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)9 CheckBox (org.apache.wicket.markup.html.form.CheckBox)8 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)8 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)7 Form (org.apache.wicket.markup.html.form.Form)7 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)5 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)5