List of usage examples for org.apache.wicket.markup.html.form Form Form
public Form(final String id, final IModel<T> model)
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.DailyViewPage.java
License:Apache License
/** * Inits Page.//from w w w. j ava 2 s . c om */ private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); final DateTextField dateTextField = new DateTextField("tedate", new PropertyModel<Date>(this, "date"), new StyleDateConverter("S-", true)); dateTextField.add(new DatePicker()); form.add(dateTextField); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); tableModel = new TableModelTimeConsumerEvaluation(getTimeEffortsDailyView(new Date())); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); final Button btnShowAsPDF = new Button("btnShowPDF") { @Override public void onSubmit() { try { loadReport(); ResourceStreamRequestTarget rsrtarget = new ResourceStreamRequestTarget( pdfResource.getResourceStream()); rsrtarget.setFileName(pdfResource.getFilename()); RequestCycle.get().setRequestTarget(rsrtarget); } catch (JRException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } catch (PersistenceException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } } @Override public boolean isEnabled() { return tableModel.getRowCount() == 0 ? false : true; } }; form.add(btnShowAsPDF); form.add(new AjaxButton("btnShowEvaluation", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { tableModel.reload(getTimeEffortsDailyView(dateTextField.getModelObject())); target.addComponent(timeeffortContainer); target.addComponent(btnShowAsPDF); } @Override protected void onError(AjaxRequestTarget target, Form<?> form1) { // TODO Set border red on textfields which are'nt filled } }); }
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.MonthlyViewPage.java
License:Apache License
/** * Inits Page.//from w ww. j a va2 s . c om */ @SuppressWarnings("unchecked") private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key"); final DropDownChoice ddYears = new DropDownChoice("yearSelection", new PropertyModel(this, "selectedYear"), getYears(), choiceRenderer); form.add(ddYears); final DropDownChoice ddMonths = new DropDownChoice("monthSelection", new PropertyModel(this, "selectedMonth"), getMonths(), choiceRenderer); form.add(ddMonths); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); initButtons(form, timeeffortContainer); Calendar cal = Calendar.getInstance(); tableModel = new TableModelTimeConsumerEvaluation( getTimeEffortsMonthlyView(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH))); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); }
From source file:au.org.theark.admin.web.component.activitymonitor.ActivityMonitorContainerPanel.java
License:Open Source License
/** * @param id/*w w w.j av a2 s . co m*/ */ public ActivityMonitorContainerPanel(String id) { super(id); form = new Form<ActivityMonitorVO>("form", new CompoundPropertyModel<ActivityMonitorVO>(new ActivityMonitorVO())); form.add(initialiseFeedBackPanel()); form.add(initialiseSearchResults()); refresh = new AjaxButton("refresh") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("Error on refresh click"); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(searchResultsPanel); } }; refresh.setDefaultFormProcessing(false); form.add(refresh); add(form); }
From source file:biz.turnonline.ecosystem.origin.frontend.myaccount.page.MyAccountBasics.java
License:Apache License
public MyAccountBasics() { add(new FirebaseAppInit(firebaseConfig)); final MyAccountModel accountModel = new MyAccountModel(); final IModel<Map<String, Country>> countriesModel = new CountriesModel(); setModel(accountModel);/* w w w . j av a 2 s . c o m*/ // form Form<Account> form = new Form<Account>("form", accountModel) { private static final long serialVersionUID = -938924956863034465L; @Override protected void onSubmit() { Account account = getModelObject(); send(getPage(), Broadcast.BREADTH, new AccountUpdateEvent(account)); } }; add(form); PropertyModel<Boolean> companyModel = new PropertyModel<>(accountModel, "company"); form.add(new CompanyPersonSwitcher("isCompanyRadioGroup", companyModel)); // account email fieldset form.add(new Label("email", new PropertyModel<>(accountModel, "email"))); // company basic info final CompanyBasicInfo<Account> basicInfo = new CompanyBasicInfo<Account>("companyData", accountModel) { private static final long serialVersionUID = -2992960490517951459L; @Override protected DropDownChoice<LegalForm> provideLegalForm(String componentId) { LegalFormListModel choices = new LegalFormListModel(); return new IndicatingAjaxDropDown<>(componentId, new LegalFormCodeModel(accountModel, "legalForm", choices), choices, new LegalFormRenderer()); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(basicInfo); // company basic info panel behaviors basicInfo.addLegalForm(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 6948210639258798921L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); basicInfo.addVatId(new Behavior() { private static final long serialVersionUID = 100053137512632023L; @Override public void onConfigure(Component component) { super.onConfigure(component); Account account = basicInfo.getModelObject(); boolean visible; if (account == null || account.getBusiness() == null) { visible = true; } else { Boolean vatPayer = account.getBusiness().getVatPayer(); visible = vatPayer == null ? Boolean.FALSE : vatPayer; } component.setVisible(visible); } }); final TextField taxId = basicInfo.getTaxId(); final TextField vatId = basicInfo.getVatId(); final CheckBox vatPayer = basicInfo.getVatPayer(); basicInfo.addVatPayer(new AjaxFormSubmitBehavior(OnChangeAjaxBehavior.EVENT_NAME) { private static final long serialVersionUID = -1238082494184937003L; @Override protected void onSubmit(AjaxRequestTarget target) { Account account = (Account) basicInfo.getDefaultModelObject(); String rawTaxIdValue = taxId.getRawInput(); AccountBusiness business = account.getBusiness(); if (rawTaxIdValue != null && Strings.isEmpty(business == null ? null : business.getVatId())) { // VAT country prefix proposal String country = business == null ? "" : business.getDomicile(); country = country.toUpperCase(); //noinspection unchecked vatId.getModel().setObject(country + rawTaxIdValue); } // must be set manually as getDefaultProcessing() returns false vatPayer.setModelObject(!(business == null ? Boolean.FALSE : business.getVatPayer())); if (target != null) { target.add(vatId.getParent()); } } @Override public boolean getDefaultProcessing() { return false; } }); // personal data panel PersonalDataPanel<Account> personalData = new PersonalDataPanel<Account>("personalData", accountModel) { private static final long serialVersionUID = -2808922906891760016L; @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(personalData); // personal address panel PersonalAddressPanel<Account> address = new PersonalAddressPanel<Account>("personalAddress", accountModel) { private static final long serialVersionUID = 3481146248010938807L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PersonalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(address); address.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -1016447969591778948L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); // company address panel CompanyAddressPanel<Account> companyAddress; companyAddress = new CompanyAddressPanel<Account>("companyAddress", accountModel, false, false) { private static final long serialVersionUID = -6760545061622186549L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new CompanyDomicileModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(companyAddress); companyAddress.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5476413125490349124L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); IModel<AccountPostalAddress> postalAddressModel = new PropertyModel<>(accountModel, "postalAddress"); IModel<Boolean> hasAddress = new PropertyModel<>(accountModel, "hasPostalAddress"); PostalAddressPanel<AccountPostalAddress> postalAddress; postalAddress = new PostalAddressPanel<AccountPostalAddress>("postal-address", postalAddressModel, hasAddress) { private static final long serialVersionUID = -930960688138308527L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PostalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } }; form.add(postalAddress); postalAddress.addStreet(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 4050800366443676166L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); PropertyModel<Object> billingContactModel = PropertyModel.of(accountModel, "billingContact"); form.add(new SimplifiedContactFieldSet<>("contact", billingContactModel)); // save button form.add(new IndicatingAjaxButton("save", new I18NResourceModel("button.save"), form)); }
From source file:br.eti.ranieri.opcoesweb.page.ConfigurarOnlinePage.java
License:Apache License
public ConfigurarOnlinePage() { add(new FeedbackPanel("feedback")); ConfiguracaoOnline configuracao = OpcoesWebHttpSession.get().getConfiguracaoOnline(); Form<ConfiguracaoOnline> formulario = new Form<ConfiguracaoOnline>("formulario", new CompoundPropertyModel<ConfiguracaoOnline>(configuracao)) { @Override/*from w w w . j av a2 s .c o m*/ protected void onSubmit() { setResponsePage(ExibirOnlinePage.class); } }; add(formulario); formulario.add(new RequiredTextField<String>("jsessionid")); formulario.add(new Button("submeter")); }
From source file:by.grodno.ss.rentacar.webapp.page.admin.panel.UserEditPanel.java
@Override public void onInitialize() { super.onInitialize(); UserEditPanel.this.setOutputMarkupId(true); Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile)); TextField<String> created = new TextField<String>("created"); created.setEnabled(false);/* w w w.ja v a 2 s .c o m*/ form.add(created); TextField<String> email = new TextField<String>("email", new PropertyModel<>(userCredentials, "email")); email.setRequired(true); email.add(StringValidator.maximumLength(100)); email.add(StringValidator.minimumLength(3)); email.add(EmailAddressValidator.getInstance()); form.add(email); DropDownChoice<UserRole> roleDropDown = new DropDownChoice<>("role", new PropertyModel<>(userCredentials, "role"), Arrays.asList(UserRole.values()), UserRoleChoiceRenderer.INSTANCE); roleDropDown.setRequired(true); form.add(roleDropDown); TextField<String> firstName = new TextField<String>("firstName"); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName"); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); lastName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phoneNumber"); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); TextField<String> licNumber = new TextField<String>("licenseNumber"); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("birthDay", config); form.add(dateBirth); TextField<String> address = new TextField<String>("address"); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city"); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region"); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zipCode"); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); WebMarkupContainer passTable = new WebMarkupContainer("pass-table"); passTable.setOutputMarkupId(true); WebMarkupContainer trPass = new WebMarkupContainer("pass"); WebMarkupContainer trCpass = new WebMarkupContainer("cpass"); if (userProfile.getId() == null) { trPass.setVisible(true); trCpass.setVisible(true); } else { trPass.setVisible(false); trCpass.setVisible(false); } trPass.setOutputMarkupId(true); trCpass.setOutputMarkupId(true); PasswordTextField password = new PasswordTextField("password", new PropertyModel<>(userCredentials, "password")); trPass.add(password); PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of("")); trCpass.add(cpassword); passTable.add(trPass); passTable.add(trCpass); form.add(passTable); form.add(new EqualPasswordInputValidator(password, cpassword)); AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (!trPass.isVisible()) { trPass.setVisible(true); trCpass.setVisible(true); passTable.add(trPass); passTable.add(trCpass); } else { trPass.setVisible(false); trCpass.setVisible(false); } if (target != null) { target.add(passTable); } } }; if (userProfile.getId() == null) { changePass.setVisible(false); } form.add(changePass); form.add(new SubmitLink("save") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (userProfile.getId() == null) { userService.register(userProfile, userCredentials); } else { userService.update(userProfile); userService.update(userCredentials); } info("User was saved"); } }); boolean a = (AuthorizedSession.get().isSignedIn() && AuthorizedSession.get().getLoggedUser().getRole().equals(UserRole.ADMIN)); form.setEnabled(a); add(form); add(new AjaxLink<Void>("back") { private static final long serialVersionUID = 1L; public void onClick(AjaxRequestTarget target) { Component newPanel = new UserListPanel(UserEditPanel.this.getId(), filter); UserEditPanel.this.replaceWith(newPanel); if (target != null) { target.add(newPanel); } } }); }
From source file:by.grodno.ss.rentacar.webapp.page.MyBooking.ProfileEditPanel.java
@Override public void onInitialize() { super.onInitialize(); final NotificationPanel feedback = new NotificationPanel("feedbackpanel"); add(feedback);//ww w . j a v a2s . com Form<UserProfile> form = new Form<UserProfile>("form", new CompoundPropertyModel<UserProfile>(userProfile)); TextField<String> firstName = new TextField<String>("firstName"); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName"); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); lastName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phoneNumber"); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); TextField<String> licNumber = new TextField<String>("licenseNumber"); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("birthDay", config); form.add(dateBirth); TextField<String> address = new TextField<String>("address"); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city"); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region"); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zipCode"); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); Label email = new Label("email", new PropertyModel<>(userCredentials, "email")); form.add(email); WebMarkupContainer passTable = new WebMarkupContainer("pass-table"); passTable.setOutputMarkupId(true); WebMarkupContainer trPass = new WebMarkupContainer("pass"); WebMarkupContainer trCpass = new WebMarkupContainer("cpass"); if (userProfile.getId() == null) { trPass.setVisible(true); trCpass.setVisible(true); } else { trPass.setVisible(false); trCpass.setVisible(false); } trPass.setOutputMarkupId(true); trCpass.setOutputMarkupId(true); PasswordTextField password = new PasswordTextField("password", new PropertyModel<>(userCredentials, "password")); trPass.add(password); PasswordTextField cpassword = new PasswordTextField("cpassword", Model.of("")); trCpass.add(cpassword); passTable.add(trPass); passTable.add(trCpass); form.add(passTable); form.add(new EqualPasswordInputValidator(password, cpassword)); AjaxLink<Void> changePass = new AjaxLink<Void>("change-password") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { if (!trPass.isVisible()) { trPass.setVisible(true); trCpass.setVisible(true); passTable.add(trPass); passTable.add(trCpass); } else { trPass.setVisible(false); trCpass.setVisible(false); } if (target != null) { target.add(passTable); } } }; if (userProfile.getId() == null) { changePass.setVisible(false); } form.add(changePass); form.add(new SubmitLink("save") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (userProfile.getId() == null) { error("saving error"); } else { userService.update(userProfile); userService.update(userCredentials); } info("User was saved"); } }); add(form); add(new Link<Void>("back") { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new MyBookingPage()); } }); }
From source file:by.grodno.ss.rentacar.webapp.page.order.CheckoutPage.java
@Override protected void onInitialize() { super.onInitialize(); final NotificationPanel feedback = new NotificationPanel("feedbackpanel"); SimpleDateFormat dt = new SimpleDateFormat("dd.MM.yyy HH:mm"); add(new Label("duration", bookingService.convertDurationToString(filter.getDateFrom(), filter.getDateTo()))); add(new Label("dateFrom", dt.format(filter.getDateFrom()))); add(new Label("locationFrom", filter.getLocationFrom().getName())); add(new Label("dateTo", dt.format(filter.getDateTo()))); add(new Label("locationTo", filter.getLocationTo().getName())); add(new Link<Void>("link-change") { private static final long serialVersionUID = 1L; @Override//from w w w . j a va 2 s . co m public void onClick() { setResponsePage(new ReservationPage(filter)); } }); add(new Link<Void>("link-change-car") { private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new ChooseCarPage(filter)); } }); addImage(car); add(new Label("name", car.getName())); add(new Label("type", car.getType().getName())); add(new Label("pass", car.getType().getNumPassengers())); add(new Label("bags", car.getType().getNumBags())); add(new Label("doors", car.getType().getNumDoors())); add(new Label("trans", car.getType().getTransmissionType())); add(new Label("rental-duration", bookingService.convertDurationToString(filter.getDateFrom(), filter.getDateTo()))); BigDecimal pricePerHour = car.getType().getPricePerHour(); totalPrice = bookingService.getTotalPrice(filter.getDateFrom(), filter.getDateTo(), pricePerHour); BigDecimal pricePerDay = bookingService.getPricePerDay(pricePerHour); int percent = settingService.get().getDepositPayment(); BigDecimal requiredDeposit = bookingService.getRequiredDeposit(totalPrice, percent); add(new Label("pricePerHour", pricePerHour.toString())); add(new Label("total", totalPrice.toString())); add(new Label("pricePerDay", pricePerDay.toString())); add(new Label("requiredDeposit", requiredDeposit.toString())); add(new Label("total1", totalPrice.toString())); add(new Label("percent", percent)); add(getPriceIcon("iconPrice1")); add(getPriceIcon("iconPrice2")); add(getPriceIcon("iconPrice3")); add(getPriceIcon("iconPrice4")); add(getPriceIcon("iconPrice5")); // -----checkout form------------ Form<UserProfile> form = new Form<UserProfile>("form-checkout", new CompoundPropertyModel<UserProfile>(userProfile)); // form.add(new FeedbackPanel("feedbackpanel")); TextField<String> firstName = new TextField<String>("firstName", new PropertyModel<>(userProfile, "firstName")); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName", new PropertyModel<>(userProfile, "lastName")); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phone", new PropertyModel<>(userProfile, "phoneNumber")); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("date-birth", new PropertyModel<>(userProfile, "birthDay"), config); form.add(dateBirth); TextField<String> licNumber = new TextField<String>("lic-number", new PropertyModel<>(userProfile, "licenseNumber")); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); TextField<String> note = new TextField<String>("note", new PropertyModel<>(booking, "note")); note.add(StringValidator.maximumLength(500)); form.add(note); TextField<String> address = new TextField<String>("address", new PropertyModel<>(userProfile, "address")); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city", new PropertyModel<>(userProfile, "city")); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region", new PropertyModel<>(userProfile, "region")); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zip-code", new PropertyModel<>(userProfile, "zipCode")); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); BootstrapCheckBoxPicker chk0 = new BootstrapCheckBoxPicker("check-confirm", Model.of(Boolean.FALSE)); form.add(chk0); form.add(new SubmitLink("button-confirm") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (chk0.getModelObject().equals(false)) { info("You must to agree rental terms"); } else { if (userProfile.getId() == null) { userCredential.setEmail("unregistered user"); userCredential.setPassword("pswd"); userCredential.setRole(UserRole.UNREGISTERED); userService.register(userProfile, userCredential); } else { userService.update(userProfile); } booking.setSumm(totalPrice); booking.setClient(userProfile); booking.setOrderStatus(OrderStatus.pending); bookingService.saveOrUpdate(booking); setResponsePage(new ConfirmPage()); } } }); form.add(feedback); add(form); }
From source file:by.grodno.ss.rentacar.webapp.page.register.RegisterPanel.java
@Override protected void onInitialize() { super.onInitialize(); Form<UserCredentials> form = new Form<UserCredentials>("form-register", new CompoundPropertyModel<UserCredentials>(userCredentials)); form.add(new FeedbackPanel("feedbackpanel")); TextField<String> email = new TextField<String>("email"); email.setRequired(true);// w w w. ja va 2 s . co m email.add(StringValidator.maximumLength(100)); email.add(StringValidator.minimumLength(3)); email.add(EmailAddressValidator.getInstance()); form.add(email); PasswordTextField password = new PasswordTextField("password"); password.setRequired(true); password.add(StringValidator.maximumLength(100)); password.add(StringValidator.minimumLength(6)); password.add(new PatternValidator("[A-Za-z0-9_-]+")); form.add(password); TextField<String> firstName = new TextField<String>("firstName", new PropertyModel<>(userProfile, "firstName")); firstName.setRequired(true); firstName.add(StringValidator.maximumLength(100)); firstName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(firstName); TextField<String> lastName = new TextField<String>("lastName", new PropertyModel<>(userProfile, "lastName")); lastName.setRequired(true); lastName.add(StringValidator.maximumLength(100)); lastName.add(StringValidator.minimumLength(2)); firstName.add(new PatternValidator("[A-Za-z]+")); form.add(lastName); TextField<String> phone = new TextField<String>("phone", new PropertyModel<>(userProfile, "phoneNumber")); phone.setRequired(true); phone.add(StringValidator.maximumLength(100)); phone.add(StringValidator.minimumLength(2)); phone.add(new PatternValidator("[0-9+()-]+")); form.add(phone); DateTextFieldConfig config = new DateTextFieldConfig(); config.withLanguage(AuthorizedSession.get().getLocale().getLanguage()); config.withFormat("dd.MM.yyyy"); DateTextField dateBirth = new DateTextField("date-birth", new PropertyModel<>(userProfile, "birthDay"), config); form.add(dateBirth); TextField<String> licNumber = new TextField<String>("lic-number", new PropertyModel<>(userProfile, "licenseNumber")); licNumber.add(StringValidator.maximumLength(100)); licNumber.add(StringValidator.minimumLength(2)); licNumber.add(new PatternValidator("[A-Za-z0-9]+")); form.add(licNumber); TextField<String> address = new TextField<String>("address", new PropertyModel<>(userProfile, "address")); address.add(StringValidator.maximumLength(100)); address.add(StringValidator.minimumLength(2)); address.add(new PatternValidator("[A-Za-z0-9 /-]+")); form.add(address); TextField<String> city = new TextField<String>("city", new PropertyModel<>(userProfile, "city")); city.add(StringValidator.maximumLength(100)); city.add(StringValidator.minimumLength(2)); city.add(new PatternValidator("[A-Za-z0-9]+")); form.add(city); TextField<String> region = new TextField<String>("region", new PropertyModel<>(userProfile, "region")); region.add(StringValidator.maximumLength(100)); region.add(StringValidator.minimumLength(2)); region.add(new PatternValidator("[A-Za-z0-9]+")); form.add(region); TextField<String> zip = new TextField<String>("zip-code", new PropertyModel<>(userProfile, "zipCode")); zip.add(StringValidator.maximumLength(20)); zip.add(StringValidator.minimumLength(2)); zip.add(new PatternValidator("[0-9]+")); form.add(zip); BootstrapCheckBoxPicker chk0 = new BootstrapCheckBoxPicker("check-confirm", Model.of(Boolean.FALSE)); form.add(chk0); form.add(new SubmitLink("button-register") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { if (chk0.getModelObject().equals(false)) { info("You must to agree rental terms"); } else { userCredentials.setRole(UserRole.CLIENT); if (userProfile.getId() == null) { userService.register(userProfile, userCredentials); } else { userService.update(userProfile); userService.update(userCredentials); } setResponsePage(new LoginPage()); } } }); add(form); }
From source file:ca.travelagency.components.validators.DuplicateValidatorTest.java
License:Apache License
@Before public void setUp() { systemUser = SystemUserHelper.makeSystemUser(); form = new Form<SystemUser>("form", new Model<SystemUser>(systemUser)); fixture = new DuplicateValidator<SystemUser>(form); }