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 ------------------------------------------------------------------------------ Since the archetype currently has not made its way into the distribution, you will need to get the archetype from the Shale Subversion repository located at: - https://svn.apache.org/repos/asf/shale/sandbox/maven/archetypes/shale-clay-starter-archetype + https://svn.apache.org/repos/asf/shale/maven/archetypes/shale-clay-starter-archetype After you have downloaded the sources, you need to run the following Maven2 command in the shale-starter-archetype directory: @@ -83, +83 @@ attachment:ShaleClay7.jpg In the Java sourcefolder (src/main/java) under the packagename you provided you should find two classes: - Person and TestVC. + Person and TestViewController. 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 name extention. @@ -361, +361 @@ <managed-bean id="page1"> <managed-bean-name>page1</managed-bean-name> <managed-bean-class> - com com.acme.test.TestVC + com com.acme.test.TestViewController </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> <managed-bean id="page2"> <managed-bean-name>page2</managed-bean-name> <managed-bean-class> - com.acme.test.TestVC + com.acme.test.TestViewController </managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> @@ -385, +385 @@ When Clay sees the symbol [EMAIL PROTECTED], it replaces it with the implicitly mapped bean that Shale is providing. In our case {{{page1}}}. - Lets take a closer look at the bean {{{com.acme.test.TestVC}}} that we are using for our backing bean. The first thing we notice is that it inherits from [http://shale.apache.org/shale-view AbstractViewController]. This class gives us some hooks (callbacks) into some Shale added lifecycle methods so that we can perform certain tasks that are relevant to that particular lifecycle. The next thing to notice is that is refers to a class Person. If you look in the {{{faces-config.xml}}} file again you will find the following declaration: + Lets take a closer look at the bean {{{com.acme.test.TestViewController}}} that we are using for our backing bean. The first thing we notice is that it inherits from [http://shale.apache.org/shale-view AbstractViewController]. This class gives us some hooks (callbacks) into some Shale added lifecycle methods so that we can perform certain tasks that are relevant to that particular lifecycle. The next thing to notice is that is refers to a class Person. If you look in the {{{faces-config.xml}}} file again you will find the following declaration: {{{ <managed-bean id="person"> @@ -397, +397 @@ </managed-bean> }}} - If you look at the above definition you will see that Person has been declared as a managed bean. Because Person is defined as a managed bean, Shale will inject it into our page2 definition because we instructed it to through the use of the managed-property section. Since Person has a scope of session it will be persisted between request so that any value that we set on one request will be available on the next. Finally we see that we define a method sayHello on the TestVC bean, and that we refer to that method in the page2Body.html in the âactionâ attribute (: [EMAIL PROTECTED]). + If you look at the above definition you will see that Person has been declared as a managed bean. Because Person is defined as a managed bean, Shale will inject it into our page2 definition because we instructed it to through the use of the managed-property section. Since Person has a scope of session it will be persisted between request so that any value that we set on one request will be available on the next. Finally we see that we define a method sayHello on the TestViewController bean, and that we refer to that method in the page2Body.html in the âactionâ attribute (: [EMAIL PROTECTED]). One of the thing that separate Java``Server Faces from an ordinary webapplication is that most interaction with the server is through http POST. This means that all fields and actions must be surrounded with a form tag. @@ -424, +424 @@ </navigation-rule> }}} - In TestVC.sayHello we returned the string page3, and in the navigation rules we see that this will send us to /page3.jsf. You can define many navigation rules, and also note that a navigation rule always must have a from view. If you use the asterix (*) then that will mean that unless otherwise specified the outcomes become global rules. + In TestViewController.sayHello we returned the string page3, and in the navigation rules we see that this will send us to /page3.jsf. You can define many navigation rules, and also note that a navigation rule always must have a from view. If you use the asterix (*) then that will mean that unless otherwise specified the outcomes become global rules. As a result of our action page3 will be rendered. If we look at the bodyCOntent definition for page3 in the clay-views-config.xml file we will se that it refers to page3Body.html.
