}
// Render the Property Handler controller.
HandlerAttributes handlerAttributes = (HandlerAttributes) attributes;
EventReference eventReference = handlerAttributes.getEventReference();
ActionReference actionReference = handlerAttributes.getActionReference();
StringBuffer scriptBuffer = new StringBuffer();
if (attributes.getId() != null) {
scriptBuffer.append("Widget.register(")
.append(createJavaScriptString(attributes.getId()))
.append(",");
addCreatedWidgetId(attributes.getId());
}
scriptBuffer.append("new Widget.Handler(")
.append(createJavaScriptExpression(eventReference))
.append(",")
.append(createJavaScriptExpression(actionReference));
if (!handlerAttributes.isEnabled()) {
scriptBuffer.append(",{isEnabled:false}");
}
scriptBuffer.append(")");
if (attributes.getId() != null) {
scriptBuffer.append(")");
}
addUsedWidgetId(eventReference.getWidgetId());
addUsedWidgetId(actionReference.getWidgetId());
// Write JavaScript content to DOM.
try {
getJavaScriptWriter().write(scriptBuffer.toString());