package org.apache.wicket.examples.compref;
import org.apache.wicket.examples.WicketExamplePage;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.SubmitLink;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
@link
@author
public class SubmitLinkPage extends WicketExamplePage
{
public SubmitLinkPage()
{
FeedbackPanel feedbackPanel = new FeedbackPanel("feedback");
add(feedbackPanel);
Form<?> form = new Form("form");
add(form);
SubmitLink internal = new SubmitLink("internal")
{
@Override
public void onSubmit()
{
info("internal onsubmit");
}
};
form.add(internal);
SubmitLink external = new SubmitLink("external", form)
{
@Override
public void onSubmit()
{
info("external onsubmit");
}
};
add(external);
}
@Override
protected void explain()
{
String html = "<form wicket:id=\"form\">\n"
+ "<a wicket:id=\"internal\">Internal SubmitLink</a>\n" + "</form>\n"
+ "<a wicket:id=\"external\">External SubmitLink</a>\n";
String code = " public SubmitLinkPage() {\n"
+ " // Add a FeedbackPanel for displaying our messages\n"
+ " FeedbackPanel feedbackPanel = new FeedbackPanel(\"feedback\");\n"
+ " add(feedbackPanel);\n"
+ "\n"
+ " // Add a form with 2 SubmitLinks that can be called\n"
+ " Form form = new Form(\"form\");\n"
+ " add(form);\n"
+ " SubmitLink internal = new SubmitLink(\"internal\");\n"
+ " form.add(internal);\n"
+ " SubmitLink external = new SubmitLink(\"external\", form);\n"
+ " add(external);\n"
+ " });\n" + " }";
add(new ExplainPanel(html, code));
}
}