/** * The JavaScript which triggers this link. Method is non-final so that subclasses can decorate * the provided script by wrapping their own JS around a call to super.getTriggerJavaScript(). * * @return The JavaScript to be executed when the link is clicked. */ protected CharSequence getTriggerJavaScript() { if (getForm() != null) { // find the root form - the one we are really going to submit Form<?> root = getForm().getRootForm(); StringBuilder script = new StringBuilder(); if (shouldInvokeJavaScriptFormOnsubmit()) { script.append(String.format("var ff=document.getElementById('%s');", getForm().getMarkupId())); script.append("if (typeof ff.onsubmit === 'function' && ff.onsubmit() == false) return false;"); } CharSequence url = urlForListener(new PageParameters()); script.append(root.getJsForListenerUrl(url)); script.append("return false;"); return script; } else { return null; } }
/** * The JavaScript which triggers this link. Method is non-final so that subclasses can decorate * the provided script by wrapping their own JS around a call to super.getTriggerJavaScript(). * * @return The JavaScript to be executed when the link is clicked. */ protected CharSequence getTriggerJavaScript() { if (getForm() != null) { // find the root form - the one we are really going to submit Form<?> root = getForm().getRootForm(); StringBuilder script = new StringBuilder(); if (shouldInvokeJavaScriptFormOnsubmit()) { script.append(String.format("var ff=document.getElementById('%s');", getForm().getMarkupId())); script.append("if (typeof ff.onsubmit === 'function' && ff.onsubmit() == false) return false;"); } CharSequence url = urlForListener(new PageParameters()); script.append(root.getJsForListenerUrl(url)); script.append("return false;"); return script; } else { return null; } }