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 ------------------------------------------------------------------------------ Another important thing to notice is that if declare your backing beans to extend AbstractViewController you have to declare them with request scope for the lifecycle methods to be called. If you declare it with scope session they will not be called! - When we do a post against the server JSF/Shale will populate all fields in the managed bean that we have associated with fields on the page (There is a lot of other things going on too but that is beyond the scope of this tutorial). That means that when the method sayHello is invoked a bean Person will have been instantiated and filled with the values coming from our page. In the method sayHello we do not actually do anything other that return a string. + When we do a post against the server JSF/Shale will populate all fields in the managed bean that we have associated with fields on the page (There is a lot of other things going on too but that is beyond the scope of this tutorial). That means that when the method sayHello is invoked a bean Person will have been instantiated and filled with the values coming from our page. In the method sayHello we do not actually do anything other that return a string. This string is used by JSF to figure out which view it should render. This is also defined in the faces-config.xml file under the navigation rules section. + + <navigation-rule>[[BR]] + <!-- These pages should be accessable form everywhere -->[[BR]] + <from-view-id>*</from-view-id>[[BR]] + <navigation-case>[[BR]] + <from-outcome>home</from-outcome>[[BR]] + <to-view-id>/page1.jsf</to-view-id>[[BR]] + </navigation-case>[[BR]] + <navigation-case>[[BR]] + <from-outcome>page2</from-outcome>[[BR]] + <to-view-id>/page2.jsf</to-view-id>[[BR]] + </navigation-case>[[BR]] + <navigation-case>[[BR]] + <from-outcome>page3</from-outcome>[[BR]] + <to-view-id>/page3.jsf</to-view-id>[[BR]] + </navigation-case>[[BR]] + </navigation-rule>[[BR]] + + 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. + + 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. + + <h3>[[BR]] + <span jsfid="outputText" value="#{messages['content.title.page3']}" allowBody="false">Clay template application - Page 3</span>[[BR]] + </h3>[[BR]] + <p>[[BR]] + <span jsfid="outputText" value="#{messages['content.message.page3']}" allowBody="false">This is Page 3 content</span>[[BR]] + </p>[[BR]] + <p>[[BR]] + <span jsfid="outputText" value="#{messages['hello']}" allowBody="false">Hello</span> <span jsfid="outputText" value="#{person.name}" allowBody="false">World</span>[[BR]] + </p>[[BR]] + + Here again we refer to the person bean, butt his time we are displaying a value from it (#{person.name}. As we mentioned this bean has bean declared with session scope, so that the name we entered on page2 is now available on page3 for as long as our session exists. We can also refer to any other managed bean, and properties in these. + + We have now been through a simple Shale/Clay application. It is recommended that you play around with it to see the effects of your changes. When you are ready to move on a natural step is to follow the [:CreatingClayComponents/ Create Clay components tutorial] to learn haw to create reusable Clay components for your pages. + + Hermod Opstvedt + February 2007 +
