List of usage examples for org.apache.wicket.markup.html.form Form add
public void add(final IFormValidator validator)
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.DailyViewPage.java
License:Apache License
/** * Inits Page.// w w w. ja va 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.//w w w . j av a2 s . c o m */ @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:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.MonthlyViewPage.java
License:Apache License
/** * Initializes buttons of form.//from ww w . ja va 2 s .com * * @param form form of page. * @param container container of page. */ private void initButtons(final Form<Effort> form, final WebMarkupContainer container) { 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) { Integer year = Integer.valueOf(selectedYear.toString()); Integer month = Integer.valueOf(selectedMonth.toString()); List<Effort> tlist = getTimeEffortsMonthlyView(year, month); tableModel.reload(tlist); target.addComponent(container); target.addComponent(btnShowAsPDF); } @Override protected void onError(AjaxRequestTarget target, Form<?> form1) { // TODO Set border red on textfields which are'nt filled } @Override public boolean isEnabled() { return !years.isEmpty(); } }); }
From source file:au.org.theark.admin.web.component.activitymonitor.ActivityMonitorContainerPanel.java
License:Open Source License
/** * @param id//from w ww . j av a2s . c om */ 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:au.org.theark.report.web.component.customreport.CustomReportContainerPanel.java
License:Open Source License
public void initialisePanel() { add(initFeedBackPanel());// ww w. j a v a 2 s . com form.add(initDbNameSelect()); form.add(query); AjaxButton runQuery = new AjaxButton("runQuery") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { // TODO Auto-generated method stub } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (dbNameDdc.getRawInput() != null && query.getRawInput() != null) { datasourceTablePanel = new DataSourceTablePanel("datasourceTablePanel", "lims", query.getRawInput()); datasourceTablePanel.setVisible(true); form.addOrReplace(datasourceTablePanel); this.info("Query submitted"); target.add(feedbackPanel); target.add(datasourceTablePanel); } else { this.error("Database name and a legitimate query are required"); target.add(feedbackPanel); } } }; runQuery.setDefaultFormProcessing(false); form.add(runQuery); form.add(datasourceTablePanel); datasourceTablePanel.setVisible(false); 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);//from w w w . java 2s . c om // 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:blg.bhdrkn.wicket.twitter.TwitterPanel.java
License:Apache License
private void addFormSubmit(Form<Void> twitterForm) { twitterForm.add(new AjaxButton("button") { private static final long serialVersionUID = 1L; @Override/*from ww w. j a va2 s . c om*/ protected void onSubmit(AjaxRequestTarget target, Form<?> form) { try { accessToken = twitter.getOAuthAccessToken(requestToken, twitterPinModel); setResponsePage(new TwitterPage(accessToken)); } catch (TwitterException e) { logger.error("Error While Getting AccessToken: " + e.getMessage()); e.printStackTrace(); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { logger.error("Error"); } }); }
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 a va 2s. 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);// www . j av a2s . c om 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 va2s . c o m 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()); } }); }