Dear Wiki user, You have subscribed to a wiki page or wiki category on "Shale Wiki" for change notification.
The following page has been changed by Hermod Opstvedt: http://wiki.apache.org/shale/ShaleAndClayTutorial ------------------------------------------------------------------------------ What happens here is that Maven will create a project based on Shale and Clay. The parameters are: - * archetypeGroupId â The archetype groupId<br/> + * archetypeGroupId â The archetype groupId[[BR]] - * archetypeArtifactId â The archetype artifactId <br/> + * archetypeArtifactId â The archetype artifactId[[BR]] - * archetypeVersion â The archetype version number<br/> + * archetypeVersion â The archetype version number[[BR]] - * groupId â The groupId of you project<br/> + * groupId â The groupId of you project[[BR]] - * packageName â The default package name of your project â included source is placed here<br/> + * packageName â The default package name of your project â included source is placed here[[BR]] - * artifactId - The groupId of you project <br/> + * artifactId - The groupId of you project[[BR]] After you have done his, a project will have been created for you in a directory with the same name as you gave for the artifactId. Move to this directory. @@ -39, +39 @@ After running this command a couple of files and a directory will be created, that is need for Eclipse. Your layout should look something like this: - ##URL: attachement:shaleclaydir.jpg Start Eclipse and open a workspace that points to C:\My projects\ShaleClay (or wherever you chose as a workspace for this project) @@ -49, +48 @@ Choose âFile->Importâ. In the next dialog select "General-Exisiting projects into workspace" attachement:shaleclaydir2.jpg - http://wiki.apache.org/shale/ShaleAndClayTutorial/shaleclaydir2.jpg You should the get the following: - http://wiki.apache.org/shale/ShaleAndClayTutorial/shaleclaydir.jpg + attachement:shaleclaydir3.jpg In the field "Select root directory" enter the name of you workspace or use the âBrowse..â button to navigate to it. Eclipse should now list all available projects. Select the ShaleClay project and hit the âFinishâ button. @@ -98, +96 @@ Lets take a closer look at these, starting with web.xml where we find these important declarations: - <!-- Override the default suffix for extension-mapped --> + <!-- Override the default suffix for extension-mapped -->[[BR]] - <context-param> + <context-param>[[BR]] - <param-name>javax.faces.DEFAULT_SUFFIX</param-name> + <param-name>javax.faces.DEFAULT_SUFFIX</param-name>[[BR]] - <param-value>.jsf</param-value> + <param-value>.jsf</param-value>[[BR]] - </context-param> + </context-param>[[BR]] - <!-- Select JSF State Saving Mode --> + <!-- Select JSF State Saving Mode -->[[BR]] - <context-param> + <context-param>[[BR]] - <param-name>javax.faces.STATE_SAVING_METHOD</param-name> + <param-name>javax.faces.STATE_SAVING_METHOD</param-name>[[BR]] - <param-value>client</param-value> + <param-value>client</param-value>[[BR]] - </context-param> + </context-param>[[BR]] - <!-- Clay Common Configuration Resources --> + <!-- Clay Common Configuration Resources -->[[BR]] - <context-param> + <context-param>[[BR]] - <param-name> + <param-name>[[BR]] - org.apache.shale.clay.COMMON_CONFIG_FILES + org.apache.shale.clay.COMMON_CONFIG_FILES[[BR]] - </param-name> + </param-name>[[BR]] - <param-value>/WEB-INF/clay-config.xml</param-value> + <param-value>/WEB-INF/clay-config.xml</param-value>[[BR]] - </context-param> + </context-param>[[BR]] - <!-- Clay Configuration Full XML view Resources --> + <!-- Clay Configuration Full XML view Resources -->[[BR]] - <context-param> + <context-param>[[BR]] - <param-name> + <param-name>[[BR]] - org.apache.shale.clay.FULLXML_CONFIG_FILES + org.apache.shale.clay.FULLXML_CONFIG_FILES[[BR]] - </param-name> + </param-name>[[BR]] - <param-value>/WEB-INF/clay-views-config.xml</param-value> + <param-value>/WEB-INF/clay-views-config.xml</param-value>[[BR]] - </context-param> + </context-param>[[BR]] - <!-- Clay XML View Suffix --> + <!-- Clay XML View Suffix -->[[BR]] - <context-param> + <context-param>[[BR]] - <param-name> + <param-name>[[BR]] - org.apache.shale.clay.XML_TEMPLATE_SUFFIX + org.apache.shale.clay.XML_TEMPLATE_SUFFIX[[BR]] - </param-name> + </param-name>[[BR]] - <param-value>.jsf</param-value> + <param-value>.jsf</param-value>[[BR]] - </context-param> + </context-param>[[BR]] These declarations (context-param) are used by Clay and the JavaServer Faces (JSF) implementation at startup. @@ -144, +142 @@ The are the Filter defintions. A filter is a Javaclass that will be called by the webcontainer on every request that comes into it (Actually only requests that match a certain predefined pattern â See filter-mapping below) - <filter> + <filter>[[BR]] - <filter-name>shale</filter-name> + <filter-name>shale</filter-name>[[BR]] - <filter-class> + <filter-class>[[BR]] - org.apache.shale.application.faces.ShaleApplicationFilter + org.apache.shale.application.faces.ShaleApplicationFilter[[BR]] - </filter-class> + </filter-class>[[BR]] - </filter> + </filter>[[BR]] - <!-- Shale Application Controller Filter Mapping --> + <!-- Shale Application Controller Filter Mapping -->[[BR]] - <filter-mapping> + <filter-mapping>[[BR]] - <filter-name>shale</filter-name> + <filter-name>shale</filter-name>[[BR]] - <url-pattern>/*</url-pattern> + <url-pattern>/*</url-pattern>[[BR]] - </filter-mapping> + </filter-mapping>[[BR]] Here Shale is wired into the request processing. In this case the Shale filter will be invoked on every request because of the /* pattern. Next comes the Servlet definitions. These servlets are instandiated by the webcontainer at startup because they have a load-on-startup set. These Servlets are responsible for setting up various session and application scoped parameters based on the configuration files, and also for receiving all requests (That match a pattern) that comes into the webapplication - <!-- JavaServer Faces Servlet Configuration --> + <!-- JavaServer Faces Servlet Configuration --> [[BR]] - <servlet> + <servlet> [[BR]] - <servlet-name>faces</servlet-name> + <servlet-name>faces</servlet-name> [[BR]] - <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> [[BR]] - <load-on-startup>1</load-on-startup> + <load-on-startup>1</load-on-startup> [[BR]] - </servlet> + </servlet> [[BR]] - <!-- JavaServer Faces Servlet Mapping --> + <!-- JavaServer Faces Servlet Mapping --> [[BR]] - <servlet-mapping> + <servlet-mapping> [[BR]] - <servlet-name>faces</servlet-name> + <servlet-name>faces</servlet-name> [[BR]] - <url-pattern>*.jsf</url-pattern> + <url-pattern>*.jsf</url-pattern> [[BR]] - </servlet-mapping> + </servlet-mapping> [[BR]] Here the JSF Servlet is defined. It will be the handler of all requests that end with .jsf Finally we tell the webcontainer how to handle our pages going back to the client. Since .jsf is not a well known mime-type, we need to inform the client that it should handle it as text/html. - <mime-mapping> + <mime-mapping>[[BR]] - <extension>jsf</extension> + <extension>jsf</extension>[[BR]] - <mime-type>text/html</mime-type> + <mime-type>text/html</mime-type>[[BR]] - </mime-mapping> + </mime-mapping>[[BR]] The next file we look at is the faces-config.xml file. This file governs the setup of JSF. It is normally divided into three sections @@ -191, +189 @@ First in out file we define which languages this application supports; Norwegian(no) and English(en), and that the default is English. + The next section tells what should happen for various events in the application. We will closer into this a bit further down. + + The last Section tells which beans JSF should manage for us. We will get closer into this a bit further down. + + The next file we look at is clay-config.xml. This file contains definitions of our Clay components, amongst other the template that we use to construct our pages with and at this moment should be the only one defined. + + Then we look at clay-views-config.xml. Here we define how the various pages on our site are build (composed), based on the components that we have defined in the clay-config.xml file. We have defined 3 separate pages. As you can see from the declarations are these based (extends) on the component âbaseLayoutâ and that we override (reassign) the definitions of âtitleâ and âbodyContentâ in each definition. + + We have now been through the main parts that make up a Shale/Clay application. We will now take a closer look at the pages we are going to use in our application. The first one being the template which makes up the look&feel of our application (you can have more than one template in your application) . This template is located in the folder âtemplatesâ and is named standard.html. + + If we take a closer look at it we see that it is devided into sections. These sections are the parts of the page that naturally lend tem selves to a functionalitygroup and as such are candidates for reuse. This is known as templating. The page is formatted as a âliquid designâ layout. If you want to read up on this, a good place to start is [http://www.mardiros.net/liquid-css-layouts.html/ Carmen Mardios] +