void beginRender(MarkupWriter writer) {
Link link = resources.createFormEventLink(EventConstants.ACTION, context);
actionSink = new ComponentActionSink(logger);
name = renderSupport.allocateClientId(resources);
formSupport = createRenderTimeFormSupport(name, actionSink, new IdAllocator());
if (zone != null) clientBehaviorSupport.linkZone(name, zone, link);
// TODO: Forms should not allow to nest. Perhaps a set() method instead of a push() method
// for this kind of check?
environment.push(FormSupport.class, formSupport);
environment.push(ValidationTracker.class, tracker);
if (autofocus)
{
ValidationDecorator autofocusDecorator = new AutofocusValidationDecorator(environment.peek(
ValidationDecorator.class), tracker, renderSupport);
environment.push(ValidationDecorator.class, autofocusDecorator);
}
// Now that the environment is setup, inform the component or other listeners that the form
// is about to render.
resources.triggerEvent(EventConstants.PREPARE_FOR_RENDER, context, null);
resources.triggerEvent(EventConstants.PREPARE, context, null);
// Save the form element for later, in case we want to write an encoding type attribute.
form = writer.element("form",
"name", name,
"id", name,
"method", "post",
"action", link);
componentInvocationMap.store(form, link);
resources.renderInformalParameters(writer);
div = writer.element("div", "class", CSSClassConstants.INVISIBLE);
for (String parameterName : link.getParameterNames())
{
String value = link.getParameterValue(parameterName);
writer.element("input",
"type", "hidden",
"name", parameterName,
"value", value);
writer.end();
}
writer.end(); // div
environment.peek(Heartbeat.class).begin();
}
|