I was looking at some of the examples from the Netbeans site and trying to find a basic example to demonstrate. After looking at the examples I found on the web, I thought I would create a quick example myself.
First I created a project in Netbeans. I picked Java Library. Then I selected create entity classes from database and used the sample JavaDB database that comes with Netbeans. It prompted me to create the persistence.xml and I accepted the defaults.
Next I created a Web project in Netbeans. During the project creation wizard, I selected Visual JSF to include the JSF and Woodstock libraries.
Next I clicked on the properties for the project and added my library to the project.
Next I created a created a new persistence.xml file. After it was created, I modified it so that it would include the specific entity classes that I created in the library project.
Note: This is required otherwise the entity classes will not be detected.
Next I added this code snippet to SessionBean1
This fetches my data so that I can display it later in a table.
Next I compile the project (no deployment yet). This refreshes the beans so that I can manipulate them visually.
Next I create a table on Page1 from the palette. I right click the table and select binding and point it from the DefaultTableProvider to customers in the SessionBean.
Now I deploy it. Poof the magic is complete.
The link to my example Netbeans 6.5.1 project on Bitbucket: SamplePersistenceWeb
Saturday, March 01, 2008
JPA and Web Examples using Project Woodstock and Netbeans
Labels:
Java
,
JavaDB
,
JEE5
,
JSF
,
Persistence
,
Programming
,
woodstock
Subscribe to:
Post Comments
(
Atom
)
Popular Posts
-
Introduction This article is not another diatribe to tell you the importance of unit testing. I think we can all agree that it is important...
-
A friend of mine asked me if there was a list of reserved words in EL and JSF. He had previously looked for it, and after some Google search...
-
I saw a question posed on stackoverflow called Trouble with Primefaces 3.0.M2 SelectOneMenu Ajax behavior and I had just done an example a...
-
I was working on a couple of SSL based issues when I made a couple of observations. The default self-signed key generation in Java does not ...
-
This is an example on how to make a system call to the local operating system to execute external programs. This example was written to work...
-
We have been doing a lot of work lately with PrimeFaces. A common set of questions comes up about displaying <p:dialog/> boxes on a pa...
-
I was asked earlier today how to reset fields in a JSF application, if the validation fails. In his case, he had a Richfaces table which had...
-
Image by quasarkitten via Flickr The basics for creating a Maven archetype can be found in the Maven - Guide to Creating Archetypes . The ...
-
Previously, I posted an example of how to use JSF 1.2 with form based authentication (j_security_check). In this example, I use JSF 2.x to...
-
Abstract A common use case is to iterate over a collection of elements, and display them on a page. In the world of JSP, we would use a Ja...
11 comments :
That's pretty cool, thanks for posting. However, I'm struggling to figure out how to use Woodstock/Visual JSF in Netbeans 6.0 with EJBs that are in an EJB project, in an enterprise project setting. Can this even be done? There seems to be a huge lack of integration there!
Thanks!
Certainly!
I use EJBs all the time in my projects. I will see if I can write a simple example and post it.
Any luck? ;)
I hear a near-future release of Netbeans will allow visual drag/drop w/ JPA and Woodstock?
I have the follow error
xception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/incidencia
Error Code: 0
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
The exception is an indication that you do not have the mySQL driver installed. You need to add the driver to your project, or ensure that the mySQL driver is in the lib directory on the server.
hi you said "u need to add the Mysql driver" but where? in a java class library or a web project?
thanks
why do you have 2 projects? art sake? it works just fine in a single Web project... at the first glimpse.
Anyway great tutorial... I tried the much detailed tutorial from netbeans and i failed at the binding data stage... simply the property in SessionBean1 refused to apeare.
The mySQL driver needs to be a part of the project.
I split the project up so that I would have a separation of concerns. I could then reuse the JPA portions in other tutorials.
You are right. You could combine them into one project if you wanted. You do have the source code. ;-)
Hi,
I was eager to develop JSF/EJB together as well - I wonder - this page is almost the only resource about this and Yeary's saying that 'I use EJBs all the time in my projects. I will see if I can write a simple example and post it.
' is the only success story about NB as far as I have read, I guess Yeary talked about NB, not about e.g. Oracle JDeveloper, where this integration is perfect.
So - for me the main problem is - I am using NB 6.1 and there is said in the help, that EJB drag and drop for tables is available from Services page 'Enterprise Java Beans' item (in NB help there is even the picture which shows that this is really a truth) - but for my installation and I have tried 2 NB6.1. isntallations on 2 separate compouters (XP and Business Vista) and I applied all the latest updates (as of today) - but still - there is no item 'Enterprise Java Beans' in the services page, but there is item 'Enterprise Beans 2.x' instead and naturally, it doesn't allow me to import EJB 3.0 beans from application client in the IDE. So - I will go this exmple - maybe I can make integration by hand. This application would be greate help, because there is no description ho to use EJB from Visual Web Faces in the JSP code level either.
I would stronlgy suggest to make dome tutorial about this - everybody is trying to do some nice and up-to-date architecture for his job assignments, or for study projects, but there is so few materials for this. I guess - programming is about creativity and not about hacking IDE to achieve the same result which can be achieved in some minutes if good documentation is at place.
I am saddened that Project Woodstock has been abandoned by Sun. There will likely be no drag-n-drop functionality for Woodstock and JPA.
Post a Comment