te a Form control Form form = new Form("form"); addControl(form); // Add a SubmitLink to the Form SubmitLink link = new SubmitLink("link"); form.add(link); } }
Custom Popup Message
The SubmitLink uses the
"onclick" event handler to submit the Form.
If you would like to customize the
"onclick" event handler, for example to show a confirmation popup message, you can retrieve the link's submit script through the {@link #getSubmitScript(java.lang.String)} method.
Here is an example of providing a confirmation popup message before submitting the Form:
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;"); } }
CSS and JavaScript resources
When SubmitLink is added to a Form it makes use of the following resources (which Click automatically deploys to the application directory,
/click):