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);
}
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);
}
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;
}
});
}
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;
}
}
Aggregations