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 StatelessPage2 extends WicketExamplePage
{
private static final long serialVersionUID = 1L;
private final Integer number = 10;
public StatelessPage2()
{
setStatelessHint(true);
add(new Label("message", new SessionModel()));
add(new BookmarkablePageLink<>("indexLink", Index.class));
final TextField<Integer> field = new TextField<>("textfield",
new PropertyModel<Integer>(this, "number"));
field.add(new RangeValidator<>(0, 20));
field.setRequired(true);
StatelessForm<?> statelessForm = new StatelessForm<Void>("statelessform")
{
@Override
protected void onSubmit()
{
info("Submitted text: " + field.getDefaultModelObject());
}
};
statelessForm.add(field);
add(statelessForm);
add(new FeedbackPanel("feedback"));
}
}