Conrtibuted by: Jay Mahadeokar.
NetBeans 6.1 comes up with new JSF Crud generator. Lets try and explore..
I must confess I have no prior knowledge of JSF and learned it through the tutorial, “Using Java Persistance API within a Visual Web JSF Application”. So if any of concepts are wrongly presented here please excuse me.
In the above tutorial we learn first to create a table in Database and then use NetBeans 6.0 JSF functionality to create a page that will simply display table contents. The tutorial thus guides us in making Hello World example for Web Application through NetBeans.
If you go through the tutorial you will realize the steps and coding that is required to simply display the data from one table.
Here we will explore the new JSF crud generator feature in NetBeans 6.1 and see for ourselves how easily we can create a database application using its features.
Three steps in creating the Application:
1. Setting up the web project:
1. We will use the sample derby database that comes up with NetBeans for our application. (jdbc:derby://localhost:1527/sample) To connect to database: Goto services tab >> right click on app on App >> connect.
2. If you expand the tables node, following tables will bhe seen:
3. Create a new Web application. In the frameworks window click on Visual Web Server faces.
Now the project has been set up.
2. Creating the Entity classes from database:
3. Creating JSF pages from entity classes:
4. A new file WelcomeJSF.jsp will be added to the directory. Open it and try to understand what is actually happening. Also explore the new files created in the Sources folder. You will realize the amount of coding the generator does for us.
5. Now just Right Click WelcomeJSF.jsp and say Run File. That’s it!!
Thus options for selection, Editing, Deleting, Adding new data all are provided for us. Easily navigation links are also provided.
Thanks to the new JSF crud generator in NetBeans IDE 6.1 we are just clicks away from representing our whole database through robust and well designed web pages. So if you have a database ready and want to create a web application representing it, think of NetBeans 6,1 and JSF Generator will be at your service.
Again.. Hats off to NetBeans!!