Results 1 to 2 of 2
  1. #1
    encryptor is offline Member
    Join Date
    Apr 2017
    Rep Power

    Default How do I Pass a Parameter to the Controller with this Code setup?

    I have what I seem to think is a different code setup than the normal standard scene, and I cant figure out how to pass a parameter to the controller with this stage and scene setup. Anyone have an idea of how to go about this?

    Im trying to just pass an ID to the controller.

    Java FX Code:
    private void LoadQuickiePage(MouseEvent e) {
            try {
                ImageView iv = (ImageView) e.getSource();
                String id = iv.getId();
                ((Node) e.getSource()).getScene().getWindow().hide();
                Flow flow = new Flow(QuickieController.class);
                DefaultFlowContainer container = new DefaultFlowContainer();
                flowContext = new ViewFlowContext();
                Stage primaryStage = new Stage();
                flowContext.register("Stage", primaryStage);
                JFXDecorator decorator = new JFXDecorator(primaryStage, container.getView());
                Scene scene = new Scene(decorator, 800, 850);
            } catch (FlowException ex) {
                Logger.getLogger(BoatBuilderController.class.getName()).log(Level.SEVERE, null, ex);

  2. #2
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    MA, USA
    Rep Power

    Default Re: How do I Pass a Parameter to the Controller with this Code setup?

    I am not sure whether the code snippet gives us enough info to give a qualified answer, but let's give it a shot. Let's assume you have a stage/ scene and you have an associated controller-instance. Now you want to pass info to the controller from a third class and have the controller do some work on the scene.
    In this case you have to pass this specific instance of the controller class to the "outside" class ("Dependency Injection"). You can do that by passing it when you create an instance of the outside class (instance of controller included in constructor) or you can just do it manually by
    1. Define variable in outside class: ControllerClass myController;
    2. Create public method in outside class: public void injectControllerInstance(ControllerClass controller){this.myController=controller;}
    3. In the Controller class, call the method from 2. in the initialize() method: outsideClass.injectControllerInstance(this);

    Then you should be good to call myController.doSomeAwesomeGraphic(); from the outside class.

Similar Threads

  1. How to pass a form one controller to another controller
    By sasikumarkrishnasamy in forum Spring
    Replies: 0
    Last Post: 08-17-2014, 07:48 PM
  2. Pass a superclass as a parameter?
    By kkid in forum New To Java
    Replies: 4
    Last Post: 11-29-2013, 02:55 PM
  3. pass a parameter from sql table to jsp page.
    By kirti bansal in forum JavaServer Pages (JSP) and JSTL
    Replies: 8
    Last Post: 05-31-2012, 09:32 AM
  4. how to pass parameter from one jsp to another jsp
    By kader_sit in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-10-2010, 02:04 PM
  5. I can't seem to pass a file through a parameter
    By daletron3030 in forum New To Java
    Replies: 5
    Last Post: 01-15-2009, 06:07 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts