Search in sources :

Example 36 with TextField

use of org.apache.wicket.markup.html.form.TextField in project midpoint by Evolveum.

the class ObjectPolicyConfigurationEditor method initLayout.

protected void initLayout() {
    final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label"));
    add(label);
    ListView<ObjectPolicyConfigurationTypeDto> repeater = new ListView<ObjectPolicyConfigurationTypeDto>(ID_REPEATER, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ObjectPolicyConfigurationTypeDto> item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField<String> name = new TextField<>(ID_NAME, createNameModel(item.getModel()));
            name.setOutputMarkupId(true);
            name.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            name.setEnabled(false);
            name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder")));
            textWrapper.add(name);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name));
            textWrapper.add(feedback);
            AjaxLink<String> edit = new AjaxLink<String>(ID_BUTTON_EDIT) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editPerformed(target, item);
                }
            };
            textWrapper.add(edit);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    //        initDialog();
    repeater.setOutputMarkupId(true);
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Example 37 with TextField

use of org.apache.wicket.markup.html.form.TextField in project midpoint by Evolveum.

the class PrismValuePanel method createInputComponent.

private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();
    ObjectWrapper objectWrapper = null;
    if (valueWrapper.getItem().getContainer() != null) {
        objectWrapper = valueWrapper.getItem().getContainer().getObject();
    }
    Item property = valueWrapper.getItem().getItem();
    boolean required = property.getDefinition().getMinOccurs() > 0;
    Panel component = createTypedInputComponent(id);
    if (component instanceof InputPanel) {
        InputPanel inputPanel = (InputPanel) component;
        //adding valid from/to date range validator, if necessary
        ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
        if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
        } else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
        }
        final List<FormComponent> formComponents = inputPanel.getFormComponents();
        for (FormComponent formComponent : formComponents) {
            formComponent.setLabel(labelModel);
            formComponent.setRequired(required);
            if (formComponent instanceof TextField) {
                formComponent.add(new AttributeModifier("size", "42"));
            }
            formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
        // Validation occurs when submitting the form
        //            if (form != null) {
        //                AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur"); 
        //                 
        //                formComponent.add(validator);
        //            }
        }
    }
    if (component == null) {
        throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
    }
    return component;
}
Also used : DateValidator(com.evolveum.midpoint.web.util.DateValidator) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 38 with TextField

use of org.apache.wicket.markup.html.form.TextField in project midpoint by Evolveum.

the class ObjectPolicyPanel method initLayout.

//	public void updateModel(AjaxRequestTarget target, ObjectPolicyConfigurationTypeDto config) {
//		model.setObject(new ObjectPolicyDialogDto(config, getPageBase()));
//		target.add(getContent());
//	}
public void initLayout() {
    Form form = new Form(ID_FORM);
    form.setOutputMarkupId(true);
    add(form);
    DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, new PropertyModel<QName>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(type);
    type.getInput().setNullValid(false);
    type.getInput().setRequired(true);
    TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
    form.add(fieldSubtype);
    form.add(fieldSubtype);
    DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, new PropertyModel<ObjectTemplateConfigTypeReferenceDto>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(), createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    form.add(template);
    template.getInput().setNullValid(false);
    template.getInput().setRequired(true);
    ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER, new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {

        @Override
        protected void populateItem(final ListItem item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField property = new TextField<>(ID_PROPERTY, new PropertyModel<String>(item.getModel(), PropertyConstraintTypeDto.F_PROPERTY_PATH));
            property.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            property.add(AttributeAppender.replace("placeholder", createStringResource("ObjectPolicyDialog.property.placeholder")));
            textWrapper.add(property);
            CheckBox oidBound = new CheckBox(ID_OID_BOUND, new PropertyModel<Boolean>(item.getModel(), PropertyConstraintTypeDto.F_OID_BOUND));
            oidBound.add(AttributeModifier.replace("title", createStringResource("ObjectPolicyDialog.label.oidBound.help")));
            textWrapper.add(oidBound);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    form.add(repeater);
    AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, createStringResource("ObjectPolicyDialog.button.cancel")) {

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("ObjectPolicyDialog.button.save")) {

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

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(form);
        }
    };
    form.add(save);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Form(org.apache.wicket.markup.html.form.Form) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectTemplateConfigTypeReferenceDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectTemplateConfigTypeReferenceDto) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 39 with TextField

use of org.apache.wicket.markup.html.form.TextField in project midpoint by Evolveum.

the class MyPasswordQuestionsPanel method initLayout.

public void initLayout() {
    // final Label question = new Label (F_QUESTION, mod.getPwdQuestion());
    final Label question = new Label(F_QUESTION, new PropertyModel<PasswordQuestionsDto>(mod, PasswordQuestionsDto.F_MY_QUESTIONS__QUESTIONITSELF));
    question.setOutputMarkupId(true);
    add(question);
    final TextField<String> answer = new TextField<String>(F_ANSWER, new PropertyModel(mod, SecurityQuestionAnswerDTO.F_PASSWORD_QUESTION_ANSWER));
    answer.setRequired(true);
    answer.setOutputMarkupId(true);
    add(answer);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) TextField(org.apache.wicket.markup.html.form.TextField) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 40 with TextField

use of org.apache.wicket.markup.html.form.TextField in project midpoint by Evolveum.

the class SimpleParametricRoleSelector method initLayout.

private void initLayout() {
    IModel<String> labelParamModel = new IModel<String>() {

        @Override
        public void detach() {
        }

        @Override
        public String getObject() {
            return getLabelParam();
        }

        @Override
        public void setObject(String object) {
        }
    };
    add(new Label(ID_LABEL_PARAM, labelParamModel) {

        @Override
        protected void onConfigure() {
            setVisible(getLabelParam() != null);
            super.onConfigure();
        }
    });
    IModel<String> labelRoleModel = new IModel<String>() {

        @Override
        public void detach() {
        }

        @Override
        public String getObject() {
            return getLabelRole();
        }

        @Override
        public void setObject(String object) {
        }
    };
    add(new Label(ID_LABEL_ROLE, labelRoleModel) {

        @Override
        protected void onConfigure() {
            setVisible(getLabelRole() != null);
            super.onConfigure();
        }
    });
    paramList = new ListView<String>(ID_LIST_PARAM, paramListModel) {

        @Override
        protected void populateItem(ListItem<String> item) {
            item.add(createParamLink(ID_ITEM_PARAM, item.getModel()));
        }
    };
    paramList.setOutputMarkupId(true);
    add(paramList);
    final Model<String> addInputModel = new Model<String>();
    TextField<String> addInput = new TextField<>(ID_ADD_INPUT, addInputModel);
    addInput.setOutputMarkupId(true);
    addInput.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        // nothing to do, Ajax behavior is there only to get data to model
        }
    });
    add(addInput);
    AjaxLink<String> addLink = new AjaxLink<String>(ID_ADD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            String newParam = addInputModel.getObject();
            LOGGER.debug("ADD cliked, input field value: {}", newParam);
            if (!StringUtils.isBlank(newParam)) {
                addParam(newParam);
            }
            addInputModel.setObject(null);
            target.add(SimpleParametricRoleSelector.this);
        }
    };
    add(addLink);
    AjaxLink<String> deleteLink = new AjaxLink<String>(ID_DELETE_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.debug("DELETE cliked, selected param: {}", selectedParam);
            deleteParam(selectedParam);
            target.add(SimpleParametricRoleSelector.this);
        }
    };
    add(deleteLink);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) TextField(org.apache.wicket.markup.html.form.TextField) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

TextField (org.apache.wicket.markup.html.form.TextField)61 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)37 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)30 Label (org.apache.wicket.markup.html.basic.Label)25 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)20 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)20 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)18 ListItem (org.apache.wicket.markup.html.list.ListItem)15 ListView (org.apache.wicket.markup.html.list.ListView)15 IModel (org.apache.wicket.model.IModel)14 ArrayList (java.util.ArrayList)13 PropertyModel (org.apache.wicket.model.PropertyModel)13 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)11 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)11 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)11 List (java.util.List)10 CheckBox (org.apache.wicket.markup.html.form.CheckBox)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)9 Form (org.apache.wicket.markup.html.form.Form)9 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)6