String formComponentId = request.getParameter(FORM_COMPONENTID_PARAMETER);
final Form form = (Form) componentSource.getComponent(formComponentId);
final ComponentActionSink actionSink = new ComponentActionSink(logger, clientDataEncoder);
PartialMarkupRendererFilter filter = new PartialMarkupRendererFilter()
{
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer)
{
hiddenFieldPositioner = new HiddenFieldPositioner(writer, rules);
// Kind of ugly, but the only way to ensure we don't have name collisions on the
// client side is to force a unique id into each name (as well as each id, but that's
// RenderSupport's job). It would be nice if we could agree on the uid, but
// not essential.
String uid = Long.toHexString(System.currentTimeMillis());
IdAllocator idAllocator = new IdAllocator(":" + uid);
clientId = renderSupport.allocateClientId(resources);
reply.put("elementId", clientId);
InternalFormSupport formSupport =
form.createRenderTimeFormSupport(formClientId, actionSink, idAllocator);
environment.push(FormSupport.class, formSupport);
environment.push(ValidationTracker.class, new ValidationTrackerImpl());
heartbeat.begin();
renderer.renderMarkup(writer, reply);
formSupport.executeDeferred();
heartbeat.end();
environment.pop(ValidationTracker.class);
environment.pop(FormSupport.class);
hiddenFieldPositioner.getElement().attributes(
"type", "hidden",
"name", Form.FORM_DATA,
"value", actionSink.getClientData());
}
};
pageRenderQueue.addPartialMarkupRendererFilter(filter);
}