Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SB won't load a file that contains <userData> #253

Open
bendem opened this issue Aug 19, 2019 · 9 comments
Open

SB won't load a file that contains <userData> #253

bendem opened this issue Aug 19, 2019 · 9 comments
Assignees

Comments

@bendem
Copy link

bendem commented Aug 19, 2019

I have the file

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<VBox prefWidth="940.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.a2l.extenso.kitdev.controllers.MethodFilesController">
    <userData>
        <fx:reference source="controller"/>
    </userData>
   <children>
      <HBox spacing="7.0">
         <children>
            <Button fx:id="importButton" mnemonicParsing="false" onAction="#onImport" text="Import methods" />
            <Button fx:id="exportButton" mnemonicParsing="false" onAction="#onExport" text="Export selection" />
            <Button fx:id="analysisButton" mnemonicParsing="false" onAction="#onAnalysis" text="Use method for analysis" />
            <Button fx:id="deleteButton" mnemonicParsing="false" onAction="#onDelete" text="Delete selected methods" />
         </children>
         <opaqueInsets>
            <Insets />
         </opaqueInsets>
         <padding>
            <Insets bottom="7.0" left="7.0" right="7.0" top="7.0" />
         </padding>
      </HBox>
      <TableView fx:id="tableView" minWidth="700.0" VBox.vgrow="ALWAYS">
        <columns>
          <TableColumn fx:id="kitId" editable="false" prefWidth="178.0" text="Kit ID" />
          <TableColumn fx:id="methodId" editable="false" prefWidth="164.0" text="Method ID" />
          <TableColumn fx:id="revision" editable="false" prefWidth="148.0" text="Revision" />
        </columns>
      </TableView>
   </children>
</VBox>

I have to remove the <userData> tag, before opening the file, otherwise I get

Aug 19, 2019 5:14:43 PM com.oracle.javafx.scenebuilder.app.SceneBuilderApp$SceneBuilderUncaughtExceptionHandler uncaughtException
SEVERE: An exception was thrown:
java.lang.NullPointerException
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:98)
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:93)
        at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:110)
        at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2560)
        at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:763)

adding the tag back after the file is opened causes the same exception but that doesn't prevent the editor from working.

@Oliver-Loeffler
Copy link
Collaborator

This is even worse. There should be an error dialog which is not shown.
The exception is thrown by FXMLLoader as it fails to handle the <fx:reference source="controller"/>.
Before making any step further, I need to find out, why the error dialog does not appear.

@Oliver-Loeffler
Copy link
Collaborator

@abhinayagarwal
What is the way SceneBuilder should work? If the controller class as defined in fx:controller property does not exist in class path or module path, this is supposed to fail. Should there be a way for users to extend the class path for FXML loading?

Otherwise, one approach would be to ignore the user data elements on existing FXMLs for FXML loading.
This would be possible by extending the functionality of PR #405 accordingly.

With #405, we could remove most likely not-working content from FXML before passing the FXML into the FXMLLoader but without removing the nodes from the FXOM so the data is not lost for the user.

Hello @bendem!
Would it be okay to just ignore this kind of user data in your case?

@bendem
Copy link
Author

bendem commented Sep 9, 2021

Yes, that's the point of userData in my opinion, provide something dynamic to a static view. There is no way scenebuilder could ever resolve that symbol.

@abhinayagarwal
Copy link
Collaborator

Ignoring the user data elements sounds like the correct approach. I can't think of a scenario where Scene Builder would need to use the data and process something.

@jaymehta-g
Copy link

Still broken, any workarounds/fixes?

@huayra07
Copy link

huayra07 commented Apr 6, 2023

Still broken, any workarounds/fixes?

no

@MetalOxidePeroxide
Copy link

...

@Oliver-Loeffler
Copy link
Collaborator

Oliver-Loeffler commented Apr 6, 2023

@jaymehta-g I will look into this as. There are other FXML/FXOM related issues around and I had to learn how this works internally. There won't be a fix for Scene Builder 20 but I'll give you a ping as soon as there is something to test. Thanks for the reminder.

@AlmasB
Could you please assign this one to me?

@Oliver-Loeffler
Copy link
Collaborator

Oliver-Loeffler commented Apr 6, 2023

Related issues:
#512 (Can't open fxml that contains fx:include)
#281 (ClassDefNotFoundError when importing custom component)

@Oliver-Loeffler Oliver-Loeffler self-assigned this Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants