# FXML FAQ

Last updated: 1/24/2013

## Contents

1. FXMLLoader shows unexpected network requests in webstart.
2. Setting root for <fx:root> is required.
3. Can list and array be initialized from an attribute?
4. Can prefixes '$', '@', '%' be used in list and arrays initialization?
5. Could be event handler dynamically changed?

1. #### FXMLLoader shows unexpected network requests in webstart.

   XMLInputFactory looks up its current implementation class name in META-INF/services/javax.xml.stream.XMLInputFactory. If such entry exists in one of application jars the request to the server doesn't happen because the resource is already available from loaded jar. Create an empty file META-INF/services/javax.xml.stream.XMLInputFactory and package it within your application. Factory finder will then get the file but because it is empty providerId==null which causes fallback to the default implementation of XMLInputFactory on jre bootclasspath.

2. #### Setting root for <fx:root> is required.

   Look at description of custom components. Setting root before loading fxml file wasn't required. Root was created and set if custom component had default constructor. To be consistent with documentation setRoot() is always required before loading fxml file.

3. #### Can list and array be initialized from an attribute?

   FXMLLoader is able to initialize list or array property from a string value containing ',' (comma) delimited tokens.

       <VBox stylesheets="style1.css,style2.css,style3.css"/>

4. #### Can prefixes '$', '@', '%' be used in list and arrays initialization?

   FXMLLoader is able to set a list or an array property from a value containing string tokens delimited by "," (list="a, b, c, d"). It can resolve properly tokens prefixed with "@", "%" or "\" Something like this list_property="%resource1, %resource2, ..." or stylesheets="@style1.css, @style2.css, ..." where % is resource and @ is relative path.

5. #### Could be event handler dynamically changed?

   If you want to wire in events into the FXML elements the event needs to come from the controller or from the embedded scripts. This has been extended so that fxmloader looks to the namespace for event handler.

   How to put event handler implementation into namespace:

            fxmlLoader.getNamespace().put("manualAction", new EventHandler<PropertyChangeEvent<String>>() {
                   public void handle(PropertyChangeEvent<String> stringPropertyChangeEvent) {
                       //handle code here
                   }
               });

   Reference event handler in fxml:

               <Widget onNameChange="$manualAction"/>