use of org.apache.tapestry5.internal.BeanEditContextImpl in project tapestry-5 by apache.
the class BeanEditor method doPrepare.
/**
* Used to initialize the model if necessary, to instantiate the object being edited if necessary, and to push the
* BeanEditContext into the environment.
*/
void doPrepare() {
if (model == null) {
Class type = resources.getBoundType("object");
model = modelSource.createEditModel(type, overrides.getOverrideMessages());
BeanModelUtils.modify(model, add, include, exclude, reorder);
}
if (object == null) {
try {
object = model.newInstance();
} catch (Exception ex) {
String message = String.format("Exception instantiating instance of %s (for component '%s'): %s", PlasticUtils.toTypeName(model.getBeanType()), resources.getCompleteId(), ex);
throw new TapestryException(message, resources.getLocation(), ex);
}
}
BeanEditContext context = new BeanEditContextImpl(model.getBeanType());
cachedObject = object;
environment.push(BeanEditContext.class, context);
// TAP5-2101: Always provide a new BeanValidationContext
environment.push(BeanValidationContext.class, new BeanValidationContextImpl(object));
}
Aggregations