1st controller from i am trying to set the value:
public class NewProjectScreenController implements Initializable,ControlledScreen {
public String result;
ScreensController myController;
/**
* Initializes the controller class.
*/
@FXML
public void goToProjectUpdateScreen(ActionEvent event) {
myController.setScreen(MainController.screen6ID);
Session session = NewHibernateUtil.opensession();
session.beginTransaction();
Query queryResult = session.createQuery("from Project where ProjectId = 3 and RegistrationId= 1");
java.util.List allUsers;
allUsers = queryResult.list();
for (int i = 0; i < allUsers.size(); i++) {
Project project = (Project) allUsers.get(i);
//System.out.println("Database contents delivered..."+ project.getProjectname());
result=project.getProjectname();
ProjectCreationScreenController.setText(result);
}
2nd Controller:
public class ProjectCreationScreenController implements Initializable,ControlledScreen {
ScreensController myController;
/**
* Initializes the controller class.
*/
@FXML
private static TextField proname;
public static void setText(String value) {
proname.setText(value);
}
@FXML
private TextField prodescription;
@FXML
private TextField OutputIntegration;
@FXML
private Button button;
@FXML
private void goBack(ActionEvent event) {
myController.setScreen(MainController.screen5ID);
}
@FXML
private void gotoSave(ActionEvent event) {
Project project = new Project();
project.setProjectname (proname.getText());
project.setProjectdescription(prodescription.getText());
project.setOutputintegration(OutputIntegration.getText());
Registration r= new Registration();
r.setRegistrationid(3);
project.setRegistration(r);
ProjectModule.AddProject(project);
// button.setDisable(false);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
}
@Override
public void setScreenParent(ScreensController screenParent) {
myController=screenParent;
}
}
Actually the problem here is I am getting the values from db but the problem is when i am trying to set the value in textfield,it is giving the Null pointer exception.
When i try to debug it , i am able to fetch the value from db and also in setext function, it is taking the exact value but the only problem is in setting the value in UI.
Using java fx and hsql