Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Accessing the controller instance when using FXMLLoaderFactory(What's the best way to get access to the controller instance after loading an FXML file using FXMLLoaderFactory)
Accessing the controller instance when using FXMLLoaderFactory [message #1131108] Thu, 10 October 2013 03:44 Go to next message
Uwe San is currently offline Uwe San
Messages: 96
Registered: January 2012
Member
Hi,

in a follow-up to this discussion in the old forum, I would like to know if using the Eclipse context is still the only (or best) way to access a controller instance after loading an FXML file using the FXMLLoaderFactory class.

The example code was:
@PostConstruct
void init(BorderPane parent, @FXMLLoader FXMLLoaderFactory factory, IEclipseContext ctx) {
   Parent topElement = (Parent) factory.loadRequestorRelative("Test.fxml").load();
   my.package.Controller c = ctx.get("my.package.Controller");
}

According to this Eclipsepedia page, "it is not intended for the developer to use the IEclipseContext directly". So is there a better alternative?

The FXMLLoader class has a getController() method. Could we have a similar solution for the FXMLLoaderFactory or FXMLBuilder class?

Thanks,
Uwe
Re: Accessing the controller instance when using FXMLLoaderFactory [message #1131124 is a reply to message #1131108] Thu, 10 October 2013 04:01 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5277
Registered: July 2009
Senior Member
Sure file a feature request, I agree the IEclipseContext should be
referenced only as a last resort in code.

I've been working on a related topic lately which allows you to publish
informations without the IEclipseContext but it is not yet checked into
the repo.

Tom

On 10.10.13 09:44, Uwe San wrote:
> Hi,
>
> in a follow-up to
> https://groups.google.com/forum/#!searchin/efxclipse/fxmlloaderfactory/efxclipse/BAkd68xlsNo
> in the old forum, I would like to know if using the Eclipse context is
> still the only (or best) way to access a controller instance after
> loading an FXML file using the FXMLLoaderFactory class.
>
> The example code was:
>
> @PostConstruct
> void init(BorderPane parent, @FXMLLoader FXMLLoaderFactory factory,
> IEclipseContext ctx) {
> Parent topElement = (Parent)
> factory.loadRequestorRelative("Test.fxml").load();
> my.package.Controller c = ctx.get("my.package.Controller");
> }
>
> According to this http://wiki.eclipse.org/E4/Contexts#Summary, "it is
> not intended for the developer to use the IEclipseContext directly". So
> is there a better alternative?
>
> The FXMLLoader class has a getController() method. Could we have a
> similar solution for the FXMLLoaderFactory or FXMLBuilder class?
>
> Thanks,
> Uwe
Re: Accessing the controller instance when using FXMLLoaderFactory [message #1131247 is a reply to message #1131124] Thu, 10 October 2013 06:43 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5277
Registered: July 2009
Senior Member
.... just wanted to say patches are welcome ;-)

Tom

On 10.10.13 10:01, Tom Schindl wrote:
> Sure file a feature request, I agree the IEclipseContext should be
> referenced only as a last resort in code.
>
> I've been working on a related topic lately which allows you to publish
> informations without the IEclipseContext but it is not yet checked into
> the repo.
>
> Tom
>
> On 10.10.13 09:44, Uwe San wrote:
>> Hi,
>>
>> in a follow-up to
>> https://groups.google.com/forum/#!searchin/efxclipse/fxmlloaderfactory/efxclipse/BAkd68xlsNo
>> in the old forum, I would like to know if using the Eclipse context is
>> still the only (or best) way to access a controller instance after
>> loading an FXML file using the FXMLLoaderFactory class.
>>
>> The example code was:
>>
>> @PostConstruct
>> void init(BorderPane parent, @FXMLLoader FXMLLoaderFactory factory,
>> IEclipseContext ctx) {
>> Parent topElement = (Parent)
>> factory.loadRequestorRelative("Test.fxml").load();
>> my.package.Controller c = ctx.get("my.package.Controller");
>> }
>>
>> According to this http://wiki.eclipse.org/E4/Contexts#Summary, "it is
>> not intended for the developer to use the IEclipseContext directly". So
>> is there a better alternative?
>>
>> The FXMLLoader class has a getController() method. Could we have a
>> similar solution for the FXMLLoaderFactory or FXMLBuilder class?
>>
>> Thanks,
>> Uwe
>
Previous Topic:How to programmatically Center a MWindow and Access his Rendering Tag.
Next Topic:RCP e4 SWT/JavaFX application with Kepler
Goto Forum:
  


Current Time: Wed Aug 20 12:52:35 EDT 2014

Powered by FUDForum. Page generated in 0.01847 seconds