FXMLLoader & BuilderFactory
Daniel Zwolenski
zonski at gmail.com
Fri May 31 16:49:07 PDT 2013
Try setting a LoadListener on your FXMLLoader and the endElement(Object
value) callback may give you what you are after.
Just out of curiosity, what's the use case?
On Sat, Jun 1, 2013 at 8:33 AM, Florian Brunner <fbrunnerlist at gmx.ch> wrote:
> Hi Daniel,
>
> Thanks for your response.
>
> > When you say 'instance' what do you mean? A controller or a node or
> something else?
> I'm looking for a way to get notified when a Node gets created.
>
> Regards,
> Florian
>
> Am Donnerstag, 30. Mai 2013, 08.25:23 schrieb Daniel Zwolenski:
> > When you say 'instance' what do you mean? A controller or a node or
> something else?
> >
> > A controller can be notified when it is initialized (and all the
> associated nodes will be initialized by this point):
> >
> > http://docs.oracle.com/javafx/2/api/javafx/fxml/Initializable.html
> >
> > Does that give you the hook ins you need?
> >
> > On 30/05/2013, at 8:03 AM, Florian Brunner <fbrunnerlist at gmx.ch> wrote:
> >
> > > 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