Should it be possible to use sql data and display it in the

Community Driven Extensions Project
Post Reply
Posts: 1
Joined: 02 Jan 2017, 11:21

05 Jan 2017, 10:12

I am using Netbeans 8.2 with Primefaces 5.2 and Primefaces Extensions 4.0. I also have a local glassfish server and a local MySQL server.

I have succesfully loaded displayed a timeline with data by using the code and xml file here: ... ange.xhtml
I can use the data from the database in a sorted datatable as shown here ... sort.xhtml
However when i try to load data from my SQL server the timeline component do not display at all and I was wondering if it should be possible to use sql data and display it in the timeline component?

I first tried with Primefaces 6.0 and Primefaces Extensions 4.0 but then the timeline component would not work at all.

My index.xhtml:

Code: Select all

 <html xmlns=""
      xmlns:h="" xmlns:f=""
    <h:body style="padding:10px 10px 10px 10px; border-style:solid;">
        <pe:timeline value="#{limitTimelineRangeView.model}"
             height="180px" showNavigation="true"></pe:timeline>
Below is the code for the class. I have tried to use @Dependent, RequestScoped,ViewScoped and ApplicationScoped as well. I do not recieve any error messages and the site itself will display with other components in the web-browser.
I use chrome and have tried to display the site in Firefox aswell.
The events get loaded to the timeline and is printed out with it's data in the console as well.

Code: Select all

public void init() {
      Connection connection =null;
      model = new TimelineModel();
        System.out.println("Events from Db");
        String serverName = "jdbc:mysql://localhost:3306/mysql?zeroDateTimeBehavior=convertToNull";
        String mydatabase = serverName;
        String url = mydatabase;
        String username = "xxxxxx";
        String password = "xxxxxx";
        connection =DriverManager.getConnection(url, username, password);
        SimpleDateFormat date = new SimpleDateFormat("YYYY");
        Statement stmt = connection.createStatement();
        String sql = "Select * FROM eventsdb ORDER BY date";
        ResultSet set = stmt.executeQuery(sql);
        // Loop to get SQL data
                String title = set.getString("title");
                String id = set.getString("id");
                String information = set.getString("information");
                String dateFromDb = set.getString("date");
                Calendar time =Calendar.getInstance();    
                Date d = date.parse(dateFromDb);
                t = new TimelineEvent();
                t.setData("Title:"+" "+title+"\n"+"Information:"+" "+information+"\n"+"Id:"+" "+id);
                model.add(new TimelineEvent("Title:"+" "+title+"\n"+"Information:"+" "+information+"\n"+"Id:"+" "+id,time.getTime()));
                System.out.println("After "+getModel().getEvents());
         catch (ClassNotFoundException | SQLException | ParseException ex) {
             Logger.getLogger(LimitTimelineRangeView.class.getName()).log(Level.SEVERE, null, ex);
          try {
          } catch (SQLException ex) {
              Logger.getLogger(LimitTimelineRangeView.class.getName()).log(Level.SEVERE, null, ex);
    public TimelineModel getModel() {
        return model;
Thanks for any feedback and let me know if i should clarify anything.

User avatar
Posts: 619
Joined: 22 Apr 2013, 15:48

05 Jan 2017, 14:29

This same exact code above works if you point it at a Datatable?

Does your limitTimelineRangeView have @Managed or @Named on it depending on whether you are using straight JSF or CDI?

Have you put logging in the init() method to make sure it is actually being called by your timeline?

Have you taken SQL out of the equation and just created a bean with hard coded values to prove the timeline is working? Then replace with your SQL call?

But to answer your original question this should ABSOLUTELY work whether it is SQL or not, JSF doesn't care how you fill your POJO's.
PrimeFaces Extensions Developer
GitHub Profile:
PrimeFaces Elite 6.2 / PF Extensions 6.2.3

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Baidu [Spider] and 2 guests