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
@author
public class StatelessPage3 extends WicketExamplePage
{
private static final long serialVersionUID = 1L;
private Integer number;
private static final String PARAMETER_NAME = "value";
@Override
protected void onBeforeRender()
{
super.onBeforeRender();
number = getPage().getPageParameters().get(PARAMETER_NAME).toInt(10);
}
public StatelessPage3()
{
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());
getPage().getPageParameters().set(PARAMETER_NAME, number);
}
};
statelessForm.add(field);
add(statelessForm);
add(new FeedbackPanel("feedback"));
}
}