package org.apache.wicket.examples.compref;
import org.apache.wicket.examples.WicketExamplePage;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
@link
@author
public class ButtonPage extends WicketExamplePage
{
public ButtonPage()
{
FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
add(feedbackPanel);
Form<Void> form = new Form<Void>("form")
{
@Override
protected void onSubmit()
{
info("Form.onSubmit executed");
}
};
Button button1 = new Button("button1")
{
@Override
public void onSubmit()
{
info("button1.onSubmit executed");
}
};
form.add(button1);
Button button2 = new Button("button2")
{
@Override
public void onSubmit()
{
info("button2.onSubmit executed");
}
};
button2.setDefaultFormProcessing(false);
form.add(button2);
add(form);
}
@Override
protected void explain()
{
String html = " <form wicket:id=\"form\">\n"
+ " <input type=\"submit\" value=\"non wicket submit button\" />\n"
+ " <input wicket:id=\"button1\" type=\"submit\" value=\"default wicket button\" />\n"
+ " <input wicket:id=\"button2\" type=\"submit\" value=\"wicket button with setDefaultFormProcessing(false)\" />\n"
+ " </form>";
String code = " // Add a form with an onSubmit implementation that sets a message\n"
+ " Form form = new Form(\"form\") {\n"
+ " protected void onSubmit() {\n"
+ " info(\"Form.onSubmit executed\");\n"
+ " }\n"
+ " };\n"
+ "\n"
+ " Button button1 = new Button(\"button1\") {\n"
+ " protected void onSubmit() {\n"
+ " info(\"button1.onSubmit executed\");\n"
+ " }\n"
+ " };\n"
+ " form.add(button1);\n"
+ "\n"
+ " Button button2 = new Button(\"button2\") {\n"
+ " protected void onSubmit() {\n"
+ " info(\"button2.onSubmit executed\");\n"
+ " }\n"
+ " };\n"
+ " button2.setDefaultFormProcessing(false);\n"
+ " form.add(button2);\n"
+ "\n"
+ " add(form);";
add(new ExplainPanel(html, code));
}
}