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

------------------------------------------------------------------------------
  
  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)
+ 
+ For Eclipse you now need to import the newly created project into the 
workspace:
+ 
+ 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
+ 
+ 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.
+ 
+ You may see a red cross on your projectname if you have not defined the maven 
classpath variable “M2_REPO”. You ca add it under "Window-preferences" and 
then "Java-Build Path-Classpath Variables"
+ 
+ attachement:shaleclay4.jpg
+ 
+ Press the "New..." button. In the next dialog type inn M2_REPO in the name 
field and in the ”Path:” field you enter the path to your local Maven2 
repository. Press "Ok" and "Ok" again in the next dialog.
+ 
+ attachement:shaleclay5.jpg
+ 
+ Eclipse will then inform you that it has to rebuild the workspace. Press the 
"Yes" button.
+ 
+ If you still have a re cross after it has recompiled, check the default Java 
version in Eclipse. If you have Java5 as standard the cause is the 
compiler-level is mismatched with what Maven set when it generated the project. 
Go to the problems view, right click on the message and choose “Quick Fix”
+ 
+ attachement:shaleclay6.jpg
+ 
+ Select "Change Java compiler level to 1.4" and press “Ok”.
+ 
+ Your project should now compile ok. Now comes the time to look at the project 
it self and how it is organized. If you expand your project it should look 
something like this:
+  
+ attachement:shaleclay7.jpg
+ 
+ In the Java sourcefolder (src/main/java) under the packagename you provided 
you should find two classes:
+ Person og TestVC. 
+ 
+ In the resources folder (src/main/resources) you will find three property 
files. This is actually one property file with two language provisions of it. 
These can be identified by their nameextention.
+  
+ In the web sources folder (src/main/webapp) you will find several folders:
+ 
+ The folder ”images” contains the images and backgrouns that are used for 
the site.
+ 
+ The folder ”pages” contains standard definitions (defaultxxx.html) of the 
various parts tghat make up the site, along with som specific definitions 
(pageXbody.html)
+ 
+ The folder “templates” contains the template that we are using to build 
our site – we will return to this shortly 
+ 
+ The folder ”theme” contains the cascading stylesheet we use to format our 
site.
+ 
+ In the folder ”WEB-INF” we find all the important configurationfiles.
+ 
+ attachement:shaleclay8.jpg
+ 
+ Lets take a closer look at these, starting with web.xml where we find these 
important declarations:
+ 
+    <!-- Override the default suffix for extension-mapped -->
+    <context-param>
+       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+       <param-value>.jsf</param-value>
+    </context-param>
+ 
+    <!-- Select JSF State Saving Mode -->
+    <context-param>
+       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+       <param-value>client</param-value>
+    </context-param>
+ 
+    <!-- Clay Common Configuration Resources -->
+    <context-param>
+       <param-name>
+          org.apache.shale.clay.COMMON_CONFIG_FILES
+       </param-name>
+       <param-value>/WEB-INF/clay-config.xml</param-value>
+    </context-param>
+ 
+    <!-- Clay Configuration Full XML view Resources -->
+    <context-param>
+       <param-name>
+          org.apache.shale.clay.FULLXML_CONFIG_FILES
+       </param-name>
+       <param-value>/WEB-INF/clay-views-config.xml</param-value>
+    </context-param>
+ 
+    <!-- Clay XML View Suffix -->
+    <context-param>
+       <param-name>
+          org.apache.shale.clay.XML_TEMPLATE_SUFFIX
+       </param-name>
+       <param-value>.jsf</param-value>
+    </context-param>
+ 
+ These declarations (context-param) are used by Clay and the JavaServer Faces 
(JSF) implementation at startup.
+ 
+ * javax.faces.DEFAULT_SUFFIX – Tells which page suffixes should be handled 
by JSF
+ * javax.faces.STATE_SAVING_METHOD – How should session state be persisted 
(Client-side or Server-side)
+ * org.apache.shale.clay.COMMON_CONFIG_FILES – What are the name(s )of the 
Clay configuration file(s),  providing absolute path within the web-context
+ * org.apache.shale.clay.FULLXML_CONFIG_FILES – What are the name(s) of the 
Clay configuration file(s) that tells Clay about our page definitions.
+ * org.apache.shale.clay.XML_TEMPLATE_SUFFIX – Which page suffixes should be 
handled by Clay.
+ 
+ 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-name>shale</filter-name>
+       <filter-class>
+          org.apache.shale.application.faces.ShaleApplicationFilter
+       </filter-class>
+    </filter>
+ 
+    <!-- Shale Application Controller Filter Mapping -->
+    <filter-mapping>
+    <filter-name>shale</filter-name>
+    <url-pattern>/*</url-pattern>
+    </filter-mapping>
+ 
+ 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 --> 
+    <servlet> 
+       <servlet-name>faces</servlet-name> 
+       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
+       <load-on-startup>1</load-on-startup> 
+    </servlet> 
+ 
+    <!-- JavaServer Faces Servlet Mapping --> 
+    <servlet-mapping> 
+       <servlet-name>faces</servlet-name> 
+       <url-pattern>*.jsf</url-pattern> 
+    </servlet-mapping> 
+ 
+ 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>
+               <extension>jsf</extension>
+               <mime-type>text/html</mime-type>
+       </mime-mapping>
+ 
+ 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
+ 
+ * General information - application 
+ * Navigation rules - navigation-rule
+ * Managed beans - managed-bean
+ 
+ First in out file we define which languages this application supports; 
Norwegian(no) and English(en), and that the default is English.
+ 

Reply via email to