|
|
||
Dru Devore's BlogCommunity: NetBeans ArchivesJSF Tables with databases in NetBeans 6.0Posted by ddevore on February 05, 2008 at 06:42 PM | Permalink | Comments (4)This is an addition to the JSF Visual Web JavaServer Faces in NetBeans Tutorial. For this information to be useful to you you will have to have a JSF Visual Web JavaServer Faces project created. To create the project please refer to the earlier blog. This is the project I will be working with in this tutorial. Empty TableThis is what you would do to start with most of the components in JSF. First open Page1.jsp and you will see the Design selected with the nice grid.
The next step is to select the Table from the Palette and click in the Designer. At this point you will have a page that looks like this.
If you run the project at this point you will get a page that looks just like the Designer above. This is because the default table data object DefaultTableDataProvider provides some data by default. The next step is to put some data into the table that is not simply the default. Database data in TableFor this part you will need a database connection defined, please check here to create a connection. Once the database is defined open the page designer with the table in it and select the Services tab. For this tutorial I have a database named JSFTutorial in MySQL with a table named address.
I will be using the address table, since it is the only table I currently have defined. To bind the JSF table to the address table simply drag and drop the table from the Services tab to the JSF table in the designer. You will now be asked to choose a target, select table1. Once do this you will see the table change to reflect the same number of rows as the address table with the same names as the columns.
That is all there is to binding a database to a JSF Table in NetBeans 6.0. You can now change the column names and the table name by simply clicking on them or selecting the JSP tab of Page1 and change the headerText attributes. You can also select the table and check out the properties and see what they do, pagination is really cool. Next time I will discuss how to use different types of data for the table. JSF Visual Web JavaServer Faces in NetBeans TutorialPosted by ddevore on February 02, 2008 at 07:38 AM | Permalink | Comments (1)I recently started working with JSF for more than simply messing around with the components. In performing this work I have found that some of the information needed to develop JSF seems to be missing or hard to find. Because of this I have decided to write up what I have found to pass along the joy of JSF. Because the tutorials for working with Visual Web JavaServer Faces in NetBeans will require a project I will start by describing how to create a project. This should work in pre 6.0 but I have used 6.0 and the latest 6.1 dev version for this blog. Create the ProjectSelect File -> New Project. In the dialog select Web category and Web Application project then click Next.
In the next dialog give the project a name, I named mine JSFTableTutorial, and keep the default for Server, Java EE Verion, and Context Path. Then click Next.
In the final dialog select Visual Web JavaServer Faces for the framework and please change the Default Java Package, mine is com.jsf.tutorial yes I know it is not a good package name but it is better then the default jsftabletutorial. The rest leave as the defaults.
When you get done you will have a view in NetBeans similar to this.
This view shows the designer and the palette also in case you are unfamiliar with the NetBeans designer. If you didn't get here from one of the tutorials on using JSF components you may be wondering why I wrote this. The reason is because I am writing multiple tutorials on using JSF components which all will need a project so here it is. Please check back for a list of tutorials on using JSF components. | ||
|
|