ControllerFactory in FXMLLoader not called during the loading of uri

Im trying to use the method setControllerFactory() FXMLLoader for injection of dependence, but stumbled upon a problem that looks like a bug to me. The controller factory works fine when loading the input stream fxml, but do not get called during the loading of a uri. I wrote a simple unit test to illustrate the issue:
public class FXMLLoaderTest {

     private FXMLLoader loader;

     @Test
     public void testFXMLFactory() throws IOException {
          FXMLLoader loader = new FXMLLoader();
          Callback<Class<?>, Object> callback = new Callback<Class<?>, Object>() {
               @Override
               public Object call(Class<?> aClass) {
                    System.out.println("Controller factory called");
                    return new String("Works");
               }
          };
          loader.setControllerFactory(callback);
          
          // This makes the test fail
          //Object node = loader.load(getClass().getClassLoader().getResource("controllerTest.fxml"));
          
          // While this works as expected
          Object node = loader.load(getClass().getClassLoader().getResourceAsStream("controllerTest.fxml"));

          assertThat(loader.getController(), is(equalTo((Object) "Works")));
     }
}
IM using javafx 2.2 shipped with JDK 7u21. Am I missing something or do I have to file an issue for this?

FXMLLoader.load (URL) is a static method, so your commented line

Object node = loader.load(getClass().getClassLoader().getResource("controllerTest.fxml"));

is equivalent to (and probably should be written as)

Object node = FXMLLoader.load(getClass().getClassLoader().getResource("controllerTest.fxml"));

Obviously, the static method is not aware of the controller factory that you set on your instance of FXMLLoader.

To use a URL with an instance of FXMLLoader, to either pass the URL to the FXMLLoader constructor:

FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("controllerTest.fxml"));

method setLocation (...) or:

FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getClassLoader().getResource("controllerTest.fxml"));

and then set the same controller factory.

Tags: Java

