1

I recently started using JFxtras IcalenderAgenda and learning how it functions, its appointments, the events...
So I created a table named planing, in the MySql database with columns like appointement_date, appointement_startTime, end_time, description, summary ...
my problem is that I don't know ( yet, understand) how can I save the details of an appointment created in JFxtras agenda into my database
to be more precise, it is not the connection to the database, but how can I extract the details of the created appointments after I press a button like save ...

I think my problem is that I don't understand what is an appointment from Agenda.appointment
i saw these functions of details extraction like (Appointment a)

a.getStartLocalDateTime()  
a.getStartTime()  
a.getSummary()  
a.getDescription()  

And I just want to use these

Thank You in Advance :)

1 Answers1

0

Agenda is a view component which is able to display any class that implements the Appointment interface that is defined inside Agenda. It is up to you to provide a class that does so.

https://github.com/JFXtras/jfxtras/blob/11/jfxtras-agenda/src/main/java/jfxtras/scene/control/agenda/Agenda.java

There are a few options to create that class.

  1. The easiest way is that your persisted class happens to implement the Agenda.Appointment interface, then you can simply provide Agenda with a list of those classes.

  2. If there is a difference for example the method names, you could provide a wrapper class that maps the Appointment interface methods to the one available in the persisted class.

  3. And finally you can use any of the AppointmentImpl* class in agenda, but then upon load you need to convert your persisted data to one of the AppointmentImpl*, and upon pressing Save back again.

I figure that the biggest question is how you get your data from the database. Do you use direct JDBC or something like JPA or EBeans?

tbeernot
  • 2,473
  • 4
  • 24
  • 31
  • thanks for the answer, I m using JDBC ( MySql JDBC driver ) for java 8 and I m not trying to get my data into the agenda! I m trying to extract the details for the created appointment into a string format so I can upload them into my Database – Adem Youssef Mar 16 '21 at 09:58
  • Then I don't understand the problem; if you have an appointment already, then you can just call the getters on the appointment and create a string out of it. Then use a SQL insert or update statement to store it in the database. – tbeernot Mar 16 '21 at 10:43
  • BTW, direct JDBC is not "the way to do it" in Java. Normally you would define a class and have a framework like JPA or EBean persist it in the database for you. That will make coding a lot easier. But if you want to do direct JDBC do consider one of the supporting libraries. https://stackoverflow.com/questions/7137929/lightweight-jdbc-helper-library-alternative-to-apache-commons-dbutils – tbeernot Mar 16 '21 at 11:03
  • thank you Sir for your time and effort , for the jdbc i already created a class for that has the `DriverManager.getConnection(url, login, pwd)` and all other needed function to connect on the DB, then i created a function in the calender `agenda.appointments().addListener(new ListChangeListener< Appointment>() { public void onChanged(Change extends Appointment> c) {...}` to extract the details that i mentioned before and it works!, except that it return it on the console ( yet more work needed to upload that on the DB) – Adem Youssef Mar 16 '21 at 11:23
  • it returns something like this in the console : – Adem Youssef Mar 16 '21 at 11:25
  • `Summary :zzzzzzz Description :aaaaaa Date :2021-03-16 Starts at :04:15:00 Finishs at :07:20:00 Localisation :zeaze` – Adem Youssef Mar 16 '21 at 11:25
  • my ultimate goal is to create a button so when i finish doing the creation, editing, and deleting in the agenda i simply click save and it will upload all of that to the DB it is getting better for sure but needs more effort if you can guide me or give me some hints would be thankful and appreciated – Adem Youssef Mar 16 '21 at 11:28
  • I know you have a long way to go. Maybe it is wise to first do the SQL statements yourself, then use one of the libraries that are mentioned in the link above. But in the end you probably want to persist classes directly and let the framework generate the SQL for you. Personally I prefer EBean https://ebean.io/ – tbeernot Mar 16 '21 at 11:42