2

I load an AngularJS page by calling this method below in my Java class, just an example. If I have an object, e.g Person, how to send that to the Angular page?

public void init() {
     Person p = this.person; //This is just an example of the object I send
     final JFXPanel fxPanel = new JFXPanel();
     fxPanel.setLayout(new BorderLayout(2,2));
     fxPanel.setSize(new Dimension(1000, 1000));
     fxPanel.setVisible(true);
     Platform.runLater(() -> {
        WebView webView = new WebView();    
        webView.getEngine().load("http://localhost:4200");
        webView.setVisible(true);
        fxPanel.setScene(new Scene(webView));
        });
     add(fxPanel);
 }
2
  • Pass it serialized (for example JSON) as argument to your URL? Commented Dec 28, 2018 at 8:25
  • Or call a JS function. See: stackoverflow.com/a/19422755/461499 Commented Dec 28, 2018 at 8:26

1 Answer 1

0

I'm not sure about Angular practices, but there is a good practice to pass data as an attribute of a tag with "data-" prefix.

<body data-authenticated-person="{id: 123, fullName: &quot;John Doe&quot;}">
...
</body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.