These notes follow on from my previous posting regarding getting Eclipse Galileo and glassfish v3 configured on OSX
In this post, I'm going to quickly outline the necessary steps for getting a very simple JSF project running within Galileo.
First, you'll need to download Mojarra and unpack it somewhere.
Go to the Java EE perspective and create a new project to get the "New Project" wizard to appear. Expand out "Web" and select "Dynamic Web Project". Give the project a name.
The "Target Runtime" should be GlassFish v3 Prelude, The Dynamic web module version should be 2.5 and select JavaServer Faces v1.2 Project as your configuration option.
Choose "Next" for the Source folders option and "Next" for the Web Module settings.
For the JSF Implementation Library settings, click on the "Manage Libraries" link (it's the icon on the right, just below the "Type" dropdown list), Select "New", create a name (e.g. "Mojarra") and check the System Library checkbox. Select OK and then highlight the library you just created and select "Add JARs". Navigate to the folder where you unpacked Mojarra and go to its lib folder. Select both jsf-impl.jar and jsf-api.jar and then select "Open".
Both JARs should be visible under the library you created. Select "OK" and now check the library you just created and select "Finish". You should now be ready to start coding.
To create a simple JSF example project:
1. Right-click on your Java Resources:src folder and select New > Other. Expand out "General" and select "File" and select "Next". If it asks you to select a "parent folder", just select the src folder for the project you just created. The file should be called messages.properties. In that file, add a line: greeting=JSF is working and save the file.
2. in WebContent/WEB-INF/web.xml, find the <servlet-mapping> and make sure it looks like this:
3. Right-click on WebContent and select "New" and "JSP". Name it "index.jsp". You should have a basic html template page.
In the body of the template, paste in:
4. Create a folder called "faces" under "WebContent"
5. Create a New JSP file inside the "faces" folder. Call it greeting.jsp (note the file extension is jsp, *not* jsf)
Below the doctype of greeting.jsp, paste in:
And in between the body tags, paste in:
Right-click on the project and select Run As > Run on Server. Ensure you're running it on GlassFish Prelude v3 (if you are working from my previous post). You should now be able to go to localhost:8080/%the_name_of_your_project% and you should see the message from the config file: "JSF is working".
The project can be found here: http://jsf-examples.googlecode.com/files/jsf-greeting.zip if anyone wants to check out the folder structure
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2009
(37)
-
▼
June
(10)
- Daisy CMS - connecting a JMS listener to the repos...
- Daisy CMS - customising the footer of the editor p...
- Daisy CMS - allowing attributes in the SimpleDocum...
- JSF - ensuring your [xhtml] pages load with a text...
- Eclipse Galileo (3.5): Creating and running a JSF ...
- Using Eclipse Galileo to develop JSF applications ...
- SVN Web view - looking at older revisions
- Notes on setting up mod_proxy on apache 2.2 for pr...
- Addressing stability issues when running Eclipse 3...
- Forcing glassfish 2.1 to start-up with JDK1.6 (OSX)
-
▼
June
(10)
6 comments:
Thanks a lot, Alex. This helped.
Glad you found it useful :)
thanks dude. works like a charm.
Thanks for this tutorial, it got me up and running pretty quickly.
Dude,
Ur just amazing. Especially the way u have given importance to small things are awesome. Keep it up buddy.
If you got an java.lang.ClassNotFoundException:
javax.servlet.jsp.jstl.core.Config
You have to find and copy it to JSTL.jar to tomcat lib folder .. then it works fine.. Nice tutorial.... thanx....
Post a Comment