Search in sources :

Example 6 with RequiredTextField

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

the class PageSecurityQuestions method initQuestionsSection.

private void initQuestionsSection(MidpointForm form) {
    WebMarkupContainer questionsContainer = new WebMarkupContainer(ID_INSIDE_FORM);
    questionsContainer.setOutputMarkupId(true);
    questionsContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return showedQuestions;
        }
    });
    form.add(questionsContainer);
    ListView<SecurityQuestionDto> questionsView = new ListView<SecurityQuestionDto>(ID_QUESTIONS, questionsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<SecurityQuestionDto> item) {
            SecurityQuestionDto question = item.getModelObject();
            Label questionText = new Label(ID_QUESTION_TEXT, new PropertyModel<String>(item.getModel(), "questionText"));
            item.add(questionText);
            RequiredTextField<String> questionAnswer = new RequiredTextField<>(ID_QUESTION_ANSWER, new PropertyModel<String>(item.getModel(), "questionAnswer"));
            questionAnswer.setOutputMarkupId(true);
            questionAnswer.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    String answer = generateAnswer();
                    answerModel.setObject(answer);
                    target.add(getHiddenAnswer());
                }
            });
            item.add(questionAnswer);
        }
    };
    questionsView.setOutputMarkupId(true);
    questionsContainer.add(questionsView);
    AjaxButton back = new AjaxButton(ID_BACK_2_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showedQuestions = false;
            questionsModel.setObject(new ArrayList<SecurityQuestionDto>());
            getHiddenUsername().getModel().setObject(null);
            getHiddenAnswer().getModel().setObject(null);
            target.add(getMainForm());
        }
    };
    questionsContainer.add(back);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) SecurityQuestionDto(com.evolveum.midpoint.web.security.util.SecurityQuestionDto) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 7 with RequiredTextField

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

the class PageEmailNonse method initStaticLayout.

private void initStaticLayout(MidpointForm form) {
    WebMarkupContainer staticLayout = new WebMarkupContainer(ID_STATIC_LAYOUT);
    staticLayout.setOutputMarkupId(true);
    staticLayout.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isDynamicForm();
        }
    });
    form.add(staticLayout);
    RequiredTextField<String> visibleUsername = new RequiredTextField<>(ID_EMAIL, new Model<>());
    visibleUsername.setOutputMarkupId(true);
    staticLayout.add(visibleUsername);
}
Also used : VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 8 with RequiredTextField

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

the class PageForgotPassword method initStaticLayout.

private void initStaticLayout(Form<?> mainForm) {
    WebMarkupContainer staticLayout = new WebMarkupContainer(ID_STATIC_LAYOUT);
    staticLayout.setOutputMarkupId(true);
    mainForm.add(staticLayout);
    staticLayout.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !isDynamicForm();
        }
    });
    WebMarkupContainer userNameContainer = new WebMarkupContainer(ID_USERNAME_CONTAINER);
    userNameContainer.setOutputMarkupId(true);
    staticLayout.add(userNameContainer);
    RequiredTextField<String> userName = new RequiredTextField<>(ID_USERNAME, new Model<>());
    userName.setOutputMarkupId(true);
    userNameContainer.add(userName);
    userNameContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            return getResetPasswordPolicy().getResetMethod() == ResetMethod.SECURITY_QUESTIONS;
        }
    });
    WebMarkupContainer emailContainer = new WebMarkupContainer(ID_EMAIL_CONTAINER);
    emailContainer.setOutputMarkupId(true);
    staticLayout.add(emailContainer);
    RequiredTextField<String> email = new RequiredTextField<>(ID_EMAIL, new Model<>());
    email.add(RfcCompliantEmailAddressValidator.getInstance());
    email.setOutputMarkupId(true);
    emailContainer.add(email);
    emailContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            ResetMethod resetMethod = getResetPasswordPolicy().getResetMethod();
            return resetMethod == ResetMethod.SECURITY_QUESTIONS || resetMethod == ResetMethod.MAIL;
        }
    });
}
Also used : VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) ResetMethod(com.evolveum.midpoint.web.page.forgetpassword.ResetPolicyDto.ResetMethod) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 9 with RequiredTextField

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

the class PageForgotPassword method createStaticFormQuery.

private ObjectQuery createStaticFormQuery(Form form) {
    RequiredTextField<String> usernameTextFiled = (RequiredTextField) form.get(createComponentPath(ID_STATIC_LAYOUT, ID_USERNAME_CONTAINER, ID_USERNAME));
    RequiredTextField<String> emailTextField = (RequiredTextField) form.get(createComponentPath(ID_STATIC_LAYOUT, ID_EMAIL_CONTAINER, ID_EMAIL));
    String username = usernameTextFiled != null ? usernameTextFiled.getModelObject() : null;
    String email = emailTextField != null ? emailTextField.getModelObject() : null;
    LOGGER.debug("Reset Password user info form submitted. username={}, email={}", username, email);
    ResetPolicyDto resetPasswordPolicy = getResetPasswordPolicy();
    if (resetPasswordPolicy == null) {
        passwordResetNotSupported();
    }
    ResetMethod method = resetPasswordPolicy.getResetMethod();
    if (method == null) {
        passwordResetNotSupported();
    }
    switch(method) {
        case MAIL:
            return getPrismContext().queryFor(UserType.class).item(UserType.F_EMAIL_ADDRESS).eq(email).matchingCaseIgnore().build();
        case SECURITY_QUESTIONS:
            return getPrismContext().queryFor(UserType.class).item(UserType.F_NAME).eqPoly(username).matchingNorm().and().item(UserType.F_EMAIL_ADDRESS).eq(email).matchingCaseIgnore().build();
        default:
            passwordResetNotSupported();
            // not reached
            return null;
    }
}
Also used : RequiredTextField(org.apache.wicket.markup.html.form.RequiredTextField) ResetMethod(com.evolveum.midpoint.web.page.forgetpassword.ResetPolicyDto.ResetMethod)

Aggregations

RequiredTextField (org.apache.wicket.markup.html.form.RequiredTextField)9 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 Label (org.apache.wicket.markup.html.basic.Label)4 ListItem (org.apache.wicket.markup.html.list.ListItem)3 ListView (org.apache.wicket.markup.html.list.ListView)3 ResetMethod (com.evolveum.midpoint.web.page.forgetpassword.ResetPolicyDto.ResetMethod)2 AttributeModifier (org.apache.wicket.AttributeModifier)2 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)2 TextArea (org.apache.wicket.markup.html.form.TextArea)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 LinkPanel (com.evolveum.midpoint.web.component.data.column.LinkPanel)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 TaskDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)1 TaskDtoExecutionStatus (com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoExecutionStatus)1 SecurityQuestionDto (com.evolveum.midpoint.web.security.util.SecurityQuestionDto)1 JQueryIcon (com.googlecode.wicket.jquery.ui.JQueryIcon)1