当前位置: 首页>>代码示例>>Java>>正文


Java PatternValidator类代码示例

本文整理汇总了Java中org.apache.wicket.validation.validator.PatternValidator的典型用法代码示例。如果您正苦于以下问题:Java PatternValidator类的具体用法?Java PatternValidator怎么用?Java PatternValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PatternValidator类属于org.apache.wicket.validation.validator包,在下文中一共展示了PatternValidator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: RegisterPage

import org.apache.wicket.validation.validator.PatternValidator; //导入依赖的package包/类
public RegisterPage(PageParameters parameters) {
	super(parameters);

	Form<User> form = new InputValidationForm<User>("form") {

		@Override
		protected void onSubmit() {
			tryToRegister();
		}
	};

	mail = new TextField<>("mail", new PropertyModel<String>(newUser, "mail"));
	InputBorder<String> mailValidationBorder = new OnEventInputBeanValidationBorder<>(
			"mailValidationBorder", mail,
			new StringResourceModel("label.mail", this, null),
			new StringResourceModel("help.mail", this, null),
			HtmlEvent.ONBLUR);
	form.add(mailValidationBorder);

	userName = new TextField<>("userName", new PropertyModel<String>(newUser, "userName"));
	InputBorder<String> userNameValidationBorder = new OnEventInputBeanValidationBorder<>(
			"userNameValidationBorder", userName,
			new StringResourceModel("label.userName", this, null),
			new StringResourceModel("help.userName", this, null),
			HtmlEvent.ONBLUR);
	form.add(userNameValidationBorder);

	firstName = new TextField<>("firstName", new PropertyModel<String>(newUser, "firstName"));
	InputBorder<String> firstNameValidationBorder = new OnEventInputBeanValidationBorder<>(
			"firstNameValidationBorder", firstName,
			new StringResourceModel("label.firstName", this, null), HtmlEvent.ONBLUR);
	form.add(firstNameValidationBorder);

	lastName = new TextField<>("lastName", new PropertyModel<String>(newUser, "lastName"));
	InputBorder<String> lastNameValidationBorder = new OnEventInputBeanValidationBorder<>(
			"lastNameValidationBorder", lastName,
			new StringResourceModel("label.lastName", this, null), HtmlEvent.ONBLUR);
	form.add(lastNameValidationBorder);

	password = new PasswordTextField("password", Model.of(""));
	password.add(new PatternValidator(AuthenticationService.PW_PATTERN));
	InputBorder<String> passwordValidationBorder = new InputBorder(
			"passwordValidationBorder", password,
			new StringResourceModel("label.password", this, null),
			new StringResourceModel("help.password", this, null));
	form.add(passwordValidationBorder);

	confirmPassword = new PasswordTextField("confirmPassword", Model.of(""));
	InputBorder<String> confirmPasswordValidationBorder = new InputBorder(
			"confirmPasswordValidationBorder", confirmPassword,
			new StringResourceModel("label.password.confirm", this, null));
	form.add(confirmPasswordValidationBorder);
	form.add(new EqualPasswordInputValidator(password, confirmPassword));
	
	add(form);
}
 
开发者ID:U-QASAR,项目名称:u-qasar.platform,代码行数:57,代码来源:RegisterPage.java

示例2: zipField

import org.apache.wicket.validation.validator.PatternValidator; //导入依赖的package包/类
private Component zipField() {
    RequiredTextField<String> zip = new RequiredTextField<>("zip", new PropertyModel<>(userInfoModel, "address.zip"));
    zip.add(new PatternValidator("^[0-9]{5}$"));
    return zip;
}
 
开发者ID:zutherb,项目名称:AppStash,代码行数:6,代码来源:RegistrationPage.java

示例3: WidgetTextField

import org.apache.wicket.validation.validator.PatternValidator; //导入依赖的package包/类
public WidgetTextField(String id, Map<String, Object> object,
        FieldController widget, Map<String, Object> components, Form<?> form) {
    super(id);

    Label label = new Label("label", widget.getTextField().label());
    // label.setOutputMarkupPlaceholderTag(true);
    add(label);
    TextFieldType widgetType = widget.getTextField().type();
    TextField<String> textField = null;
    if (widgetType == TextFieldType.EMAIL
            || widgetType == TextFieldType.TEXT
            || widgetType == TextFieldType.NUMBER
            || widgetType == TextFieldType.REGX
            || widgetType == TextFieldType.URL) {
        textField = (TextField<String>) components.get(widget.getName());
        if (widget.getType().getName().equals("java.lang.Byte")
                || widget.getType().getName().equals("byte")) {
            textField.add(new ByteValidator());
        } else if (widget.getType().getName().equals("java.lang.Long")
                || widget.getType().getName().equals("long")) {
            textField.add(new LongValidator());
        } else if (widget.getType().getName().equals("java.lang.Double")
                || widget.getType().getName().equals("double")) {
            textField.add(new DoubleValidator());
        } else if (widget.getType().getName().equals("java.lang.Integer")
                || widget.getType().getName().equals("int")) {
            textField.add(new IntegerValidator());
        } else if (widget.getType().getName().equals("java.lang.Float")
                || widget.getType().getName().equals("float")) {
            textField.add(new FloatValidator());
        } else if (widget.getType().getName().equals("java.lang.Short")
                || widget.getType().getName().equals("short")) {
            textField.add(new ShortValidator());
        } else if (widget.getType().getName().equals("java.lang.String")) {
            if (widget.getTextField().type() == TextFieldType.EMAIL) {
                textField.add(new EmailAddressValidator());
            } else if (widget.getTextField().type() == TextFieldType.URL) {
                textField.add(new UrlValidator());
            } else if (widget.getTextField().type() == TextFieldType.REGX) {
                textField.add(new PatternValidator(widget.getTextField()
                        .pattern()));
            }
        } else {
            throw new WicketRuntimeException("unknow type "
                    + widget.getType().getName());
        }
    }

    // textField.setOutputMarkupPlaceholderTag(true);

    add(textField);
    if (widget.getUnique() != null) {
        UniqueValidator validator = new UniqueValidator(widget.getUnique(),
                object, textField, components);
        form.add(validator);
    }

    textField.setLabel(new Model<String>(widget.getTextField().label()));
    if (widget.getNotNull() != null) {
        textField.setRequired(true);
    }

    textField.add(AttributeModifier.replace("placeholder", widget
            .getTextField().placeholder()));
    InputFeedback feedback = new InputFeedback("feedback", textField);

    // feedback.setOutputMarkupPlaceholderTag(true);
    add(feedback);
}
 
开发者ID:PkayJava,项目名称:pluggable,代码行数:70,代码来源:WidgetTextField.java


注:本文中的org.apache.wicket.validation.validator.PatternValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。