buffer.append("<p>Replies from DWR are shown with a yellow background if they are simple or in an alert box otherwise.<br/>\n");
buffer.append("The inputs are evaluated as Javascript so strings must be quoted before execution.</p>\n");
for (int i = 0; i < methods.length; i++)
{
MethodDeclaration method = methods[i];
String methodName = method.getName();
// Is it on the list of banned names
if (JavascriptUtil.isReservedWord(methodName))
{
buffer.append("<li style='color: #88A;'>" + methodName + "() is not available because it is a reserved word.</li>\n");
continue;
}
buffer.append("<li>\n");
buffer.append(" " + methodName + '(');
Class<?>[] paramTypes = method.getParameterTypes();
for (int j = 0; j < paramTypes.length; j++)
{
Class<?> paramType = paramTypes[j];
// The special type that we handle transparently
if (LocalUtil.isServletClass(paramType))
{
buffer.append("AUTO");
}
else
{
String value = "";
if (paramType == String.class)
{
value = "\"\"";
}
else if (paramType == Boolean.class || paramType == Boolean.TYPE)
{
value = "true";
}
else if (paramType == Integer.class || paramType == Integer.TYPE || paramType == Short.class || paramType == Short.TYPE
|| paramType == Long.class || paramType == Long.TYPE || paramType == Byte.class || paramType == Byte.TYPE)
{
value = "0";
}
else if (paramType == Float.class || paramType == Float.TYPE || paramType == Double.class || paramType == Double.TYPE)
{
value = "0.0";
}
else if (paramType.isArray() || Collection.class.isAssignableFrom(paramType))
{
value = "[]";
}
else if (Map.class.isAssignableFrom(paramType))
{
value = "{}";
}
buffer.append(" <input class='itext' type='text' size='10' value='" + value + "' id='p" + i + j + "' title='Will be converted to: " + paramType.getName() + "'/>");
}
buffer.append(j == paramTypes.length - 1 ? "" : ", \n");
}
buffer.append(" );\n");
String onclick = (LocalUtil.isJavaIdentifierWithPackage(scriptName) ? scriptName : "dwr.engine._getObject(\"" + scriptName + "\")") + "." + methodName + "(";
for (int j = 0; j < paramTypes.length; j++)
{
if (!LocalUtil.isServletClass(paramTypes[j]))
{
onclick += "objectEval($(\"p" + i + j + "\").value), ";
}
}
onclick += "reply" + i + ");";
buffer.append(" <input class='ibutton' type='button' onclick='" + onclick + "' value='Execute' title='Calls " + scriptName + '.' + methodName + "(). View source for details.'/>\n");
buffer.append(" <script type='text/javascript'>\n");
buffer.append(" var reply" + i + " = function(data)\n");
buffer.append(" {\n");
buffer.append(" if (data != null && typeof data == 'object') alert(dwr.util.toDescriptiveString(data, 2));\n");
buffer.append(" else dwr.util.setValue('d" + i + "', dwr.util.toDescriptiveString(data, 1));\n");
buffer.append(" }\n");
buffer.append(" </script>\n");
buffer.append(" <span id='d" + i + "' class='reply'></span>\n");
// Print a warning if this method is overloaded
boolean overloaded = false;
for (int j = 0; j < methods.length; j++)
{
if (j != i && methods[j].getName().equals(methodName))
{
overloaded = true;
}
}
if (overloaded)
{
buffer.append("<br/><span class='warning'>(Warning: overloaded methods are not recommended. See <a href='#overloadedMethod'>below</a>)</span>\n");
}
// Print a warning if the method uses un-marshallable types
for (Class<?> paramType1 : paramTypes)
{
if (!converterManager.isConvertable(paramType1))
{
buffer.append("<br/><span class='warning'>(Warning: No Converter for " + paramType1.getName() + ". See <a href='#missingConverter'>below</a>)</span>\n");
}
}
if (!converterManager.isConvertable(method.getReturnType()))
{
buffer.append("<br/><span class='warning'>(Warning: No Converter for " + method.getReturnType().getName() + ". See <a href='#missingConverter'>below</a>)</span>\n");
}
// See also the call to getReasonToNotExecute() above
try
{