Wednesday Aug 26, 2009

JSF 2.0, NetBeans 6.8, and GlassFish

Following are steps to get JSF 2.0 running on GlassFish, and can develop JSF 2.0 projects in NetBeans. Also, included are NetBeans project using JSF 2.0, and JSF 2.0 with some new Facelets functions.
Below is a screen shot of the JSF 2.0 selection step in NetBeans 6.8.

NetBeans 6.8 is packaged with GlassFish v3, which, I believe (I did not test), includes JSF 2.0.
Because I am running GlassFish V2, I followed the instructions to download the JSF JAR files to update my GlassFish for JSF 2.0:
Installing Mojarra 2.0.0 RC on GlassFish v2
\* download the Mojarra 2.0.0 RC binary bundle bundle from the project page.
- filename: mojarra-2.0.0-RC-binary.zip
\* backup your existing jsf-impl.jar found in GF_HOME/lib
\* copy the new jsf-api and jsf-impl JARs to GF_HOME/lib
\* edit your GF_HOME/domains/<domain-name>/config/domain.xml and
- add (or update the existing classpath-prefix) 'classpath-prefix="${com.sun.aas.installRoot}/lib/jsf-api.jar" to the java-config element
- Example: <java-config classpath-suffix="" classpath-prefix="${com.sun.aas.installRoot}/lib/jsf-api.jar" ... >
\* Restart the GlassFish server
Note, the above instructions from: https://javaserverfaces.dev.java.net/nonav/rlnotes/2.0.0/releasenotes.html

Install NetBeans 6.8:
\* To download NetBeans 6.8, click on 6.8 M1, from the NetBeans download page: http://www.netbeans.org/downloads/index.html
- Filename: netbeans-6.8_m1-java-windows.exe
\* Run the installation.

Now that you have a JSF 2.0 GlassFish version, and NetBeans 6.8, you are ready to develop JSF 2.0 projects.
\* Start NetBeans.
\* Select New Project/Java Web/Web Application. In the project form, enter:
- Project Name: jsf1
- Project Location: C:\\java\\jsf\\samples
- Click Next.
- The Server selected is your JSF 2.0 GlassFish version.
- Click Next.
- Check JavaServer Faces, which then displays JSF 2.0 configuration information.
- Click Finish.
\*\*\* You now have your first JSF 2.0 NetBeans Project ready to run.

Descriptions of the jsf1 project files, under the Projects tab: jsf1/Web Pages:
- forwardToJSF.jsp : the project's home page which uses the JSF Servlet URL Pattern (faces/) to forward the browser to the first JSF page:
<jsp:forward page="faces/template-client.xhtml"/>
- template-client.xhtml : JSF 2.0 page, which uses a Facelets template.
- template.xhtml : Facelets template
- In the directory jsf1/Web Pages/WEB-INF, are the configuration files: web.xml and faces-config.xml
\* Run the project.

There are sample JSF 2.0 code which can be downloaded in the Mojarra 2.0.0 RC binary bundle. I have built one and zipped it up for your convience:
Click here to download jsf2ajax.zip, a JSF 2.0 code sample NetBeans Project.

Enjoy JSF 2.0, Stacy Thurston, Sun Learning Services developer.

About

Tech event, training, business, in east and south Asia.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today