Question: How do I get
started with PrimeFaces in NetBeans?
Response: First of all,
PrimeFaces is a JSF(Java Server Faces) Framework. JSF is a UI framework created
to ease User Interface creation in Java Web Application development. There are
a number of JSF frameworks e.g PrimeFaces, ICE Faces, Rich Faces, Oracle ADF
e.t.c.
We shall Use NetBeans 7.3 to
get a hello world application with PrimeFaces 3.4. Note that PrimeFaces 3.4 is already part of NetBeans 7.3. You might only need to download PrimeFaces if you want a different version from that already provided in NetBeans. If you have a higher version of NetBeans, then you might have a higher or similar version of PrimeFaces which is fine.
Requirements: You only need to have NetBeans 7.3 up and
running on your computer.
Step 1: Choose
Project. Open netbeans and Go to File->New Project. A New Project window will pop up. Choose Java Web-> WebApplication . If you are running NetBeans for
the first time after Installation, you might see some extra step as NetBeans
tries to activate the Java web environment, so don't worry. Click Next.
Step 2: Name and
Location. In the ProjectName put PrimeFacesHelloWorld.
Click Next. ProjectName is the
name of your project, so it can be anything. Location is where it will be
stored on your computer, so you can change the location by clicking browse if
you want.
Step 3: Server and Settings. On the Server, Choose GlassFish Server 3.1.2.,
Java EE version is Java EE 6 Web, Optionally tick "Enable Contexts and
Dependency Injection". Click Next. If you are using another version of NetBeans, you
might have a different version of GlassFish. Its fine. You are free to
use another Java EE server if you know how to, but since GlassFish is the
default for NetBeans, we use that for this tutorial. For a hello word
application like this, Contexts and Dependency Injection (CDI) might not count
but later if you are to do a bigger application, you might need it. So, Its no
problem if you don't tick it for now.
Step 4: Frameworks.On Frameworks, tick Java Server Faces.
Below, on Java Server Faces Configuration, select PrimeFaces. If you want to see the version of
PrimeFaces you have, Click more. This also helps if you have more than one
versions of PrimeFaces installed. NetBeans 7.3 has PrimeFaces 3.4 already
installed. So, all you have to do is just tick it and your application will
automatically be configured to use PrimeFaces. After all this, click Next
Step 5: Run. Right Click PrimeFacesHelloWord(with a blue round Icon)
and Click Run. At this point,
your application is already created. The application already has 2 Webpages. i.e
index.xhtml and welcomePrimefaces.xhtml. If you notice
under libraries, you can see primeFaces 3.4.jar. You can also right click
index.xhtml and Run.
Step 6: You have arunning application in the browser. The Index page has a link(PrimeFaces welcome Page ). Click
this link and you will see a PrimeFaces page.
This note is optional. You don't have to read it to get the application to run but the information might be helpful.
If you want to use another version of PrimeFaces say PrimeFaces 3.5, just download the jar and after creating the Java web Project with JSF activated, right click libraries and add the Jar.
Or Go to Tools-> Ant Libraries->New Library ->Library Name(The name for the library you are adding-your own naming)->Add JAR/Folder->Browse for the Jar you downloaded and add it(The jar will be added under the library name you just created). When you add a library here, It will be globally available so whenever you wish to add it in the project, you will always find it on the list of jars(after creating the project right click libraries ->Add library->you will see a list of global libraries and the library you added in ant libraries will be on the list), and also for PrimeFaces You will find it on the List when you are creating a PrimePaces application under more in the NetBeans Wizard.
Note: Images are coming soon. But if you follow well, you can have your helloworld program running. Let me know if you have any issues or any questions or even suppliments. Thanx.