Code Monkey home page Code Monkey logo

Comments (12)

headcr4sh avatar headcr4sh commented on June 12, 2024

Your module binds an instance of your view "wrong". (wrong means: not as you would have like to use it...)

See this line in your app class:
bind(FxmlExampleView.class).toInstance(new FxmlExampleView());

How is injection supposed to work if you don't construct your class via Guice but instead invoke the constructor of the class manually?

You can either replace this line with:
bind(FxmlExampleView.class).to(FXMLExampleView.class).in(Scope.SINGLETON);

OR you can annotate your FXMLExampleView class with "@javax.inject.Singleton"

... but I think what you REALLY want to do is have a look at the @FXMLComponent annotation which makes creating FXML-based components even easier!! :-) -- have a look at the Calculator Example App which can be found in the "examples" directory of the fx-guice source tree!

Regards
Benjamin

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

ok I removed the line and added FXMLComponent to it, but it still didnt work. still a NPE
which would mean, that my view class is instantiated by guice, but the GuiceFXMLLoader is still not found
even after replacing all that with @singleton and using bind(.class).to(.class).in(Scopes.SIINGLETON) throws an com.google.inject.CreationException with "Binding points to itself" so that doesnt work too. When I try to run your calc project, it throws error, cause maven repository was down for the compiler >_> and if I strip it down to run it without maven, I get the same error as in the smaller example (thus I tried using a smaller example to learn in the first place)

So am I missing something fundamental here?

from fx-guice.

headcr4sh avatar headcr4sh commented on June 12, 2024

Sounds pretty strange.

(1) Which Java version do you use?
(2) Which version of JavaFX do you use (if not using the one that comes bundled with your JRE)?
(2) Which version of fx-guice do you use?
(3) If you say "if i strip it down to run it without maven" -- which dependencies DID you put on the classpath?
fx-guice-${version}.jar and inject-1.jar? Any others beside that?

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024
  1. 1.7.0_21
  2. bundled, javafx.props says javafx.runtime.version=2.2.21
  3. I downloaded G3.0 from here https://code.google.com/p/google-guice/downloads/list
  4. I use Eclipse so I added all the jars to classpath:
  • fx-guice
  • fx-guice javadoc
  • all guice jars (for safety measures, though I dont need multibinding and such)

from fx-guice.

headcr4sh avatar headcr4sh commented on June 12, 2024

I just checked. -- seems like a bug in fx-guice 2.1.x
fx-guice 2.0.x seems to run just fine...

... I'll have a look. :-(

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

I feel kinda dumb now, I can't compile it myself. Even though I specify the JavaFX directory of the jar in my JDK its still telling me "missing symbols" of JavaFX Components.
Dou you maybe have a pre-compiled version of fx-guice on the repo?

Thank you again very much :3

from fx-guice.

headcr4sh avatar headcr4sh commented on June 12, 2024

Hi thatsIch,

I have just released a new version of fx-guice into the wild. Version 2.1.2 can be fetched from the OSS Sonatype Maven repository (oss.sonatype.org) ... it usually takes a few hours until the artifacts have been synced with the Central Maven Repo.

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

oh ok thank you :)

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

I am still getting GuiceFXMLLoader a null value via @Inject.
Subclass is called via Guice with @Inject and everything else is fine with GuiceApplication but the GuiceFXMLLoader

from fx-guice.

headcr4sh avatar headcr4sh commented on June 12, 2024

Can you provide an example that I can download and run?
(Please,... don't just upload a bunch of files onto some pastebin site)

E.g. create a small Github project or zip up your stuff and send it via Dropbox/whatever.

Otherwise I fear I won't be able to reproduce your problem. :-(

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

Sure can do it tomorrow. I try to minimalize it as far as possible.

€: is an eclipse project ok for you?

from fx-guice.

thatsIch avatar thatsIch commented on June 12, 2024

Closing because I kinda expected

@Inject
private GuiceFXMLLoader loader;

to be avaiable upon instantiation, but I guess its on avaiable on

@PostConstruct

Thanks for Support though, awesome integration with JFX :)

👍

from fx-guice.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.