List of usage examples for org.apache.wicket.validation.validator StringValidator StringValidator
public StringValidator(Integer minimum, Integer maximum)
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private TextField<String> newPrefixTextField(final ModbusConfigurationEntry configEntry) { final RequiredTextField<String> textField = new RequiredTextField<String>("prefix", new PropertyModel<String>(configEntry, "designatorRange.designator")); textField.add(new PatternValidator("[A-Za-z0-9_]+") { @Override//from ww w .j a v a 2 s.c o m protected ValidationError decorate(ValidationError error, IValidatable<String> validatable) { error.addKey("prefix.PatternValidator"); return error; } }); textField.add(new StringValidator(1, 12) { @Override protected ValidationError decorate(ValidationError error, IValidatable<String> validatable) { error.addKey("prefix.LengthValidator"); return error; } }); textField.add(new PrefixValidator()); textField.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { configEntry.getDesignatorRange().setDesignator(textField.getModelObject()); } }); return textField; }
From source file:org.apache.openmeetings.web.components.admin.users.UserForm.java
License:Apache License
/** * Add the fields to the form/* w w w. j a va2 s . c om*/ */ private void addFormFields() { RequiredTextField<String> login = new RequiredTextField<String>("login"); login.add(new StringValidator(4, null)); // login.setLabel(new Model<String>("testname")); add(login); passwordField = new PasswordTextField("password"); add(passwordField); passwordField.setRequired(false); add(new DropDownChoice<Long>("salutations_id", getSalutationsIds(), new IChoiceRenderer<Long>() { private static final long serialVersionUID = 1L; public Object getDisplayValue(Long id) { return getSaluationLabelById(id); } public String getIdValue(Long id, int index) { return "" + id; } })); add(new TextField<String>("firstname")); add(new TextField<String>("lastname")); add(new DropDownChoice<OmTimeZone>("omTimeZone", Application.getBean(OmTimeZoneDao.class).getOmTimeZones(), new ChoiceRenderer<OmTimeZone>("frontEndLabel", "jname"))); add(new DropDownChoice<Long>("language_id", getFieldLanguageIds(), new IChoiceRenderer<Long>() { private static final long serialVersionUID = 1L; public Object getDisplayValue(Long id) { return getFieldLanguageLabelById(id); } public String getIdValue(Long id, int index) { return "" + id; } })); add(DateLabel.forDatePattern("starttime", "dd.MM.yyyy HH:mm:ss")); add(DateLabel.forDatePattern("updatetime", "dd.MM.yyyy HH:mm:ss")); add(new CheckBox("forceTimeZoneCheck")); RequiredTextField<String> email = new RequiredTextField<String>("adresses.email"); // email.setLabel(new Model<String>("testemail")); email.add(EmailAddressValidator.getInstance()); add(email); add(new TextField<String>("adresses.phone")); add(new CheckBox("sendSMS")); DateTextField age = new DateTextField("age"); DatePicker datePicker = new DatePicker() { private static final long serialVersionUID = 1L; @Override protected String getAdditionalJavaScript() { return "${calendar}.cfg.setProperty(\"navigator\",true,false); ${calendar}.render();"; } }; datePicker.setShowOnFieldClick(true); datePicker.setAutoHide(true); age.add(datePicker); add(age); add(new TextField<String>("adresses.street")); add(new TextField<String>("adresses.additionalname")); add(new TextField<String>("adresses.zip")); add(new TextField<String>("adresses.town")); add(new DropDownChoice<State>("adresses.states", Application.getBean(StateDao.class).getStates(), new ChoiceRenderer<State>("name", "state_id"))); final String field159 = WebSession.getString(159); final String field160 = WebSession.getString(160); add(new DropDownChoice<Integer>("status", Arrays.asList(0, 1), new IChoiceRenderer<Integer>() { private static final long serialVersionUID = 1L; public Object getDisplayValue(Integer id) { if (id.equals(0)) { return field159; } else if (id.equals(1)) { return field160; } return null; } public String getIdValue(Integer id, int index) { return "" + id; } })); final String field166 = WebSession.getString(166); final String field167 = WebSession.getString(167); final String field168 = WebSession.getString(168); final String field1311 = WebSession.getString(1311); add(new DropDownChoice<Long>("level_id", Arrays.asList(1L, 2L, 3L, 4L), new IChoiceRenderer<Long>() { private static final long serialVersionUID = 1L; public Object getDisplayValue(Long id) { if (id.equals(1L)) { return field166; } else if (id.equals(2L)) { return field167; } else if (id.equals(3L)) { return field168; } else if (id.equals(4L)) { return field1311; } return null; } public String getIdValue(Long id, int index) { return "" + id; } })); add(new TextArea<String>("adresses.comment")); List<Organisation> orgList = Application.getBean(OrganisationManager.class).getOrganisations(3L); List<Organisation_Users> orgUsers = new ArrayList<Organisation_Users>(orgList.size()); for (Organisation org : orgList) { orgUsers.add(new Organisation_Users(org)); } ListMultipleChoice<Organisation_Users> orgChoiceList = new ListMultipleChoice<Organisation_Users>( "organisation_users", orgUsers, new ChoiceRenderer<Organisation_Users>("organisation.name", "organisation.organisation_id")); add(orgChoiceList); final String field1160 = WebSession.getString(1160); // 1160 everybody final String field1168 = WebSession.getString(1168); // 1168 contact final String field1169 = WebSession.getString(1169); // 1169 nobody add(new RadioChoice<Long>("community_settings", new IModel<Long>() { private static final long serialVersionUID = 1L; public Long getObject() { if (user.getShowContactData() != null && user.getShowContactData()) { return 1L; } else if (user.getShowContactDataToContacts() != null && user.getShowContactDataToContacts()) { return 2L; } return 3L; } public void setObject(Long choice) { if (choice.equals(1L)) { user.setShowContactData(true); user.setShowContactDataToContacts(false); } else if (choice.equals(2L)) { user.setShowContactData(false); user.setShowContactDataToContacts(true); } else { user.setShowContactData(false); user.setShowContactDataToContacts(false); } } public void detach() { } }, Arrays.asList(1L, 2L, 3L), new IChoiceRenderer<Long>() { private static final long serialVersionUID = 1L; public Object getDisplayValue(Long id) { if (id.equals(1L)) { return field1160; } else if (id.equals(2L)) { return field1168; } else { return field1169; } } public String getIdValue(Long id, int index) { return "" + id; } })); add(new TextArea<String>("userOffers")); add(new TextArea<String>("userSearchs")); }
From source file:org.onexus.website.api.pages.browser.filters.panels.StringFilterPanel.java
License:Apache License
@Override protected FormComponent<String> createValueFormComponent(String componentId) { return new TextField<String>(componentId).add(new StringValidator(1, 200)); }
From source file:org.wicketstuff.validation.client.ClientAndServerExactLengthValidatingBehavior.java
License:Apache License
@Override protected void addServerSideValidator(FormComponent<String> component) { component.add(new StringValidator(mLength, mLength)); }
From source file:org.wicketstuff.validation.client.ClientAndServerLengthBetweenValidatingBehavior.java
License:Apache License
@Override protected void addServerSideValidator(FormComponent<String> component) { component.add(new StringValidator(mMin, mMax)); }
From source file:org.wicketstuff.validation.client.ClientAndServerMaximumLengthValidatingBehavior.java
License:Apache License
@Override protected void addServerSideValidator(FormComponent<String> component) { component.add(new StringValidator(null, mMax)); }
From source file:org.wicketstuff.validation.client.ClientAndServerMinimumLengthValidatingBehavior.java
License:Apache License
@Override protected void addServerSideValidator(FormComponent<String> component) { component.add(new StringValidator(mMin, null)); }
From source file:wicket.contrib.phonebook.web.page.EditContactPage.java
License:Apache License
/** * Constructor. Create or edit the contact. Note that if you don't need the page to be * bookmarkable, you can use whatever constructor you need, such as is done here. * //from w w w. j a v a2 s .c om * @param backPage * The page that the user was on before coming here * @param contactModel * Model that contains the contact we will edit */ public EditContactPage(Page backPage, IModel<?> contactModel) { this.backPage = backPage; Contact contact = (Contact) contactModel.getObject(); Form<Contact> form = new Form<Contact>("contactForm", new CompoundPropertyModel<Contact>(contact)); add(form); form.add(newRequiredTextField("firstname", 32)); form.add(newRequiredTextField("lastname", 32)); form.add(newRequiredTextField("phone", 16)); form.add(new TextField<String>("email").add(new StringValidator(null, 128)) .add(EmailAddressValidator.getInstance())); form.add(new CancelButton()); form.add(new SaveButton()); }
From source file:wicket.contrib.phonebook.web.page.EditContactPage.java
License:Apache License
private RequiredTextField<String> newRequiredTextField(String id, int maxLenght) { RequiredTextField<String> textField = new RequiredTextField<String>(id); textField.add(new StringValidator(null, maxLenght)); return textField; }
From source file:za.org.rfm.web.memberdata.page.EditMemberPage.java
License:Apache License
/** * Constructor. Create or edit the contact. Note that if you don't need the page to be * bookmarkable, you can use whatever constructor you need, such as is done here. * * @param backPage/*from w w w.j a v a2s .c o m*/ * The page that the user was on before coming here * @param contactModel * Model that contains the contact we will edit */ public EditMemberPage(Page backPage, IModel<?> contactModel) { this.backPage = backPage; Member member = (Member) contactModel.getObject(); Form<Member> form = new Form<Member>("contactForm", new CompoundPropertyModel<Member>(member)); add(form); form.add(newRequiredTextField("firstName", 32)); form.add(newRequiredTextField("lastName", 32)); form.add(newRequiredTextField("phone", 16)); form.add(new TextField<String>("email").add(new StringValidator(null, 128)) .add(EmailAddressValidator.getInstance())); form.add(new CancelButton()); form.add(new SaveButton()); }