Accessing the controller instance when using FXMLLoaderFactory [message #1131108] |
Thu, 10 October 2013 03:44  |
Eclipse User |
|
|
|
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 #1131247 is a reply to message #1131124] |
Thu, 10 October 2013 06:43  |
Eclipse User |
|
|
|
.... 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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03264 seconds