Problem in populating tableview with database data using javafx MVC architecture.

Problem in populating tableview with database data using javafx MVC architecture.

This code is working in simple javafx appliction without MVC architecture. Here i want to populate tableview as it is with database table data. Here the problem is i am getting all elelments of every row in each column of tableview.

Controller:

 @FXML private void handleButtonAction(ActionEvent event) throws Exception
    {
       ObservableList tl = tmd.t_model();
       ObservableList<ObservableList> rl = tmd.t_row();

       for (Object val : tl) 
            {
                TableColumn col = new TableColumn(String.valueOf(val));
                System.out.println("FXMLColumn j[" + (String.valueOf(tl)));

                System.out.println("Column col[" + (String) tl.get(0) + "] ");
                col.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<ObservableList, String>, ObservableValue<String>>()
                {
                    public ObservableValue<String> call(TableColumn.CellDataFeatures<ObservableList, String> param)
                    {
                        return new SimpleStringProperty(param.getValue().toString());
                    }

                });
                tableview.getColumns().addAll(col);
            }
         tableview.setItems(rl);
    }    

model;

 public ObservableList t_model() throws Exception
   {
       Connection c ;
            data = FXCollections.observableArrayList();
        try{
                c = Dao.getCon();
                String SQL = "SELECT * from Mem_bill";
                ResultSet rs = c.createStatement().executeQuery(SQL);    

                    for(int i=0 ; i<rs.getMetaData().getColumnCount(); i++)
                    {
                        data.add(rs.getMetaData().getColumnName(i+1));

                    }
                }
            catch(Exception e)
            {
               System.out.println("problem in t_model"+e.getMessage());
            }
                  return data;
   } 
   public ObservableList t_row() throws Exception
   {
       Connection c ;
       ObservableList data1 = FXCollections.observableArrayList();
       c = Dao.getCon();
            String SQL = "SELECT * from Mem_bill";
            ResultSet rs = c.createStatement().executeQuery(SQL);
             while(rs.next())
            {
                ObservableList<String> row = FXCollections.observableArrayList();
                for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++)
                {
                   String rw=rs.getString(i);
                   row.add(rw);
                   //data1.add(row);
                   System.out.println("ROW BREAK :"+rw);
                   System.out.println("VAL I:"+i);

                }

                data1.add(row);
             }
             return data1;
   }`print("code sample");`
View Answers

July 14, 2014 at 5:06 PM

This is possible in javafx application without MVC architecture. Need help in implementing same in MVC

Ads









Related Tutorials/Questions & Answers:
Problem in populating tableview with database data using javafx MVC architecture.
Problem in populating tableview with database data using javafx MVC architecture.  This code is working in simple javafx appliction without MVC architecture. Here i want to populate tableview as it is with database table data
Problem in populating tableview with database data using javafx MVC architecture.
Problem in populating tableview with database data using javafx MVC architecture.  This code is working in simple javafx appliction without MVC architecture. Here i want to populate tableview as it is with database table data
Advertisements
How to display data from database in a TableView
How to display data from database in a TableView  I need to populate a TableView (JavaFx) with database items. I designed the TableView in JavaFx... at this. The classes: This is the Class that creates the database data object: import
populating textbox value from the database using onchange function,
populating textbox value from the database using onchange function,  hi, Everyone I have a problem regarding poulatinng the value in textbox after... dynamically from the database(mysql). after selecting the value from the dropd
using jsp and servlets andin Mvc architecture
using jsp and servlets andin Mvc architecture  how to insert a form data in different tables, that means education details in education table, address details in address table,like that and finally if we fetch all must come
online book store by using MVC architecture
online book store by using MVC architecture  Tarzan book store decided to go online to increase itsā?? revenues and provide itsā?? customers a way... and complaint with MVC architecture
How to display data from database in a TableView via Hibernate
How to display data from database in a TableView via Hibernate  I need to populate a TableView (JavaFx) with database items. I designed the TableView in JavaFx Scene Builder. So far the TableView does not change at all and only
Query for generating Stock Report Using MVC architecture in j2ee
Query for generating Stock Report Using MVC architecture in j2ee  ... some data (current stock=(summation of)watch Quantity in WATCHMASTER... tables with data is: WATCHMASTER { watchid varchar(30), watchname varchar(20
Problem in accessing data from Database
Problem in accessing data from Database  hi..... i'm making a project on servlet and jsp with ms access 2007 at the backend. One field in my database... in currency column and then try to retrieve data using my servlet coding
MVC Architecture In Java
2 (MVC) Architecture : Applications are developed using MVC (Model-View.... These are as : Using the MVC architecture we can make our application loosely...MVC Architecture In Java In this section we will discuss about the MVC
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc framework???  I ve solved this problem based on the Product Search Application. Those who need this concept and code segment kindly copy it. Thanks and All
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from the database using servlet on the jsp page and there is checkbox corresponding each row but the problem is that i am not fetching data in any textboxes so how
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database
Spring MVC and Hibernate with DWR 3 -- Configuration Using MySQL Database  How to configure Spring MVC and Hibernate with DWR 3, Simple example -- reading a table, editing-deleting and adding new rows
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai... it to database in single hit user.jsp <form action="UserServlet" method="post... set to bean and pass bean to dao insert() and insert into database thank u
problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting output "Record has been inserted", 1.no data in the table(sample) public
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
retrieve data from database using jsf
retrieve data from database using jsf  Hello I want an example of source code to retrieve data from database i have a database (oracle) name as db1 it's contain table 'author' composed of three columns idauthor(primary key
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
how to insert data into database using jsp & retrive
how to insert data into database using jsp & retrive  Hello, I have created 1 html page which contain username, password & submit button. in my oracle10G database already contain table name admin which has name, password
a complete project on spring web mvc using oracle database in netbeans ide 7.0
a complete project on spring web mvc using oracle database in netbeans ide 7.0  dear sir , i want a complete tutorial on the title matter.please sir help me . any full developped project based on shopping cart can
how to insert data in database using html+jsp
how to insert data in database using html+jsp  anyone know what... and database name. Here machine name id localhost and database name..."; // declare a connection by using Connection interface
Populate a combo box using data from a database
Populate a combo box using data from a database  Hi Guys, In need... to populate the first one, and then how to send the data off to a servlet and preform a search on the database for the values I want, but then how do I pass that back
retrive data from database using jsp in struts?
retrive data from database using jsp in struts?   *search.jsp* <%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
How to get the data from the database using Servlet or JSP program
the problem   Get data from database using servlet Retrieve data from database using JSP Get data from database using JSP...How to get the data from the database using Servlet or JSP program  
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql. I tried using Ajax from your example. But for some browser it does not support
sending data to google chart api from mysql database using java
sending data to google chart api from mysql database using java  how to send data from mysql database to google chart api using java
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance

Ads