Java Code Examples for org.apache.wicket.markup.html.form.PasswordTextField#setRequired()

The following examples show how to use org.apache.wicket.markup.html.form.PasswordTextField#setRequired() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PasswordPropertyEditor.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	input = new PasswordTextField("input", Model.of(getModelObject()));
	input.setRequired(false);
	input.setResetPassword(false);
	input.setLabel(Model.of(getDescriptor().getDisplayName()));
	add(input);

	Password password = getDescriptor().getPropertyGetter().getAnnotation(Password.class);
	String autoComplete = password.autoComplete();
	if (StringUtils.isNotBlank(autoComplete))
		input.add(AttributeAppender.append("autocomplete", autoComplete));
	input.add(new OnTypingDoneBehavior() {

		@Override
		protected void onTypingDone(AjaxRequestTarget target) {
			onPropertyUpdating(target);
		}
		
	});
}
 
Example 2
Source File: SecureStringEditor.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct simple text editor.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param errorLabelModel error label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param readOnly  if true this component is read only
 */
public SecureStringEditor(final String id,
                          final MarkupContainer markupProvider,
                          final IModel<String> model,
                          final IModel<String> labelModel,
                          final IModel<String> errorLabelModel,
                          final AttrValueWithAttribute attrValue,
                          final boolean readOnly) {

    super(id, "secureStringEditor", markupProvider);

    final PasswordTextField textField = new PasswordTextField(EDIT, model);

    textField.setLabel(labelModel);
    textField.setRequired(attrValue.getAttribute().isMandatory());
    textField.setEnabled(!readOnly);

    if (StringUtils.isNotBlank(attrValue.getAttribute().getRegexp())) {
        textField.add(new CustomPatternValidator(attrValue.getAttribute().getRegexp(), errorLabelModel));
    }
    textField.add(new AttributeModifier("placeholder", labelModel));
    add(textField);
}
 
Example 3
Source File: ChangePasswordPopupPanel.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, ChangePasswordPopupPanel.class);
	
	passwordForm = new Form<Void>("form");
	body.add(passwordForm);
	
	newPasswordField = new PasswordTextField("newPassword", Model.of(""));
	newPasswordField.setLabel(new ResourceModel("administration.user.field.newPassword"));
	newPasswordField.setRequired(true);
	passwordForm.add(newPasswordField);
	
	confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));
	confirmPasswordField.setLabel(new ResourceModel("administration.user.field.confirmPassword"));
	confirmPasswordField.setRequired(true);
	passwordForm.add(confirmPasswordField);
	
	return body;
}
 
Example 4
Source File: ManageUsersPage.java    From webanno with Apache License 2.0 5 votes vote down vote up
public DetailForm(String id, IModel<User> aModel)
{
    super(id, new CompoundPropertyModel<>(aModel));

    setOutputMarkupId(true);
    setOutputMarkupPlaceholderTag(true);
    
    add(new TextField<String>("username")
            .setRequired(true)
            .add(this::validateUsername)
            .add(enabledWhen(() -> isCreate)));
    add(new Label("lastLogin"));
    add(new EmailTextField("email"));
    
    passwordField = new PasswordTextField("password");
    passwordField.setModel(PropertyModel.of(DetailForm.this, "password"));
    passwordField.setRequired(false);
    add(passwordField);
    
    repeatPasswordField = new PasswordTextField("repeatPassword");
    repeatPasswordField.setModel(PropertyModel.of(DetailForm.this, "repeatPassword"));
    repeatPasswordField.setRequired(false);
    add(repeatPasswordField);
    
    add(new EqualPasswordInputValidator(passwordField, repeatPasswordField));
    
    add(new ListMultipleChoice<>("roles", getRoles())
            .add(this::validateRoles)
            .add(visibleWhen(ManageUsersPage.this::isAdmin)));
    
    add(new CheckBox("enabled")
            .add(this::validateEnabled)
            .add(visibleWhen(ManageUsersPage.this::isAdmin))
            .setOutputMarkupPlaceholderTag(true));

    add(new LambdaAjaxButton<>("save", ManageUsersPage.this::actionSave));
    
    add(new LambdaAjaxLink("cancel", ManageUsersPage.this::actionCancel));
}
 
