Download presentation
Presentation is loading. Please wait.
Published byAldous Dickerson Modified over 9 years ago
1
2008 - Shale and JSF Ken Sipe - Code Mentor
2
2 Presentation Goal Provide enough understanding for someone new to JSF and Shale to start coding…
3
3 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
4
4 About the Speaker Sun Certified Java 2 Architect. Instructor for VisiBroker for Java, OOAD, Rational Rose, and Java Development. Frequently speaks on the subject of distributed computing programming, including CORBA and EJB architecture. JBoss Certified Developer ;)
5
5 What is Shale? JavaServer Faces JSF++ Extends JSF to add Functionality Added Components without the overhead of committee Struts 2.0 Well it is the same guys who are involved A number of components carried over Tiles FileUpload Doesn’t work in the same MVC model of struts 1.x http://struts.apache.org/shale http://wiki.apache.org/struts/StrutsShale
6
6 Shale Features View Lifecycle Events Dialog Web Flow AJAX Support Validation Commons Validator Tiles Integration Spring Integration Tapestry-Like Views
7
7 Shale Tag Library Token pattern, used to prevent double posts Used for Tiles... and dynamically added content Used for commons validation Client and Server Used with commons validation Client side Tapestry Like
8
8 JSF Extension Points ShalePropertyResolver Value binding expressions for JNDI ShaleVariableResolver String Integration JNDI Lookups ShaleViewHandler Lifecycle events for ViewControllers TilesViewHandler Maps tile components DialogNavigatioHandler The space between request and session
9
9 Shales Future Ready a big question Craig says perhaps: Struts 2.0 New Apache project Part of MyFaces Part of JSF 2.0
10
10 Shale Library References Shale provides a number if jars for distribution: shale-core.jar shale-spring.jar shale-clay.jar shale-test.jar shale-tiles.jar To use tiles you'll need tiles-core.jar There are 2 tlds taglib.tld – contained in shale-cores.jar shale-clay.tld – contained in shale-clay.jar
11
11 Shale References Shale makes significant use of jakarta commons commons-logging commons-validator commons-digester commons-beanutils commons-chain commons-collections
12
12 JBuilder Shale Configuration Create a Library with Shale-core.jar Extract taglib.tld Configure a custom tag lib
13
13 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
14
14 JSF Events JSF defines standard server side events and listener APIS: ActionEvent calls xxx_action() method and/or event listeners ValueChangeEvent calls xxx_valueChanged() method and/or event listeners Sufficient to deal with most low level UI components Insufficient to deal with application level events
15
15 Shale View Life-cycle Events Shale extends server side event paradigm ViewController backing bean per page: Standard “View Helper” design pattern Supports standard event handler methods init() preprocess() prerender() destroy() Great for handling PostBacks in a slightly different way than the initial view.
16
16 Using ViewController Implement the ViewController interface. org.apache.shale.view.ViewController Provide a no-args public constructor. Declare your backing bean as a managed bean. In nearly all circumstances, you will want the bean to be placed in request scope. Provide public JavaBean properties that may be set to customize the functionality provided by this bean. Ensure that the functionality of your backing bean is not dependent upon the order in which property setters are called. Create event handlers for the lifecycle events of interest, plus standard JavaServer Faces event handlers for things like actions and value changes.
17
17 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
18
18 JSF Validation JSF defines standard server validation capabilities which integrates well with JSF components 1..* validators per component are possible Model updates are only after validations occur.
19
19 Shale Validation Jakarta Commons Validator Leverage the same rules created for struts 1.x applications Leverage same rules for other frameworks / applications integrated with commons Client-Side Validation Extends past JSF by providing validation at the client side Tag Support Client-side or Server-side or Both Generators client-side JavaScript
20
20 XML Configuration Although there can be any number of files used for validation configuration, typically there is at least : Validation-rules.xml Contains the xml defined rules Typically generic / Non application specific Provided with the struts download
21
21 Validation-rules.xml <validator name="required" classname="org.apache.struts.validator.FieldChecks" method="validateRequired" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg="errors.required"> <![CDATA[ …
22
22 Shale Validation Components … …
23
DEMO Shale Validation
24
24 Presentation Agenda What is Shale? View LifeCycle Events Validation Spring Integration Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
25
25 Shale and Spring DelegatingVariableResolver Access Spring beans with JSF expressions #{user} Zero-Configuration Just package shale-spring.jar and spring.jar in the lib of war applicationContext.xml
26
26 Presentation Agenda What is Shale? View LifeCycle Events Validation Spring Integration Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
27
27 Tiles Shale Integration Add to the lib directory of WAR shale-tiles.jar tiles-core.jar
28
28 Tiles and Shale Can be leverage across all of Shale ViewIds of Dialogs Navigation Rule * login-page-tile
29
29 Shale Tiles Layout '>
30
30 Tiles.XML file <definition name="login-page-tile" extends="header-menu-content-tile"> </definition
31
31 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
32
32 Tapestry “Style” Define a web page without any code Code is tied to page through html tag attributes. jsfid Web can be: Html JSP xml
33
33 Separation of Page Designer and Developer Supports 2 Views Design Time (Web Developers) http://localhost:8082/app/home.html Run Time http://localhost:8082/app/home.faces Designer Works with HTML Developer JSP to include HTML XML to connect it all together
34
34 Configuration clay-config.xml contains the jsfid replacement mappings view-config.xml contains the component name references from clay-config.xml shale-clay.jar
35
35 Login HTML Username username error message Password password error message
36
36 Login JSP <sh:clay id="loginTemplate" jsfid="/pages/clay-login.html" managedBeanName="loginPage"/>
37
37 JSP Page not required WEB.XML configuration: clay-template-suffix.html
38
38 Clay-Config.XML file
39
39 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
40
40 AJAX – The New Buzz Asynchronous JavaScript with XML Except it’s not always Asynchronous And It’s not always XML Server submissions without a page post and refresh Out-side of Shale support I really like DWR Direct Web Remoting http://getahead.ltd.uk/dwr/ http://getahead.ltd.uk/dwr/
41
41 AJAX / JSF Warning… If you change the state of expected states values held by server… bad things happen Mainly the short-circuits the 2 nd or 3 rd phase of JSF (just for a model update and redisplays the page.
42
42 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
43
43 Shale Dialogs Modeled after Springs Web Flow Simplified Not complete duplication of Spring Modeled as States and Transitions Get your STDs out
44
44 Dialog State Types Action Represents a call to a public method, taking no parameters, and returning a String that will be treated as the logical outcome View Represents the rendering of a JavaServer Faces view Subdialog Represents pushing the state of the current dialog onto a stack, and starting a specified new dialog at its starting state Exit Terminates the current dialog
45
45 Defining Dialogs - Dialog-config.xml <dialog name="Create Account" start="User Information">
46
46 Defining Dialogs <view name="Summary" viewId="/pages/account.jsp"> <end name="Exit" viewId="/pages/login.jsp"/>
47
47 Working with Dialogs Enter dialogs through JSF actions <h:commandButton value=‘register’ action=“dialog: Create Account ” /> DialogNavigationHandler manages dialog flow From Dialog, navigate back to JSF
48
48 Multi-Dialog Configuration Files org.apache.shale.dialog.CONFIGURATION /WEB-INF/account-dialogs.xml,/WEB-INF/user-dialogs.xml
49
49 Presentation Agenda What is Shale? View LifeCycle Events Validation Tiles Integration Clay – Tapestry-like Views AJAX Dialogs
50
50 Summary Shale makes many common web development task easier. Extension of JSF Not bound to JCP committee
51
Questions?
52
52 Thank You 2008 Web Application Development using Struts, Shale and JSF Please fill out the speaker evaluation You can contact me further at … kensipe@codementor.net
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.