{try { __CLOVER_130_0.M[700]++;
__CLOVER_130_0.S[3130]++;if ((((_events == null || _events.isEmpty()) && (++__CLOVER_130_0.CT[570] != 0)) || (++__CLOVER_130_0.CF[570] == 0))){
__CLOVER_130_0.S[3131]++;return;}
__CLOVER_130_0.S[3132]++;Body body = Body.get(cycle);
__CLOVER_130_0.S[3133]++;if ((((body == null) && (++__CLOVER_130_0.CT[571] != 0)) || (++__CLOVER_130_0.CF[571] == 0))){
__CLOVER_130_0.S[3134]++;throw new ApplicationRuntimeException(
Tapestry.getMessage("Form.needs-body-for-event-handlers"),
this,
null,
null);}
__CLOVER_130_0.S[3135]++;StringBuffer buffer = new StringBuffer();
__CLOVER_130_0.S[3136]++;Iterator i = _events.entrySet().iterator();
__CLOVER_130_0.S[3137]++;while ((((i.hasNext()) && (++__CLOVER_130_0.CT[572] != 0)) || (++__CLOVER_130_0.CF[572] == 0))){
{
__CLOVER_130_0.S[3138]++;Map.Entry entry = (Map.Entry) i.next();
__CLOVER_130_0.S[3139]++;FormEventType type = (FormEventType) entry.getKey();
__CLOVER_130_0.S[3140]++;Object value = entry.getValue();
__CLOVER_130_0.S[3141]++;buffer.append("document.");
__CLOVER_130_0.S[3142]++;buffer.append(_name);
__CLOVER_130_0.S[3143]++;buffer.append(".");
__CLOVER_130_0.S[3144]++;buffer.append(type.getPropertyName());
__CLOVER_130_0.S[3145]++;buffer.append(" = ");
// The typical case; one event one event handler. Easy enough.
__CLOVER_130_0.S[3146]++;if ((((value instanceof String) && (++__CLOVER_130_0.CT[573] != 0)) || (++__CLOVER_130_0.CF[573] == 0))){
{
__CLOVER_130_0.S[3147]++;buffer.append(value.toString());
__CLOVER_130_0.S[3148]++;buffer.append(";");
}}
else{
{
// Build a composite function in-place
__CLOVER_130_0.S[3149]++;buffer.append("function ()\n{\n");
__CLOVER_130_0.S[3150]++;boolean combineWithAnd = type.getCombineUsingAnd();
__CLOVER_130_0.S[3151]++;List l = (List) value;
__CLOVER_130_0.S[3152]++;int count = l.size();
__CLOVER_130_0.S[3153]++;for (int j = 0; (((j < count) && (++__CLOVER_130_0.CT[574] != 0)) || (++__CLOVER_130_0.CF[574] == 0)); j++){
{
__CLOVER_130_0.S[3154]++;String functionName = (String) l.get(j);
__CLOVER_130_0.S[3155]++;if ((((j > 0) && (++__CLOVER_130_0.CT[575] != 0)) || (++__CLOVER_130_0.CF[575] == 0))){
{
__CLOVER_130_0.S[3156]++;if ((((combineWithAnd) && (++__CLOVER_130_0.CT[576] != 0)) || (++__CLOVER_130_0.CF[576] == 0))){
__CLOVER_130_0.S[3157]++;buffer.append(" &&");}
else{
__CLOVER_130_0.S[3158]++;buffer.append(";");}
}}
__CLOVER_130_0.S[3159]++;buffer.append("\n ");
__CLOVER_130_0.S[3160]++;if ((((combineWithAnd) && (++__CLOVER_130_0.CT[577] != 0)) || (++__CLOVER_130_0.CF[577] == 0))){
{
__CLOVER_130_0.S[3161]++;if ((((j == 0) && (++__CLOVER_130_0.CT[578] != 0)) || (++__CLOVER_130_0.CF[578] == 0))){
__CLOVER_130_0.S[3162]++;buffer.append("return ");}
else{
__CLOVER_130_0.S[3163]++;buffer.append(" ");}
}}
__CLOVER_130_0.S[3164]++;buffer.append(functionName);
__CLOVER_130_0.S[3165]++;buffer.append("()");
}}
__CLOVER_130_0.S[3166]++;buffer.append(";\n}");
}}
__CLOVER_130_0.S[3167]++;buffer.append("\n\n");
}}
__CLOVER_130_0.S[3168]++;body.addInitializationScript(buffer.toString());
} finally { }}