_formSupport = new FormSupportImpl();
_environment.push(ValidationTracker.class, _tracker);
_environment.push(FormSupport.class, _formSupport);
Heartbeat heartbeat = new HeartbeatImpl();
_environment.push(Heartbeat.class, heartbeat);
heartbeat.begin();
try
{
final Holder<Object> holder = Holder.create();
ComponentEventHandler handler = new ComponentEventHandler()
{
public boolean handleResult(Object result, Component component, String methodDescription)
{
// We want to process the event here, so that the component and method description are
// properly identified. But that's going to cause a headache aborting the
// event.
try
{
_eventResultProcessor.processComponentEvent(result, component, methodDescription);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
holder.put(true);
return true; // Abort other event processing.
}
};
_resources.triggerEvent(PREPARE, context, handler);
//
if (holder.hasValue()) return holder.get();
// TODO: Ajax stuff will eventually mean there are multiple values for this parameter
// name
String actionsBase64 = _request.getParameter(FORM_DATA);
ObjectInputStream ois = null;
Component component = null;
try
{
ois = new Base64ObjectInputStream(actionsBase64);
while (true)
{
String componentId = ois.readUTF();
ComponentAction action = (ComponentAction) ois.readObject();
component = _source.getComponent(componentId);
action.execute(component);
component = null;
}
}
catch (EOFException ex)
{
// Expected
}
catch (Exception ex)
{
throw new TapestryException(ex.getMessage(), component, ex);
}
finally
{
TapestryInternalUtils.close(ois);
}
heartbeat.end();
ValidationTracker tracker = _environment.peek(ValidationTracker.class);
// Let the listeners peform any final validations