package org.apache.wicket.examples.stateless;
import org.apache.wicket.examples.WicketExamplePage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.validation.validator.RangeValidator;
@author
public class StatelessPage extends WicketExamplePage
{
private static final long serialVersionUID = 1L;
private final Integer number = 10;
public StatelessPage()
{
setStatelessHint(true);
add(new Label("message", new SessionModel()));
add(new BookmarkablePageLink<>("indexLink", Index.class));
final TextField<Integer> field = new TextField<>("textfield",
new PropertyModel<>(this, "number"));
field.add(new RangeValidator<>(null, 20));
field.setRequired(true);
StatelessForm<?> statelessForm = new StatelessForm<Void>("statelessform")
{
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit()
{
info("Submitted text: " + field.getDefaultModelObject());
}
};
statelessForm.add(field);
add(statelessForm);
add(new FeedbackPanel("feedback"));
}
}