public MyPage extends Page { public void onInit() { Form form = new Form("form"); SubmitLink link = new SubmitLink("link", "Delete"); form.add(link); // Get the submit script for the given form name String submitScript = submitLink.getSubmitScript(form.getName()); // Add a confirmation popup message scriptLink.setOnClick("var confirm = window.confirm('Are you sure?'); if (confirm) " + submitScript + " else return false;"); } }
You can use this class 2 ways. First with the constructor without a Form object then this Link must be inside a Form so that it knows what form to submit to. Second way is to use the Form constructor then that form will be used to submit to.
Form f = new Form("linkForm", new CompoundPropertyModel(mod)); f.add(new TextField("value1")); f.add(new SubmitLink("link1") { protected void onSubmit() { System.out.println("Link1 was clicked, value1 is: " + mod.getValue1()); }; }); add(new SubmitLink("link2",f) { protected void onSubmit() { System.out.println("Link2 was clicked, value1 is: " + mod.getValue1()); }; }); <form wicket:id="linkForm" > <input wicket:id="value1" type="text" size="30"/> <a wicket:id="link1">Press link1 to submit</a> <input type="submit" value="Send"/> </form> <a wicket:id="link2">Press link 2 to submit</a>
If this link is not placed in a form or given a form to cooperate with, it will fall back to a normal link behavior, meaning that {@link #onSubmit()} will be called without any otherconsequences.
@author chris @author jcompagner @author Igor Vaynberg (ivaynberg) @author Eelco Hillenius
|
|