Similar Questions

  • Editing cascading from the selection list - not refreshing during the loading?

    Hi all

    I have 2 lists of selection, the latter with an option cascading of LOV.

    Now, this works very well when you select an option in the list 1, list 2 fills correctly.

    My question is when I re - complete list 1 and list 2 from a single onload procedure 1 load properly, list 2 does not show the correct value (but it has not the right value is session).

    This feature exist?

    Please let me know if you need more information.

    Concerning

    Spam

    Hello

    You have the following items in the pl/sql code of DA:

    begin
    select parent_id, child_id
     into :p1_parent, :p1_child
    from holder
    where parent_id = 1;
    end;
    

    You have the following in the query LOV's P1_CHILD:

    select col2 d, col1 r
    from child
    where col3 = :p1_parent
    

    P1_parent = 1, the LOV query returns 2 rows - DUNDEE and GLASGOW. The list of selection, therefore, cannot set a value. I changed the order of the day of the P1_CHILD page for a multiple-selection list and it works fine now.

  • Loading screen is not animated, during the operation, but after

    Hi all!

    Here's my problem: I am display a gif animated using the class presented here.

    It is used in a specific class loader that perform an action, while the gif is displayed (the gif is a spinner). Only once the operation is completed, the LoadingScreen came out of the screen.

    Here's my class loader:

    public class LoadingScreen extends MainScreen {
    
        /**
         * The action to be processed during the loading.
         */
        Runnable action = null;
    
        private AnimatedGIFField _image;
    
        /**
         * Default constructor.
         *
         * @param action the action to manage.
         */
        public LoadingScreen(Runnable action)
        {
            super(FIELD_VCENTER);
            this.setTitle(CommonTools.initTitleBar());
            this.action = action;
    
            displayAnimation();
    
            if(this.action != null)
            {
                UiApplication.getUiApplication().invokeLater(this.action);
            }
        }
    
        /**
         * Display the animation during the loading process.
         */
        private void displayAnimation()
        {
            EncodedImage encImg =
                GIFEncodedImage.getEncodedImageResource("loading.gif");
            GIFEncodedImage img = (GIFEncodedImage) encImg;
    
            _image = new AnimatedGIFField(img);
    
            getMainManager().setBackground(BackgroundFactory.createSolidBackground(Color.BLACK));
    
            LabelField label = new LabelField("Connect..."){
                public void paint(Graphics g)
                {
                    g.setColor(Color.WHITE);
                    super.paint(g);
                    }
            };
    
            HorizontalFieldManager containerSpin = new HorizontalFieldManager(FIELD_HCENTER);
            HorizontalFieldManager containerLabel = new HorizontalFieldManager(FIELD_HCENTER);
            containerSpin.add(_image);
            containerLabel.add(label);
    
            containerSpin.setPadding(Display.getHeight()>>2, 0, 0, 0);
    
            this.add(containerSpin);
            this.add(containerLabel);
    
            KasualApplication.isLoading = true;
        }
    }
    

    The problem is that the gif is not animated, while the action runs. But if I have a popup appears at the end of the action to let the loading screen, I see that the gif is animated. As well as the animation starts when the action is complete.

    I think something is wrong in the clock of my son, but I don't see that.

    Could you please help me?

    Thanks in advance.

    It's ok, the solution is described here.

  • Default method of workflow activity is not called when the Page refreshes

    Basically, try to call a script function java front page of fragments of the charges.

    INSTALLATION PROGRAM:

    Jdev 12 c

    TF defined with a default activity that invokes a page fragment.

    The activity of default method calls a method to support bean which inturn calls the method init java script before the fragment on the page doesn't load.

    This TF is in a container jsf page.

    During the loading of the page containing the first activity of the method is called and js function triggers and then fragments of charges which is the desired behavior.

    PROBLEM:

    When I refresh the page by pressing F5 or by running the page again on the same window of the browser activity method default IS NOT gets called which inturn will not trigger the js call.

    But when I run the same page again in a different window it works and then subsequent updates or page load activity IS NOT of default method is called.

    If it is not provided? The default activity is called when the workflow is updated.

    Check outhttp://www.oracle.com/technetwork/developer-tools/adf/learnmore/108-triggerpopupinregion-1994836.pdf which should work also in your car.

    Timo

  • System error 31 during the loading of the LabVIEW runtime engine

    I get the following error message.  I've attached a screenshot of him as well.

    System error 31 during the loading of the LabVIEW runtime engine (\\lvrt.dll)

    I'm trying to update an instrument running Windows 95.  What is system 31 error?  I can't find anything on this topic using Google or the search function of the forum.

    The instrument is a Romulus-IIIA of the Quad.  Chasing the assistance on their part as well.

    Hi Szandstra,

    See the knowledge base article describing what you see.  Follow the steps there to correct the problem.  Have a great day and let me know if this solution does not work for you!

  • VAIO Duo 13 touchscreen does not well during the charge. Stop charge in battery mode, it's ok.

    Any user of Duet 13 having problems with the touch screen when the load on the sector? Touch screen keyboard reacts not well, or does not capture the key pressed during the loading of the machine. However, once load stop and battery operated, things return to normal. What could go wrong?

    personal Sony can help you advise? I only encounter this problem while loading the battery, powered by battery or adapter has been working very well.

  • Animation during the loading of the page

    I just created an animation using Fireworks which, according to the tutorial can be used as entertainment during the loading of the page. What format this file must be in and where do I download it on the server... (someone has a tutorial)... one I used went, step by step, how to do it, but did not operate on the site... Thank you

    "whatisgood" wrote in message
    News:go3jlv$29$1@forums. Macromedia.com...
    > I have just created an animation using Fireworks according to the tutorial
    > can
    > serve animation while the page is loading. What format for this
    > file
    > have need to be and where do I download it on the server... (anyone have one)
    (> tutorial)... one I used went, step by step, how to do it, but does not
    > talk
    > make it all work on the site... Thank you
    >

    Im not that warned with animation in FW, but I'm assuming it would be a
    animated gif format.

    When you turn the image, the actual file or the path is not so much the
    important thing, making sure that you have correctly linked to the image
    destination on the page.
    When you upload to the server, make sure that you keep the file
    structure of your local files. If you use dreamweaver to ftp and you
    have set properly your site in dreamweaver, and then download the image
    your local site files should maintain this structure.

    Hope this is useful

    Concerning
    Fiona

  • iCloud backup after iOS 10 - some files were not available during the last backup

    HI - we are a company with about 350 users of iPhone and iPad.  I put this in the iCloud in the community section, but I've seen other users have the same problem in this section, so I thought I would add here.

    In order to stop users add their own e-mail accounts on the iPhone that lock us the device through restrictions - deactivation of the accounts section.  It stops and then access the iTunes settings.  In the test of iOS 10.0.1, we have one of the devices (a 16 GB 5 s, who had been a backup at 7:20 that morning), improved 9.3.2 that went well with no obvious problems, then, after a few days to leave the handset to the function, we have lifted the restriction and the backup on iCloud to find any backup not occurred since the upgrade and a message 'some files were not available during the last. backup"in its place.

    If all our staff upgrade their phones (we gave says not yet) then the backups look like they stop.  It is easy to fix, as a manual backup, will complete the process, but you have to remove the restriction to do this.

    We tested on iPhone 5, 5 s, air iPad iOS 8 to 9.3.5 and all have this problem.

    I have exactly the same problem, 16 GB iPhone 5s as well. I plan on raising at my Genius Bar appointment today.

  • iPhone 6 + will not except that the load rope nor any what lightning male. Impossible to recharge the iPhone.

    iPhone 6 + will not except that the load rope nor any what lightning male. Impossible to recharge the iPhone. Male/female connection not relieve tight. Advice\help would be appreciated.

    Try a different cable - preferably a certified one MFI

    If this does not work

    Please take a genius appointment at an Apple Store, or select another authorized service provider.

  • When you use Device.device.os, it throws error #1079: native methods are not allowed in the loaded code.

    Hi all

    When I tried to use the Device.device.OS to get the string from the bone. It is compiled smoothly. But it throws error when the application started on my desk.

    Error #1079: Native methods are not allowed in the loaded code.

    It does not error in the emulator, but he did not get the chain of the OS.

    Someone knows how to use the device class? Is it still not currently supported?

    Thank you very much!

    Error #1079: Native methods are not allowed in the loaded code.

    This error is thrown on the desktop because your qnx - air.swc is probably in the process of fusion as code instead of being tied to your project as external. The reason who need to be external is that it contains classes that exist in the execution of AIR in the Simulator and not in the AIR runtime on your desktop. The device classes use the custom air extensions we wrote to get the properties of the device.

    If you want just the operating system, you can also use the Capabilities.os, which is a standard API Flash Player and does not require the use of custom extensions.

    My guess on why it does not work on the device thus is that the qnx - air.swc is not defined externally. Return to externally set and run it in the Simulator.

    Hope that helps

    Julian

  • Hi my creative cloud App tabs is not working means the loading of spent 2 hrs

    Hi my creative cloud App tabs is not working means the loading of spent 2 hrs

    Hello

    I think you found the turning wheel on the Adobe CC application.

    Please check the help below document:

    Does not open App | Wheels of progress turn continuously

    You can also view the nets below where this issue has been addressed:

    Adobe Creative Cloud / Desktop App / Home Screen: constant spinning wheel

    Creative Cloud Desktop App taped blue spinning wheel after update.

    Kind regards

    Sheena

  • My serial number is not accepted during the installation of 12 elements in Photoshop.

    My serial number is not accepted during the installation of 12 elements in Photoshop.   Answer: This serial number is not valid for Adobe Photoshop elements 12.

    You can't do that by phone, but in the link I gave, click always problems? and then chat with an Agent.

  • the system configuration not saved during the last stop on the service console error

    Hello

    I m getting this msg of error on the service console

    the system configuration not saved during the last stop on the service console error

    but when I tried to run some commands s troubleshoot mode according to the vmware esxcfg-boot - b, esxcfg-boot - p I got an error message like

    bad interprator usr permission denied

    I guess you follow this KB: http://kb.vmware.com/kb/1002503

    But seems like you have file system errors.

    Try to restart your system in init 1

    Then use fsck command to check your ext3 file system (remember that the file systems are not in use and use the - f option).

    André

  • [ADF, JDev12.1.3] How to display a gif of loading during the loading of the af: table (through the ExecuteWithParams method call)?

    Hallo,

    in the fragment of my page, I created an af:table you drag an instance of VO for the data control; I also have a search button by dragging the operation ExecuteWithParams of the same instance of VO.

    I double clicked on the serach button to create the searchButton_action method in the bean calling the ExecuteWithParams operation after you have made a few operations.

    Next to the button, I put a table whose source is a gif of "load".

    I would like to make visible the gif while research is underway and make it invisible when the search is complete.


    In the beginning, I followed this approach.

    In the searchButton_action, I wrote the code to set the visible of the image property.

    But it did not work because the gif never appears. I also tried to set the property PartialTriggers of the image with the ID of the button table and search.

      public String searchButton_action() {
        RichActiveImage imgSearch = (RichActiveImage) FacesUtils.findComponent("ImgSearch");
        imgSearch.setVisible(true);
        AdfFacesContext.getCurrentInstance().addPartialTarget(imgSearch);
        // ...
        OperationBinding operationBinding = BindingsUtils.getBindings().getOperationBinding("MyVOInstanceExecuteWithParams");
        // ...
        imgSearch.setVisible(false);
        AdfFacesContext.getCurrentInstance().addPartialTarget(imgSearch);
        // ...
      }
    

    Then I tried with another approach which is to set the Visible property using the value off of the search button which is #{! links.} MyVOInstanceExecuteWithParams.enabled}

    But also, this approach has not worked.

    I also tried to set the property PartialTriggers of the image with the ID of the button table and search.

    What's not in my efforts? You could you kindly help me to solve the problem?

    Thank you

    Federico

    PS

    FacesUtils.findComponent is a method that retrieves the item passed as param. It works well since I used it several more times in my application.

    Your approach may not work add there is only a single thread of UI work. Your trigger reached the component when the execute with Péan has finished its work.

    For your use case there are a few solutions combining JavaScript and client-server events showing a window as long as the operation is running. Read https://blogs.oracle.com/groundside/entry/notification_during_long_running_transactions for all the info.

    Timo

  • Where can get newspaper of reason behind Manager jaxws soap does not run during the webservice call in weblogic 11 g

    Hi guys,.

    http://docs.Oracle.com/CD/E23943_01/Web.1111/e13734/handlers.htm#WSADV189

    I created SOAP manage by top surround URL and deployment artifacts are generated with build.xml.

    I don't know why managers do not run in the web service call in weblogic 11 g.

    Regarding

    Siddharth Singh

    Solution

    Ant was not generating little class and manager xml file

    I manually copy these files

    Maybe Ant was not generating these files because of this warning

    [jwsc] WARNING: types of annotations without Transformers: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotation.XmlAccessorType, javax.xml.bind.annotation.XmlType, javax.xml.bind.annota

    n.XmlElement]

    [jwsc] 1 WARNING

    Full journal of ants

    D:\SOAP_JMS>Ant f ant - build - jhand.xml
    BuildFile: Ant - build - jhand.xml
    Trying to replace the old definition of the task clientgen

    Build-service4:
    [jwsc] TJ: processing module/om/sai/buddh/SaiWebService
    [jwsc] The analysis of source files
    [jwsc] The analysis of source files
    [jwsc] 1 TJS files processing for the module/om/sai/buddh/SaiWebService
    [jwsc] TJ: D:\Oracle-ESB-RND\EncrpytionDecriptionWS\src\om\sai\buddh\SaiWebService.java valid.
    [jwsc] Treatment of the web services JAX - WS 1...
    [jwsc] WARNING: types of annotations without Transformers: [javax.xml.bind.annotation.XmlRootElement, javax.xml.bind.annotat
    tion. XmlElement]
    [jwsc] 1 WARNING
    [jwsc] Compilation of 5 source files for C:\Users\si244339\AppData\Local\Temp\_y1j0ng
    [jwsc] Building jar: D:\SOAP_JMS\outputnew\AAJAXHandlerSai1EarResponseQ\om\sai\buddh\SaiWebService.war
    [jwsc] Created JWS deployment outputFile: D:\SOAP_JMS\outputnew\AAJAXHandlerSai1EarResponseQ\om\sai\buddh\SaiWebServic
    [jwsc] [EarFile] Application file: D:\SOAP_JMS\outputnew\AAJAXHandlerSai1EarResponseQ\META-INF\application.xml
    [AntUtil.deleteDir] remove directory C:\Users\si244339\AppData\Local\Temp\_y1j0ng

    BUILD SUCCESSFULLY

Maybe you are looking for

  • You can install Windows on a Mac without an optical drive

    Hey, I have a Mac end 2011 a friend gave to me and he said it was broken. I realized that it was just the SATA port on the motherboard, so I pulled out the optical drive and I put an SSD in it. Now I want to install Windows but Mac says that I am not

  • How to change the email password?

    I can't find where change my thunderbird email password... my ISP gave me a temp and I'm going to change it, but where?I figured out the master password, but cannot find any info on the ordinary e-mail password

  • Cannot delete the bookmark

    Information system: Ubuntu 11.10, running Firefox-trunk 12.0a1 (2012-01-21), cannot remove bookmarks.

  • Stop the mouse Bluetooth in a Satellite E105-s1402

    Mouse presenter give bluetooth lost connection without reason. I have the latest version of BT stack (6.40.02). Can someone help me? TKS

  • Defragmentation and how soon to defragment again?

    Once you do a defrag, how much time will you need to do again my computer seems like it needs quite often. I also checked as the next day and noticed something on the files that cannot be moved. He looked like a fragment in blue is green instead of R