boolean isAsync = isAsync() || update != null && update.size() > 0;
if (!isAsync && type.equals(FormConstants.SUBMIT_NORMAL))
return;
JSONObject json = null;
// build async URL to form if async
if (isAsync)
{
IForm form = getForm();
json = new JSONObject();
json.put("async", Boolean.TRUE);
json.put("json", isJson());
DirectServiceParameter dsp = new DirectServiceParameter(form, null, this);
json.put("url", getDirectService().getLink(true, dsp).getURL());
}
// only if not async - otherwise we have to stop the client side event to prevent normal form submission
// within the submitbindings client side generated function
if (!isAsync && !isParameterBound("onClick") && !isParameterBound("onclick"))
{
StringBuffer str = new StringBuffer();
str.append("tapestry.form.").append(type);
str.append("('").append(getForm().getClientId()).append("',");
str.append("'").append(getName()).append("'");
if (json != null)
str.append(",").append(json.toString());
str.append(")");
writer.attribute("onClick", str.toString());
return;
}
Map parms = new HashMap();
parms.put("submit", this);
parms.put("key", ScriptUtils.functionHash(type + this.hashCode()));
parms.put("type", type);
if (json != null)
parms.put("parms", json.toString());
PageRenderSupport prs = TapestryUtils.getPageRenderSupport(cycle, this);
getSubmitScript().execute(this, cycle, prs, parms);
}