FXMLLoader & BuilderFactory
Florian Brunner
fbrunnerlist at gmx.ch
Wed May 29 15:03:01 PDT 2013
Hi,
I'm experimenting with FXMLLoader. Is there a way to get notified, when an instance gets created?
I tried to work with a wrapper class for BuilderFactory, like this:
public class WrapperBuilderFactory implements BuilderFactory {
private final BuilderFactory builderFactory;
public WrapperBuilderFactory(BuilderFactory builderFactory) {
this.builderFactory = builderFactory;
}
@Override
public Builder<?> getBuilder(Class<?> type) {
Builder<?> builder = builderFactory.getBuilder(type);
return new WrapperBuilder<>(builder);
}
private static class WrapperBuilder<T> implements Builder<T> {
private final Builder<T> builder;
public WrapperBuilder(Builder<T> builder) {
this.builder = builder;
}
@Override
public T build() {
T t = builder.build();
doSomething();
return t;
}
private void doSomething(){
// do something
}
}
}
and then call:
FXMLLoader loader = new FXMLLoader();
loader.setBuilderFactory(new FXMLControllerBuilderFactory(loader.getBuilderFactory()));
But it seems that BuilderFactory.getBuilder usually returns null, which gets treaded completely differently (instance created at XML start tag) than when a Builder gets returned (instance created at XML end tag).
Is there another way to get notified when an instance gets created?
Otherwise I will file an enhancement request.
Kind regards,
Florian
More information about the openjfx-dev
mailing list