use of org.apache.wicket.markup.html.form.Form in project midpoint by Evolveum.
the class PageAccountActivation method initLayout.
private void initLayout() {
WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
activationContainer.setOutputMarkupId(true);
add(activationContainer);
activationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !activated;
}
});
Form form = new Form<>(ID_MAIN_FORM);
activationContainer.add(form);
Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
usernamePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
});
form.add(usernamePanel);
PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
form.add(passwordPanel);
AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
propagatePassword(target, form);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
target.add(getFeedbackPanel());
}
};
form.add(confirmPasswrod);
WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
confirmationContainer.setOutputMarkupId(true);
confirmationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return activated;
}
});
add(confirmationContainer);
AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
confirmationContainer.add(linkToLogin);
RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
confirmationContainer.add(activatedShadows);
List<ShadowType> shadowsToActivate = getShadowsToActivate();
if (shadowsToActivate.isEmpty()) {
LOGGER.error("No accounts to validate for user {}", userModel.getObject());
getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
throw new RestartResponseException(PageLogin.class);
}
for (ShadowType shadow : shadowsToActivate) {
Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
activatedShadows.add(shadowDesc);
}
}
use of org.apache.wicket.markup.html.form.Form in project midpoint by Evolveum.
the class PageRequestRole method initButtons.
private void initButtons(Form mainForm) {
AjaxSubmitButton save = new AjaxSubmitButton(ID_SAVE_BUTTON, createStringResource("PageBase.button.save")) {
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
onSavePerformed(target);
}
};
mainForm.setDefaultButton(save);
mainForm.add(save);
AjaxSubmitButton cancel = new AjaxSubmitButton(ID_CANCEL_BUTTON, createStringResource("PageBase.button.back")) {
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getFeedbackPanel());
}
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
// onCancelPerformed(target);
}
};
mainForm.add(cancel);
}
use of org.apache.wicket.markup.html.form.Form in project midpoint by Evolveum.
the class PageSecurityQuestions method initLayout.
public void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
pqPanels = new ArrayList<MyPasswordQuestionsPanel>();
PrismObject<SecurityPolicyType> securityPolicy = getSecurityPolicy();
LOGGER.trace("Found security policy: {}", securityPolicy);
if (securityPolicy == null) {
LOGGER.error("No security policy, cannot process security questions");
// we do not want to provide any information to the attacker.
throw new RestartResponseException(PageError.class);
}
questionNumber = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestionNumber() : 0;
policyQuestionList = securityPolicy.asObjectable().getCredentials() != null && securityPolicy.asObjectable().getCredentials().getSecurityQuestions() != null ? securityPolicy.asObjectable().getCredentials().getSecurityQuestions().getQuestion() : new ArrayList<SecurityQuestionDefinitionType>();
List<SecurityQuestionAnswerDTO> userQuestionList = model.getObject().getSecurityAnswers();
if (userQuestionList == null) {
getSession().error(getString("pageForgetPassword.message.ContactAdminQuestionsNotSet"));
SecurityContext securityContext = SecurityContextHolder.getContext();
securityContext.setAuthentication(null);
throw new RestartResponseException(PageForgotPassword.class);
}
if (questionNumber <= userQuestionList.size()) {
// Questions
for (Iterator iterator = policyQuestionList.iterator(); iterator.hasNext(); ) {
SecurityQuestionDefinitionType securityQuestionDefinitionType = (SecurityQuestionDefinitionType) iterator.next();
// user's question List loop to match the questions
for (int userQuestint = 0; userQuestint < userQuestionList.size(); userQuestint++) {
// if the question is in the policy check
int panelNumber = 0;
if (userQuestionList.get(userQuestint).getPwdQuestion().equalsIgnoreCase(securityQuestionDefinitionType.getIdentifier())) {
SecurityQuestionAnswerDTO a = new SecurityQuestionAnswerDTO(userQuestionList.get(userQuestint).getPwdQuestion(), "", userQuestionList.get(userQuestint).getQuestionItself());
a = checkIfQuestionisValid(a, policyQuestionList);
MyPasswordQuestionsPanel panel = new MyPasswordQuestionsPanel(ID_PASSWORD_QUESTIONS_PANEL + panelNumber, a);
pqPanels.add(panel);
panelNumber++;
// This is the Question!
}
}
}
}
add(mainForm);
mainForm.add(getPanels(pqPanels));
initButtons(mainForm);
}
use of org.apache.wicket.markup.html.form.Form in project midpoint by Evolveum.
the class WizardSteps method initLayout.
protected void initLayout() {
ListView<WizardStepDto> linkContainer = new ListView<WizardStepDto>(ID_LINK_REPEATER, getModel()) {
@Override
protected void populateItem(ListItem<WizardStepDto> item) {
final WizardStepDto dto = item.getModelObject();
item.setRenderBodyOnly(true);
AjaxSubmitLink button = new AjaxSubmitLink(ID_LINK) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
changeStepPerformed(target, dto);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
item.add(button);
button.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
final boolean enabled = ((PageResourceWizard) getPageBase()).isCurrentStepComplete();
// System.out.println(dto.getName() + " enabled = " + enabled);
return enabled;
}
@Override
public boolean isVisible() {
return dto.isVisible();
}
});
button.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return dto.getWizardStep() == getActiveStep() ? "current" : null;
}
}));
button.add(AttributeModifier.replace("style", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
final boolean enabled = ((PageResourceWizard) getPageBase()).isCurrentStepComplete();
// TODO respect color scheme (and find a better style for disabled anyway...)
return enabled ? null : "color: #FFF;";
}
}));
Label label = new Label(ID_LABEL, createLabelModel(dto.getName()));
button.add(label);
}
};
add(linkContainer);
AjaxLink help = new AjaxLink(ID_BUTTON_HELP) {
@Override
public void onClick(AjaxRequestTarget target) {
showHelpPerformed(target);
}
};
add(help);
initModals();
}
use of org.apache.wicket.markup.html.form.Form in project midpoint by Evolveum.
the class SearchItemPanel method initPopover.
private void initPopover() {
WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
popover.setOutputMarkupId(true);
add(popover);
WebMarkupContainer popoverBody = new WebMarkupContainer(ID_POPOVER_BODY);
popoverBody.setOutputMarkupId(true);
popover.add(popoverBody);
ListView values = new ListView<DisplayableValue>(ID_VALUES, new PropertyModel<List<DisplayableValue>>(popoverModel, SearchItem.F_VALUES)) {
@Override
protected void populateItem(final ListItem<DisplayableValue> item) {
item.add(AttributeModifier.replace("style", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return item.getIndex() != 0 ? "margin-top: 5px;" : null;
}
}));
SearchPopupPanel fragment = createPopoverFragment(item.getModel());
fragment.setRenderBodyOnly(true);
item.add(fragment);
}
};
popoverBody.add(values);
AjaxSubmitButton update = new AjaxSubmitButton(ID_UPDATE, createStringResource("SearchItemPanel.update")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
updateItemPerformed(target);
}
};
popoverBody.add(update);
AjaxButton close = new AjaxButton(ID_CLOSE, createStringResource("SearchItemPanel.close")) {
@Override
public void onClick(AjaxRequestTarget target) {
closeEditPopoverPerformed(target);
}
};
popoverBody.add(close);
}
Aggregations