Example 5
Source File: TransferPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
protected void initComponents() {
    add(new Label("host", getString("ActionContributor.Run.destination.host")));
    TextField<String> hostField = new TextField<String>("hostField",
            new PropertyModel<String>(destination, "host"));
    hostField.setLabel(new Model<String>(getString("ActionContributor.Run.destination.host")));
    hostField.setRequired(true);
    hostField.add(new JcrNameValidator());
    add(hostField);

    add(new Label("port", getString("ActionContributor.Run.destination.port")));
    TextField<Integer> portField = new TextField<Integer>("portField",
            new PropertyModel<Integer>(destination, "port"));
    add(portField);

    add(new Label("folder", getString("Folder")));
    TextField<String> folderField = new TextField<String>("folderField",
            new PropertyModel<String>(destination, "folder"));
    add(folderField);

    add(new Label("username", getString("ActionContributor.Run.destination.username")));
    TextField<String> userField = new TextField<String>("userField",
            new PropertyModel<String>(destination, "username"));
    add(userField);

    add(new Label("password", getString("ActionContributor.Run.destination.password")));
    PasswordTextField passwordField = new PasswordTextField("passwordField",
            new PropertyModel<String>(destination, "password"));
    passwordField.setRequired(false);
    passwordField.setResetPassword(false);
    add(passwordField);
    
    add(new Label("changedFileName", getString("ActionContributor.Run.destination.changedFileName")));
    TextField<String> fileNameField = new TextField<String>("changedFileNameField",
            new PropertyModel<String>(destination, "changedFileName"));
    fileNameField.setLabel(new Model<String>(getString("ActionContributor.Run.destination.changedFileName")));
    fileNameField.setRequired(false);
    fileNameField.add(new JcrNameValidator());
    add(fileNameField);       
}
 
Example 6
Source File: DistributionSettingsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void addComponents(Form<Settings> form) {

	final TextField<String> mailServerIpField = new TextField<String>("mailServer.ip");
       form.add(mailServerIpField);
       final TextField<Integer> mailServerPortField = new TextField<Integer>("mailServer.port");
       form.add(mailServerPortField);
       final TextField<String> mailServerSenderField = new TextField<String>("mailServer.from");
       form.add(mailServerSenderField);
       final TextField<String> mailServerUsernameField = new TextField<String>("mailServer.username");
       form.add(mailServerUsernameField);
       final PasswordTextField mailServerPasswordField = new PasswordTextField("mailServer.password");
       mailServerPasswordField.setResetPassword(false);
       mailServerPasswordField.setRequired(false);
       form.add(mailServerPasswordField);
       final CheckBox tlsCheckField = new CheckBox("mailServer.enableTls");
       form.add(tlsCheckField);        
       form.add(new MailServerValidator(new FormComponent[] {mailServerIpField, mailServerPortField, mailServerSenderField}));
       
       final TextField<String> distributorDatePatternField = new TextField<String>("distributor.datePattern");
       distributorDatePatternField.add(new JcrNameValidator(getString("Settings.general.distributorDatePattern.error")));
       form.add(distributorDatePatternField);
       final TextField<String> distributorTimePatternField = new TextField<String>("distributor.timePattern");
       distributorTimePatternField.add(new JcrNameValidator(getString("Settings.general.distributorTimePattern.error")));
       form.add(distributorTimePatternField);
       
       Settings settings = storageService.getSettings();
       oldMailPort = settings.getMailServer().getPort();
       oldMailIp = settings.getMailServer().getIp();
       
}
 
Example 7
Source File: UserFormPopupPanel.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@Override
protected Component createBody(String wicketId) {
	DelegatedMarkupPanel body = new DelegatedMarkupPanel(wicketId, UserFormPopupPanel.class);
	
	userForm = new Form<User>("form", getModel());
	body.add(userForm);
	
	TextField<String> emailField = new EmailTextField("email", BindingModel.of(userForm.getModel(),
			Binding.user().email())) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(UserFormPopupPanel.this.isAddMode());
		}
	};
	emailField.setLabel(new ResourceModel("administration.user.field.email"));
	emailField.setRequired(isAddMode());
	userForm.add(emailField);
	
	TextField<String> fullNameField = new TextField<String>("fullName", BindingModel.of(userForm.getModel(),
			Binding.user().fullName()));
	fullNameField.setLabel(new ResourceModel("administration.user.field.fullName"));
	userForm.add(fullNameField);
	
	WebMarkupContainer passwordContainer = new WebMarkupContainer("passwordContainer") {
		private static final long serialVersionUID = 2727669661139358058L;
		
		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(UserFormPopupPanel.this.isAddMode());
		}
	};
	userForm.add(passwordContainer);
	
	CheckBox activeField = new CheckBox("active", BindingModel.of(userForm.getModel(), Binding.user().active()));
	activeField.setLabel(new ResourceModel("administration.user.field.active"));
	passwordContainer.add(activeField);
	
	newPasswordField = new PasswordTextField("newPassword", Model.of(""));
	newPasswordField.setLabel(new ResourceModel("administration.user.field.password"));
	newPasswordField.setRequired(true);
	passwordContainer.add(newPasswordField);
	
	confirmPasswordField = new PasswordTextField("confirmPassword", Model.of(""));
	confirmPasswordField.setLabel(new ResourceModel("administration.user.field.confirmPassword"));
	confirmPasswordField.setRequired(true);
	passwordContainer.add(confirmPasswordField);
	
	LocaleDropDownChoice localeField = new LocaleDropDownChoice("locale", BindingModel.of(userForm.getModel(), Binding.user().locale()));
	localeField.setLabel(new ResourceModel("administration.user.field.locale"));
	userForm.add(localeField);
	
	return body;
}