Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
.... 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 May 07 02:40:04 EDT 2025

Powered by FUDForum. Page generated in 0.03264 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top