• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get the date to use in a View JavaFX?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys. Well.. My problem is great problem. I'm making a cash system (simple: bills to pay, money to get in, least one other and have the balance). My app use JDBC with MySQL (JPA is a lot of things) and JavaFX. It´s based on MVC. The database is work fine, View classes too, so now I have a issue. End-user insert the values on system, so is save in the DB. In a point, the user needs to know what is the SUM of all bills insert at the system. I´m use a custom query that work´s fine (SELECT SUM(VALUES) FROM CASH WHERE VALUES IS NOT NULL AND DATE='a date select by the user'). At console of MySQL this query return to me that I need. Now THE PROBLEM: I create a method to use this custom query, but at the view class is return a error of NULLPOINTEREXCEPTION.
Folow the basic classes to better understanding:




Now, I have a datePicker in a class view, where the user select a date to make this SUM, and show all values of the bills are added and show in a TextField.
1st - It´s necessary in this

pass like a parameter a date too? (like this: public Bill sumValuesBill(Bill bill, LocalDate date))???
2nd - How I create a method in a controller to get a date from datePicker and use in this method to sum this bills specific by date?
If I was not clear, I can make a video, and post in YouTube to be more clear. For now, thank´s a lot. Regards to all. Ricardo.
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code isn't formatted as code. Please edit your question to provide formatted code.

Making an offsite video is not recommended. Try to edit the question so that it is clear.

If you have a NullPointerException, provide a full stack trace, and indicate where in the code (what line) the stack trace is indicating that the error occurs at.
Read up on What is a NullPointerException and how to fix it?

Fix any bugs you have before you add new features.
So, make sure your program works without causing a NullPointerException before you try to add additional features such as a date picker.

> 1st - It´s necessary in this pass like a parameter a date too? (like this:)???

Yes.

> 2nd - How I create a method in a controller to get a date from datePicker and use in this method to sum this bills specific by date?

See the DatePicker doc. It responds to an onAction specifier. My guess is that you intend to declare your DatePicker in FXML, and inject it into your controller via @FXML. You can also set the action handler for the onAction event as specified in the Introduction to FXML document.


Where I assume the bill has been previously set into the controller using a mechanism such as passing parameters.

FXML usage is a standard way of implementing MVC principles within a JavaFX application and you say you are using MVC. I don't know if you are using FXML, so you may need to adjust the strategy above if you are not. But, regardless, the info above will probably provide you enough info to work out how to solve your issue. If you are unsure how to integrate FXML and controller logic into your application, you may wish to study the Makery tutorial.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic