List of usage examples for org.apache.wicket.markup.html.form StatelessForm StatelessForm
public StatelessForm(String id, IModel<T> model)
From source file:com.github.mvollebregt.calendar.pages.CalendarItemFormPage.java
License:Open Source License
public CalendarItemFormPage(final CalendarItem calendarItem) { Form calendarItemForm = new StatelessForm("calenderItemForm", new CompoundPropertyModel<CalendarItem>(calendarItem)) { /** default form submit */ @Override//from w ww .j av a 2 s . c o m protected void onSubmit() { Calendar.getInstance().getItems().add(calendarItem); setResponsePage(SummaryPage.class); } }; add(calendarItemForm); calendarItemForm.add(new FeedbackPanel("feedback")); calendarItemForm.add(new RequiredTextField<String>("name")); calendarItemForm.add(new DateTimeField("start")); calendarItemForm.add(new DateTimeField("end")); calendarItemForm.add(new Button("saveButton")); Button cancelButton = new Button("cancelButton") { /** cancel button submit */ @Override public void onSubmit() { setResponsePage(SummaryPage.class); } }; cancelButton.setDefaultFormProcessing(false); calendarItemForm.add(cancelButton); }
From source file:name.martingeisse.wicket.simpleform.SimpleFormPanel.java
License:Open Source License
/** * Builds the form for this panel./*w ww . ja v a 2s. c o m*/ * * @param id the wicket:id of the form to build * @param model the model for the form * @param onSubmitCallback a callback that should be invoked when the form gets submitted * @return the form */ protected Form<F> newForm(final String id, final IModel<F> model, final Runnable onSubmitCallback) { if (isBuildStateless()) { return new StatelessForm<F>(id, model) { @Override protected void onValidate() { super.onValidate(); AjaxRequestUtil.markForRender(SimpleFormPanel.this); } @Override protected void onSubmit() { super.onSubmit(); onSubmitCallback.run(); } }; } else { return new Form<F>(id, model) { @Override protected void onValidate() { super.onValidate(); AjaxRequestUtil.markForRender(SimpleFormPanel.this); } @Override protected void onSubmit() { super.onSubmit(); onSubmitCallback.run(); } }; } }
From source file:org.lbogdanov.poker.web.page.IndexPage.java
License:Apache License
/** * Creates a new instance of <code>Index</code> page. *///from w ww . j av a2s . c o m @SuppressWarnings("unchecked") public IndexPage() { WebMarkupContainer session = new WebMarkupContainer("session"); WebMarkupContainer login = new WebMarkupContainer("login") { @Override protected void onConfigure() { super.onConfigure(); setVisible(userService.getCurrentUser() == null); } }; Form<?> internal = new StatelessForm<Credentials>("internal", new CompoundPropertyModel<Credentials>(new Credentials())); MarkupContainer usernameGroup = new ControlGroup("usernameGroup"); MarkupContainer passwordGroup = new ControlGroup("passwordGroup"); MarkupContainer rememberGroup = new ControlGroup("rememberGroup"); internal.add(new BootstrapFeedbackPanel("feedback"), usernameGroup.add(new RequiredTextField<String>("username") .setLabel(new ResourceModel("login.internal.username"))), passwordGroup.add( new PasswordTextField("password").setLabel(new ResourceModel("login.internal.password"))), rememberGroup.add(new CheckBox("rememberme"), new AjaxFallbackButton("submit", internal) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Credentials credentials = (Credentials) form.getModelObject(); // TODO Atmosphere issue // getSession().replaceSession(); try { userService.login(credentials.username, credentials.password, credentials.rememberme); if (target != null) { target.appendJavaScript("$('#crsl').carousel({interval: false}).carousel('next');"); target.add(getNavBar()); } } catch (RuntimeException re) { LOGGER.info("Authentication error", re); form.error(IndexPage.this.getString("login.internal.authError")); if (target != null) { target.add(form); } } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { if (target != null) { target.add(form); } } })); IModel<Game> gameModel = new CompoundPropertyModel<Game>(new Game()); IValidator<String> codeValidator = new IValidator<String>() { @Override public void validate(IValidatable<String> validatable) { String code = validatable.getValue(); if (!sessionService.exists(code)) { ValidationError error = new ValidationError(); error.addKey("session.join.invalidCode").setVariable("code", code); validatable.error(error); } } }; Form<?> join = new Form<Game>("join", gameModel); MarkupContainer codeGroup = new ControlGroup("codeGroup").add(new AjaxFallbackButton("submit", join) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Game game = (Game) form.getModelObject(); setResponsePage(SessionPage.class, new PageParameters().add("code", game.code)); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { if (target != null) { target.add(form); } } }); join.add(new BootstrapFeedbackPanel("feedback"), codeGroup.add(new RequiredTextField<String>("code").setLabel(new ResourceModel("session.join.code")) .add(maximumLength(SESSION_CODE_MAX_LENGTH), codeValidator))); IValidator<String> estimatesValidator = new IValidator<String>() { @Override public void validate(IValidatable<String> validatable) { try { Duration.parse(validatable.getValue()); } catch (IllegalArgumentException e) { ValidationError error = new ValidationError(); error.addKey("session.create.estimates.invalidEstimate").setVariable("estimate", e.getMessage()); validatable.error(error); } } }; Form<?> create = new Form<Game>("create", gameModel); MarkupContainer nameGroup = new ControlGroup("nameGroup"); MarkupContainer estimatesGroup = new ControlGroup("estimatesGroup"); MarkupContainer descriptionGroup = new ControlGroup("descriptionGroup"); create.add(new BootstrapFeedbackPanel("feedback"), nameGroup.add(new RequiredTextField<String>("name") .setLabel(new ResourceModel("session.create.name")).add(maximumLength(SESSION_NAME_MAX_LENGTH))), estimatesGroup.add(new RequiredTextField<String>("estimates") .setLabel(new ResourceModel("session.create.estimates")) .add(maximumLength(SESSION_ESTIMATES_MAX_LENGTH), estimatesValidator)), descriptionGroup.add(new TextArea<String>("description") .setLabel(new ResourceModel("session.create.description")) .add(maximumLength(SESSION_DESCRIPTION_MAX_LENGTH))), new AjaxFallbackButton("submit", create) { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { Game game = (Game) form.getModelObject(); String code = sessionService.create(game.name, game.description, game.estimates).getCode(); setResponsePage(SessionPage.class, new PageParameters().add("code", code)); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { if (target != null) { target.add(form); } } }); login.add(internal.setOutputMarkupId(true)); session.add(join.setOutputMarkupId(true), create.setOutputMarkupId(true)); session.add(append("class", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return userService.getCurrentUser() != null ? "active" : null; } })); add(login, session); }
From source file:org.wicket_sapporo.guiceApp.page.GuiceSignInPage.java
License:Apache License
/** * Construct./*from w ww . j a v a 2 s .co m*/ */ public GuiceSignInPage() { userId = ""; passphrase = ""; // ???????? CompoundPropertyModel ?. IModel<GuiceSignInPage> formModel = new CompoundPropertyModel<>(this); // ???????????? Stateless ??. StatelessForm<GuiceSignInPage> form = new StatelessForm<GuiceSignInPage>("form", formModel) { private static final long serialVersionUID = -4915291457682594278L; @Override protected void onSubmit() { super.onSubmit(); if (guiceAuthService.certify(userId, passphrase)) { GuiceAppSession.get().signIn(userId, passphrase); setResponsePage(GuiceSignedPage.class); } // ?? FeedBackPanel ????. error("."); } }; add(form); form.add(new FeedbackPanel("feedback")); form.add(new RequiredTextField<String>("userId") { private static final long serialVersionUID = 1651429085939866494L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("ID")); } }); form.add(new PasswordTextField("passphrase") { private static final long serialVersionUID = 5908552907006076177L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("")); } }); }
From source file:org.wicket_sapporo.springApp.page.SpringSignInPage.java
License:Apache License
/** * Construct./*w ww . j av a 2 s . com*/ */ public SpringSignInPage() { userId = ""; passphrase = ""; // ???????? CompoundPropertyModel ?. IModel<SpringSignInPage> formModel = new CompoundPropertyModel<>(this); // ???????????? Stateless ??. StatelessForm<SpringSignInPage> form = new StatelessForm<SpringSignInPage>("form", formModel) { private static final long serialVersionUID = -4915291457682594278L; @Override protected void onSubmit() { super.onSubmit(); if (springAuthService.certify(userId, passphrase)) { SpringAppSession.get().signIn(userId, passphrase); setResponsePage(SpringSignedPage.class); } // ?? FeedBackPanel ????. error("."); } }; add(form); form.add(new FeedbackPanel("feedback")); form.add(new RequiredTextField<String>("userId") { private static final long serialVersionUID = 1651429085939866494L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("ID")); } }); form.add(new PasswordTextField("passphrase") { private static final long serialVersionUID = 5908552907006076177L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("")); } }); }
From source file:org.wicket_sapporo.workshop01.page.session.SimpleSignInPage.java
License:Apache License
/** * Construct./* www . jav a 2 s. c o m*/ * ????????? * ??????? * ????????Mock??????????. * ?????????????. * DI??????????. * * @param the * {@link IAuthService}. */ public SimpleSignInPage(IAuthService service) { authService = service; userId = ""; passphrase = ""; // ???????? CompoundPropertyModel ?. IModel<SimpleSignInPage> formModel = new CompoundPropertyModel<>(this); // ???????????? Stateless ??. StatelessForm<SimpleSignInPage> form = new StatelessForm<SimpleSignInPage>("form", formModel) { private static final long serialVersionUID = -4915291457682594278L; @Override protected void onSubmit() { super.onSubmit(); if (authService.certify(userId, passphrase)) { WS01Session.get().signIn(userId, passphrase); setResponsePage(SignedPage.class); } // ?? FeedBackPanel ????. error("."); } }; add(form); form.add(new FeedbackPanel("feedback")); form.add(new RequiredTextField<String>("userId") { private static final long serialVersionUID = 1651429085939866494L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("ID")); } }); form.add(new PasswordTextField("passphrase") { private static final long serialVersionUID = 5908552907006076177L; @Override protected void onInitialize() { super.onInitialize(); // ????? setLabel(Model.of("")); } }); }
From source file:org.xaloon.wicket.plugin.user.panel.RegistrationPanel.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override//from www . ja va 2s . c o m protected void onInitialize(SystemPlugin plugin, SystemPluginBean pluginBean) { IModel<T> model = new CompoundPropertyModel(getDefaultModel()); Form<T> registrationForm = new StatelessForm<T>("register-form", model) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { onFormSubmit(getModelObject()); } }; add(registrationForm); /** add form feedback panel */ add(new ComponentFeedbackPanel("feedback-panel", registrationForm)); PasswordTextField passwordField = createPasswordField(registrationForm); createUsernameField(registrationForm); createEmailField(registrationForm); createRepeatPasswordField(registrationForm, passwordField); createAgreementPanel(registrationForm); createCaptchaPanel(registrationForm); registrationForm.add(createAgreementMessageLabel()); registrationForm.add(new EmailPluginEnabledValidator()); onFormInitialize(registrationForm); }
From source file:org.xaloon.wicket.plugin.user.panel.UserProfilePanel.java
License:Apache License
@SuppressWarnings("unchecked") @Override/* w ww . j a v a 2 s . c o m*/ protected void onInitialize() { super.onInitialize(); T user = null; PageParameters params = (PageParameters) getDefaultModelObject(); String username = params.get(UsersPage.PARAM_USER_ID).toString(); if (!StringUtils.isEmpty(username) && securityFacade.isAdministrator()) { user = (T) userFacade.getUserByUsername(username); } else { user = (T) securityFacade.getCurrentUser(); } Form<T> profileForm = new StatelessForm<T>("user-form", new CompoundPropertyModel<T>(user)) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { onFormSubmit(getModelObject()); } }; profileForm.setMultiPart(true); add(profileForm); /** add form feedback panel */ add(new ComponentFeedbackPanel("feedback-panel", profileForm)); createUsernameField(profileForm, user); createEmailField(profileForm, user); profileForm.add(createFirstNameField()); profileForm.add(createLastNameField()); profileForm.add(createSignatureField()); profileForm.add(createTimezoneField()); createAgreementPanel(profileForm, user); profileForm.add(createAgreementMessagePanel()); profileForm.add(createExternalAuthenticationPanel(profileForm.getModel())); createUserProfileImagePanel(profileForm, user); onFormInitialize(profileForm); }