Posts Tagged ‘eclipse’

Creating And Running JSF Project

Sunday, August 2nd, 2009

These notes follow on from my previous posting regarding JavaServer Faces Technology – JSF. 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 Apache Tomcat v6.0, 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:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

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:
<jsp:forward page=”/faces/greeting.jsf” />

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)

6. And in between the body tags, paste in:
<f:view>
<f:loadBundle basename=”messages” var=”message”/>
<p><h:outputText value=”#{message.greeting}” /></p>
</f:view>

7. Run it!!

Eclipse Configuration for Tapestry

Wednesday, January 30th, 2008

After I wrote an article about Tapestry, maybe it’s time to write about configuring our IDE so it can be used for developing Tapestry application. Why I need an IDE? Because it can help me more, can make me easy to developt an application. Maybe other choose Netbean or Sun Studio as his IDE, but I think it’s doesn’t matter what the IDE as long as the developer on comfort mood.

(more…)