use of org.apache.tapestry5.internal.util.CaptureResultCallback in project tapestry-5 by apache.
the class AjaxFormUpdateControllerImpl method createInternalFormSupport.
private InternalFormSupport createInternalFormSupport(String formClientId, String formComponentId, ComponentActionSink actionSink) {
// 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
// JavaScriptSupport's job). It would be nice if we could agree on the uid, but
// not essential.
String uid = Long.toHexString(System.nanoTime());
IdAllocator idAllocator = new IdAllocator("_" + uid);
Component formComponent = componentSource.getComponent(formComponentId);
CaptureResultCallback<InternalFormSupport> callback = CaptureResultCallback.create();
// This is a bit of a back-door to access a non-public method!
formComponent.getComponentResources().triggerEvent("internalCreateRenderTimeFormSupport", new Object[] { formClientId, actionSink, idAllocator }, callback);
return callback.getResult();
}
use of org.apache.tapestry5.internal.util.CaptureResultCallback in project tapestry-5 by apache.
the class Select method onChange.
Object onChange(final EventContext context, @RequestParameter(value = "t:selectvalue", allowBlank = true) final String selectValue) throws ValidationException {
final Object newValue = toValue(selectValue);
CaptureResultCallback<Object> callback = new CaptureResultCallback<Object>();
EventContext newContext = new AbstractEventContext() {
@Override
public int getCount() {
return context.getCount() + 1;
}
@Override
public <T> T get(Class<T> desiredType, int index) {
if (index == 0) {
return typeCoercer.coerce(newValue, desiredType);
}
return context.get(desiredType, index - 1);
}
};
this.resources.triggerContextEvent(EventConstants.VALUE_CHANGED, newContext, callback);
this.value = newValue;
return callback.getResult();
}
use of org.apache.tapestry5.internal.util.CaptureResultCallback in project tapestry-5 by apache.
the class Tree method doUpdateSelected.
Object doUpdateSelected(String nodeId, boolean selected) {
TreeNode node = model.getById(nodeId);
String event;
if (selected) {
selectionModel.select(node);
event = EventConstants.NODE_SELECTED;
} else {
selectionModel.unselect(node);
event = EventConstants.NODE_UNSELECTED;
}
CaptureResultCallback<Object> callback = CaptureResultCallback.create();
resources.triggerEvent(event, new Object[] { nodeId }, callback);
final Object result = callback.getResult();
if (result != null) {
return result;
}
return new JSONObject();
}
Aggregations