11 Mart 2008 Salı

Starting Web Application Development 2



I have recorded the development phase of “Hello World" JSF application but as you see it's not readable. You may reach the readable version of this video from my colleague Mehmet Gürsul's personal web site.


Now I’ll try to identify the steps of the “Hello World" JSF application.
Step 1 - Setting the workspaces JRE: We have to set the JRE of the workspace with the downloaded SDK 6’s JRE. Of the record, now SDK 6 is open source and you can attach the source files to view the code behind the class implementations. In the developing process I will be giving all the necessary source files of the related open source API’s.

Step 2 - Creating dynamic web project: By using project wizard we crate a new dynamic web project with using the JSF1.2 capabilities. In the wizard we have to modify some of the default values.

We have to increase Java Server Faces 1.1 to 1.2 and Dynamic Web Module 2.4 to 2.5 as the version 2.4 doesn't support Java Server Faces 1.2.

Step 3 - Configuring classpaths: After project is created we must add required jar files to project lib folder. Now required jars are only MyFaces implementation jars and their dependencies. You can find these jars MyFaces lib folder. To run our application we need one more jar that name is jstl.jar and standart.jar, you can find these jars tomcat\webapps\examples\WEB-INF\lib folder.

I'm sure you could easily add a server and create sample jsp to run our application. I want to talk about little what happened backround. Our faces-config.xml is empty yet. web.xml has two significant attributes, one of them is <servlet> and the other one is <servlet-mapping> .

<servlet>

<servlet-name>Faces Servlet</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1&lt:/load-on-startup>

</servlet>



When an event occurs click a button for example, the event notification is sent via HTTP to the server. On the server is a special servlet called the FacesServlet. Each JSF application in the Web container has its own FacesServlet. For JSF requests to be processed, they must be directed to the FacesServlet.

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>

</servlet-mapping>



This means that the URL of every request must contain the /faces/ pattern, as specified in the url-pattern element under the element.

We will add many capabilies in our sample project step by step. Every steps may come additional elements web.xml and faces-config.xml or new configuration files. I try to explain every element shortly.

Next step is connecting database and add simple domain object to database.

Hiç yorum yok: