Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » is it possible to use eclipse service in controller of fxml?
is it possible to use eclipse service in controller of fxml? [message #1724147] Sun, 21 February 2016 18:21 Go to next message
Milankumar Ardeshana is currently offline Milankumar ArdeshanaFriend
Messages: 27
Registered: August 2015
Junior Member
hi

for my application i am loading ui from fxml. i have multiple part application. and each part is as below

Part1                                                   | Part2
personabstractpart.java (part)                          | PersonDetailedInfoPart.java (part)                                                                
personabstractpart.fxml (ui-> built using javafx 8)     | PersonDetailedInfoPart.fxml (ui-> built using javafx 8)             
personabstractpartcontroller.java (controller for fxml) | PersonDetailedInfoPartcontroller.java (controller for fxml)


now i want to use ESelectionService in my controller class. as below

@FXML
private TableView<Person> personTable;

@Inject
private ESelectionService selectionService;
...
@FXML
private void initialize() {
    	
    	
    	personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
    		
			@Override
			public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
				selectionService.setSelection(newValue);
				System.out.println("set: " + newValue); 
			}
		});
.
.
.
}



my controller class is not able to inject selection service here.

Question is
(a) is it possible to inject selectionService/controllerclass using ContextInjectionFactory? i don't know what(controller/service) i should inject and where(view/controller) i should inject and is it recommended?

(b) (i) so what currently i am doing is loading fxml and after that i am fetching my controlls from root of fxml and adding listener to my tableview. is this recommended?

root = FXMLLoader.load(PersonAbstractPart.class.getResource("PersonAbstractPart.fxml"));
AnchorPane box=(AnchorPane)root;
parent.setTop(box);
Node splitpane = box.getChildren().get(0);
SplitPane spnode = (SplitPane)splitpane;
Node anchornode = spnode.getItems().get(0);
AnchorPane anchorPane = (AnchorPane)anchornode;
personTable=(TableView<Person>)anchorPane.getChildren().get(0);
.
.
.
personTable.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() {
    		
			@Override
			public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) {
				selectionService.setSelection(newValue);
				System.out.println("set: " + newValue); 
			}
		});



(ii) can i make my view to be controller? --> in view class @FXML is not fetching the controls after loading the fxml. and can't use easily as i can use in controller class.

any help appreciated.

Thanks,
Milan
Re: is it possible to use eclipse service in controller of fxml? [message #1724149 is a reply to message #1724147] Sun, 21 February 2016 19:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

https://wiki.eclipse.org/Efxclipse/Runtime/Recipes#.40FXMLLoader

Tom


On 21.02.16 19:21, Milankumar Ardeshana wrote:
> hi
> for my application i am loading ui from fxml. i have multiple part
> application. and each part is as below
>
>
> Part1 | Part2
> personabstractpart.java (part) |
> PersonDetailedInfoPart.java
> (part)
> personabstractpart.fxml (ui-> built using javafx 8) |
> PersonDetailedInfoPart.fxml (ui-> built using javafx 8)
> personabstractpartcontroller.java (controller for fxml) |
> PersonDetailedInfoPartcontroller.java (controller for fxml)
>
>
> now i want to use ESelectionService in my controller class. as below
>
>
> @FXML
> private TableView<Person> personTable;
>
> @Inject
> private ESelectionService selectionService;
> ..
> @FXML
> private void initialize() {
>
>
>
> personTable.getSelectionModel().selectedItemProperty().addListener(new
> ChangeListener<Person>() {
>
> @Override
> public void changed(ObservableValue<? extends Person>
> observable, Person oldValue, Person newValue) {
> selectionService.setSelection(newValue);
> System.out.println("set: " + newValue); }
> });
Re: is it possible to use eclipse service in controller of fxml? [message #1724150 is a reply to message #1724149] Sun, 21 February 2016 20:50 Go to previous message
Milankumar Ardeshana is currently offline Milankumar ArdeshanaFriend
Messages: 27
Registered: August 2015
Junior Member
Perfect. Thanks.
Previous Topic:Buckminster can't resolve org.eclipse.fx.javafx
Next Topic:opening a ui modeled dialogue from main thread leads to exception
Goto Forum:
  


Current Time: Thu Apr 25 00:43:26 GMT 2024

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

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

Back to the top