title: Null data Passing Variable from Controller A to Controller B
body: <p>Hello I am Trying to pass Variable data from database from one Controller to another, but I Have one problem, when I am passing the data to the controller A  to Controller B, appear a Null value, the jerarchy between Scenes is this:</p>
  
  <pre><code>LoginController-&gt;AdminController-&gt;UserController
  </code></pre>
  
  <p>in the LoginController to Access AdminController and Pass the Value i do this:</p>
  
  <pre><code>    public String getRoladmin() {
      return roladmin;
  }
  
  
      public void setRoladmin(String roladmin) {
      this.roladmin = roladmin;
  }
  
  
     public String roladmin="";
  </code></pre>
  
  <p>I Capture the Variable roladmin in this portion of my code like this:</p>
  
  <pre><code> while(rs.next()) {
  
                   comparauser=rs.getString("NOMBREUSUARIO");
                   comparapass=rs.getString("PASS");
                   miadmin=rs.getString("NOMBRE_ADMIN");
                   roladmin=rs.getString("ROL_ADMIN");
  
  
               }
  </code></pre>
  
  <p>to access the Stage I validate if the user and pass are correct like this:</p>
  
  <pre><code> ----rest of code---   if(comparauser.equals(fusuario.getText().toString())&amp;&amp;comparapass.equals(fcontrasena.getText().toString().trim())) {
  
                       try {
                              Stage administrador=new Stage();
                              FXMLLoader carga = new FXMLLoader(getClass().getResource("Admin.fxml"));
                              Parent StackPane = (Parent)carga.load();
                              Scene scene = new Scene(StackPane);
  
                              AdminScreenController loadl = carga.&lt;AdminScreenController&gt;getController();
                              /*loadl.UserScreen.setText("Bienvenido"+"  "+fusuario.getText().toString());*/
                              loadl.UserScreen.setText("Bienvenido"+"  "+miadmin);
                              /* String r=loadl.UserScreen.getText().toString();*/
  
  
  
  
  
        -----in this part I call the LoginController and pass the variable Roladmin------
  
  
  
  ----begin of call--
                                  String h=LoginController.this.roladmin;
                                  LoginController.this.setRoladmin(h);
                                  String r=LoginController.this.getRoladmin();
                                  loadl.setCapdata(r);
  
  
  
      -----end of call-----
  
                                  if(!r.equals("ADMINISTRADOR")) {
  
                                          loadl.btnimg5.setDisable(true);
                                          loadl.btnimg5.setStyle("-fx-opacity:0.65;");
  
                                      }
                                  else {
                                      loadl.btnimg5.setDisable(false);
                                  }
  
                                  scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
                                  administrador.setScene(scene);
                                  administrador.setTitle("AdminScreen");
                                  Stage login=(Stage)fusuario.getScene().getWindow();
                                  login.hide();
                                  administrador.show();
                           }catch(Exception e) {
                               Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, e);
                           }
                       }
      ---rest of code---  
  </code></pre>
  
  <p>now i Pass that variable to the AdminController  like this</p>
  
  <pre><code>in AdminController i have this:
  
  public String capdata;
      public String h;
  
      public String getCapdata() {
          return capdata;
      }
  
      public String setCapdata(String data) {
          return this.capdata = data;
      }
  
  
  this is the code i have to load UserController Stage:
  
  
      public void UserView() throws IOException {
          Stage userstage = new Stage();
          FXMLLoader cargauser =new FXMLLoader(getClass().getResource("UsuarioScreen.fxml"));
          Parent StackPane = (Parent)cargauser.load();
          UserController cargatodouser = cargauser.&lt;UserController&gt;getController();
          String pasadato=UserScreen.getText().toString();
          cargatodouser.iduser.setText(pasadato);
  
    ---begin of call to pass the variable---          
  
  h=AdminScreenController.this.getCapdata();
  
  ---end of call---   
  
  
  
          /*String r=cargatodouser.iduser.getText().toString();*/
          Scene scene = new Scene(StackPane);
          scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
          userstage.setScene(scene);
          userstage.setTitle("QuoraApp");
          Stage AdminScreen=(Stage)btnimg1.getScene().getWindow();
          AdminScreen.hide();
          userstage.show();
  }
  </code></pre>
  
  <p>now when i am passing the variable to the UserController Class i have a null value I am doing this:</p>
  
  <pre><code>In UserController class i have this to go back AdminController:
  
  
  
  
  public String capturau;
  
  
  
  public String getCapturau() {
      return capturau;
  }
  
  public String setCapturau(String capturau) {
      return this.capturau = capturau;
  }
  
          public void inicio() throws IOException {
  
                              Stage administrador=new Stage();
                              FXMLLoader carga = new FXMLLoader(getClass().getResource("Admin.fxml"));
                              Parent StackPane =(Parent) carga.load();
  
                              AdminScreenController loadl = carga.&lt;AdminScreenController&gt;getController();
                              String pasadato=iduser.getText().toString();
                              loadl.UserScreen.setText(pasadato);
  
                              /*Captura.setText(loadl.getCapdata());
                              String captura=Captura.getText().toString();
                              System.out.println(captura);*/
  
  
                             UserController.this.setCapturau(loadl.getCapdata());
                             String gg=UserController.this.getCapturau();
                             System.out.println(gg);
  
          }
  </code></pre>
  
  <p>what i am doing wrong? a little help here please.       </p>