Search in sources :

Example 76 with AjaxRequestTarget

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

the class PageSizePopover method initLayout.

protected void initLayout() {
    Button popButton = new Button(ID_POP_BUTTON);
    popButton.setOutputMarkupId(true);
    add(popButton);
    WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
    popover.setOutputMarkupId(true);
    add(popover);
    Form form = new Form(ID_FORM);
    popover.add(form);
    AjaxSubmitButton button = new AjaxSubmitButton(ID_BUTTON) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            super.onError(target, form);
            target.add(getPageBase().getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            super.onSubmit(target, form);
            pageSizeChanged(target);
        }
    };
    form.add(button);
    TextField input = new TextField(ID_INPUT, createInputModel());
    input.add(new RangeValidator(5, 100));
    input.setLabel(createStringResource("PageSizePopover.title"));
    input.add(new SearchFormEnterBehavior(button));
    input.setType(Integer.class);
    form.add(input);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Button(org.apache.wicket.markup.html.form.Button) Form(org.apache.wicket.markup.html.form.Form) TextField(org.apache.wicket.markup.html.form.TextField) RangeValidator(org.apache.wicket.validation.validator.RangeValidator) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 77 with AjaxRequestTarget

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

the class LinkColumn method populateItem.

@Override
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
    IModel model = createLinkModel(rowModel);
    cellItem.add(new LinkPanel(componentId, model) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            LinkColumn.this.onClick(target, rowModel);
        }

        @Override
        public boolean isEnabled() {
            return LinkColumn.this.isEnabled(rowModel);
        }
    });
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel)

Example 78 with AjaxRequestTarget

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

the class ObjectLinkColumn method populateItem.

@Override
public void populateItem(Item<ICellPopulator<T>> cellItem, String componentId, final IModel<T> rowModel) {
    IModel<ObjectType> superModel = createLinkModel(rowModel);
    final ObjectType targetObjectType = superModel.getObject();
    IModel<String> nameModel = new PropertyModel<String>(superModel, FocusType.F_NAME.getLocalPart() + ".orig");
    cellItem.add(new LinkPanel(componentId, nameModel) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectLinkColumn.this.onClick(target, rowModel, targetObjectType);
        }

        @Override
        public boolean isEnabled() {
            return ObjectLinkColumn.this.isEnabled(rowModel);
        }
    });
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 79 with AjaxRequestTarget

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

the class ObjectNameColumn method populateItem.

@Override
public void populateItem(final Item<ICellPopulator<SelectableBean<O>>> cellItem, String componentId, final IModel<SelectableBean<O>> rowModel) {
    IModel<String> labelModel = new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            SelectableBean<O> selectableBean = rowModel.getObject();
            O value = selectableBean.getValue();
            if (value == null) {
                OperationResult result = selectableBean.getResult();
                OperationResultStatusPresentationProperties props = OperationResultStatusPresentationProperties.parseOperationalResultStatus(result.getStatus());
                return cellItem.getString(props.getStatusLabelKey());
            } else {
                String name = WebComponentUtil.getName(value);
                if (selectableBean.getResult() != null) {
                    StringBuilder complexName = new StringBuilder();
                    complexName.append(name);
                    complexName.append(" (");
                    complexName.append(selectableBean.getResult().getStatus());
                    complexName.append(")");
                    return complexName.toString();
                }
                return name;
            }
        }
    };
    if (isClickable(rowModel)) {
        // beware: rowModel is very probably resolved at this moment; but it seems to cause no problems
        cellItem.add(new LinkPanel(componentId, labelModel) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                SelectableBean<O> selectableBean = rowModel.getObject();
                O value = selectableBean.getValue();
                if (value == null) {
                    OperationResult result = selectableBean.getResult();
                    throw new RestartResponseException(new PageOperationResult(result));
                } else {
                    if (selectableBean.getResult() != null) {
                        throw new RestartResponseException(new PageOperationResult(selectableBean.getResult()));
                    } else {
                        ObjectNameColumn.this.onClick(target, rowModel);
                    }
                }
            }
        });
    } else {
        cellItem.add(new Label(componentId, labelModel));
    }
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) OperationResultStatusPresentationProperties(com.evolveum.midpoint.web.page.admin.server.dto.OperationResultStatusPresentationProperties) PageOperationResult(com.evolveum.midpoint.web.page.error.PageOperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 80 with AjaxRequestTarget

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

the class NavigatorPanel method initFirst.

private void initFirst() {
    WebMarkupContainer first = new WebMarkupContainer(ID_FIRST);
    first.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return isFirstEnabled() ? "" : "disabled";
        }
    }));
    add(first);
    AjaxLink firstLink = new AjaxLink(ID_FIRST_LINK) {

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

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

        @Override
        public boolean isEnabled() {
            return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
        }
    });
    first.add(firstLink);
}
Also used : AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)393 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)108 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)105 ArrayList (java.util.ArrayList)91 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)82 Form (org.apache.wicket.markup.html.form.Form)78 IModel (org.apache.wicket.model.IModel)73 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)71 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)56 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 ListItem (org.apache.wicket.markup.html.list.ListItem)43 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)34 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 ListView (org.apache.wicket.markup.html.list.ListView)32 TextField (org.apache.wicket.markup.html.form.TextField)30