Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

D22 Portlet Development With Open Source Frameworks


Published on

  • Be the first to comment

  • Be the first to like this

D22 Portlet Development With Open Source Frameworks

  1. 1. Session Number: D22 Jump START your Portlet development with Open Source Frameworks! Sean Newby, Perficient Sunil Patil, Ascendant Technology LLC Peter Blinstrubas, IBM
  2. 2. Agenda <ul><li>IBM Portlet Development Perspective </li></ul><ul><li>Struts 2.0 </li></ul><ul><li>Spring 2.0 </li></ul>
  3. 3. <ul><li> IBM Portlet Development Perspective </li></ul><ul><li>Email: </li></ul>
  4. 4. Why Use a Framework for Portlet Development? <ul><li>Starts off small and later is enhanced. </li></ul><ul><li>Model View Controller well established. </li></ul><ul><ul><li>Provides separation between different layers </li></ul></ul><ul><li>Frameworks force developers into using a standard approach when building applications </li></ul><ul><li>Shield some of the underlying complexity of developing an application. </li></ul><ul><li>Provides interfaces or abstract classes to speed and structure your development effort. </li></ul><ul><li>Options </li></ul><ul><ul><li>Write the portlet in portal api </li></ul></ul><ul><ul><li>Develop a custom framework for portlet development. </li></ul></ul><ul><ul><ul><li>Port servlet world framework to the portlet world </li></ul></ul></ul><ul><ul><li>Use an existing framework! </li></ul></ul>
  5. 5. Frameworks for Portlet Development <ul><li>IBM Frameworks </li></ul><ul><ul><li>Just the Portlet API </li></ul></ul><ul><ul><li>WebSphere Portlet Factory </li></ul></ul><ul><ul><ul><li>AJAX based on DOJO </li></ul></ul></ul><ul><ul><li>JSF V1.1 on Portal 6.x with JWL 3.0 </li></ul></ul><ul><ul><li>JSF 1.2 for Portal running on WAS 7 (plans subject to change) </li></ul></ul><ul><ul><ul><li>AJAX </li></ul></ul></ul><ul><ul><li>Struts Apache Bridge for JSR 168 Container on WAS 6.1 </li></ul></ul><ul><ul><li>Currently Struts Portlet Framework supports Struts 1.1 and 1.29 </li></ul></ul><ul><li>Alternative Frameworks </li></ul><ul><ul><li>Custom MVC </li></ul></ul><ul><ul><li>Spring 2.0 </li></ul></ul><ul><ul><li>Struts 2.0 </li></ul></ul><ul><ul><li>Many More… (i.e. Shale, Wicket,…) </li></ul></ul>
  6. 6. What is the Struts Portlet Framework? <ul><li>Runtime </li></ul><ul><ul><li>A package that supports Struts application in Portal. </li></ul></ul><ul><ul><li>Includes a level of Struts (1.1 and 1.29) </li></ul></ul><ul><ul><li>A portlet controller and a request processor. </li></ul></ul><ul><ul><li>Implementations of some of the Struts tags </li></ul></ul><ul><li>Tool Set </li></ul><ul><ul><li>Flow Editor for creating and wiring pages and actions together </li></ul></ul><ul><ul><li>A full Struts-Config editor </li></ul></ul><ul><ul><li>Link validation and re-factoring for Struts specific links </li></ul></ul><ul><ul><li>Wizards for creating Actions, Struts JSPs and Form Beans </li></ul></ul><ul><ul><li>Page Designer Visualizations for some Struts-html tags </li></ul></ul><ul><ul><li>Full Page Designer Palette for Struts Tags </li></ul></ul>
  7. 7. What is the Struts Portlet Framework? <ul><li>Support for writing/migrating Struts applications that can be deployed in WebSphere Portal </li></ul><ul><li>Also provides samples to show how portal features can be incorporated by Struts applications </li></ul>
  8. 8. Struts 1.x in General <ul><li>Struts is: </li></ul><ul><ul><li>Controller based framework </li></ul></ul><ul><li>Struts does not have: </li></ul><ul><ul><li>A built-in UI component model </li></ul></ul><ul><ul><li>A built-in event model for UI components </li></ul></ul><ul><ul><li>A built-in state management for UI components </li></ul></ul><ul><ul><li>A built-in support of multiple renderers (Struts is </li></ul></ul><ul><ul><ul><li>more or less tied up with HTML) </li></ul></ul></ul><ul><li>Struts is Not a standard (despite its popularity) </li></ul><ul><li>IBM has no plans to continue SPF Development. </li></ul><ul><li>Recommended for Legacy Struts Applications. </li></ul><ul><ul><li>Also consider Apache Bridge </li></ul></ul>
  9. 9. IBM and JSF <ul><li>Part of Java EE 5 </li></ul><ul><ul><li>Participation in JSR Expert Group </li></ul></ul><ul><ul><li>J2EE-based Web UI and application framework </li></ul></ul><ul><li>WPLC </li></ul><ul><ul><ul><li>Underlying technology in Composite Application Designer </li></ul></ul></ul><ul><ul><ul><li>Used in Portal Workflow portlets </li></ul></ul></ul><ul><ul><ul><li>Being incorporated into Lotus Expeditor </li></ul></ul></ul><ul><ul><ul><li>Widgets in Portlet Factory </li></ul></ul></ul><ul><li>Recommended for new portlet development </li></ul><ul><li>Note: Refer to session D12 for JSF details </li></ul>
  10. 10. JSF General <ul><li>Benefits </li></ul><ul><ul><li>Reusable UI Components </li></ul></ul><ul><ul><li>Custom Tag Libraries </li></ul></ul><ul><ul><li>API for managing UI components, events, input navigation, page navigation </li></ul></ul><ul><ul><li>Addresses complex navigation requirements </li></ul></ul><ul><ul><li>Extensible - Everything is pluggable </li></ul></ul><ul><ul><li>Rich tooling support </li></ul></ul><ul><ul><li>Flexible Actions: different navigations for multiple components on a single page </li></ul></ul><ul><ul><li>Supports Expression </li></ul></ul><ul><ul><li>Built in state management </li></ul></ul><ul><li>Concerns </li></ul><ul><ul><li>Complexity </li></ul></ul><ul><ul><li>Still relatively new </li></ul></ul><ul><ul><li>Out of the box capability to meet requirements </li></ul></ul><ul><ul><li>Availability of skills </li></ul></ul>
  11. 11. <ul><li>Plug-in to Eclipse & Rational Application Developer </li></ul><ul><li>Multi-page custom portlets/applications without coding </li></ul><ul><li>Integration capabilities (SAP, Domino, PeopleSoft, Siebel, Web Services, Databases, Portal Content Repository) </li></ul><ul><li>Service-oriented development </li></ul><ul><li>Support for Portal features such as portlet communication, business user configuration, auto-deploy, single sign-on </li></ul><ul><li>“ Dynamic profiling” capability, to create multiple variations from a single set of source portlets </li></ul>WebSphere Portlet Factory Rapid Portlet Creation and Customization Tooling IBM WebSphere Portlet Factory simplifies & accelerates the development, deployment, maintenance, and reuse of custom portlets and applications.
  12. 12. Portlet Factory General <ul><li>Benefits </li></ul><ul><ul><li>DataCentric Applications </li></ul></ul><ul><ul><li>Expand Portlet Creation to developers of all skill level </li></ul></ul><ul><ul><li>Captures Design Patterns/Standardize Development Model </li></ul></ul><ul><ul><li>Lots of adapters </li></ul></ul><ul><ul><li>Strong XML/Web Service support </li></ul></ul><ul><ul><li>Code generation technology protects investment </li></ul></ul><ul><ul><li>Protecting against backend product upgrades </li></ul></ul><ul><li>Concerns </li></ul><ul><ul><li>New vocabulary (learning curve) </li></ul></ul><ul><ul><li>Complex application, process intensive </li></ul></ul>
  13. 13. There are so many choices? Portlet API JSF Framework Struts Portlet Framework Struts 2.0 My Servlet Framework There may be many valid and not so valid reasons to consider. Portlet Factory Spring 2.0 Apache Bridge
  14. 14. <ul><li> Apache Struts 2.0: </li></ul><ul><li>Sunil Patil, Senior Consultant, Ascendant Technology LLC </li></ul><ul><li>Email: </li></ul>
  15. 15. Struts 2.0 Introduction <ul><li>Action Framework, allows you to map URL to Action Class </li></ul><ul><li>Missing features of Apache Struts 1.0 will be ported to Struts 2.0 </li></ul><ul><li>OpenSymphony’s WebWorks framework will cease to exists </li></ul><ul><ul><li>WebWorks will only release patches for existing versions. </li></ul></ul><ul><li>The WebWorks framework has built-in support for JSR-168 portlet development </li></ul><ul><li>Architecture based on OpenSymphony’s WebWorks Framework </li></ul><ul><ul><li>Command pattern implementation </li></ul></ul><ul><ul><ul><li>Actions are command objects </li></ul></ul></ul>
  16. 16. Client Selection Example <ul><li>At previous client using Apache Struts 2.0 framework </li></ul><ul><li>Reasons Struts 2.0 framework is considered </li></ul><ul><ul><li>Customer wanted precise control on the Portlet Screens </li></ul></ul><ul><ul><li>Customer wanted to use common look and feel across all portlets </li></ul></ul><ul><ul><li>Has considered JSF, but developing custom components in JSF requires lot of work </li></ul></ul><ul><ul><li>Developers already had experience on Apache Struts 1.0, easy migration </li></ul></ul><ul><ul><li>Provides clear separation between Action and Render phase </li></ul></ul>
  17. 17. Key Struts 2.0 objects/concepts <ul><li>Jsr168Dispatcher: </li></ul><ul><ul><li>The Controller portlet that handles all requests to the portlet application. Similar to ActionServlet in Struts 1.0 framework </li></ul></ul><ul><li>Action </li></ul><ul><ul><li>Jsr168Dispatcher passed request to configured Action to handle request. </li></ul></ul><ul><ul><li>Combines ActionForm, Action and Model class </li></ul></ul><ul><ul><li>Location in framework where you write you business logic. </li></ul></ul><ul><li>Results </li></ul><ul><ul><li>Different view technologies are supported </li></ul></ul><ul><ul><ul><li>JSP </li></ul></ul></ul><ul><ul><ul><li>Velocity </li></ul></ul></ul><ul><ul><ul><li>Freemarker </li></ul></ul></ul>
  18. 18. Key Struts 2.0 objects/concepts Cont. <ul><li>Interceptor </li></ul><ul><ul><li>Interceptors are one of the most powerful features of Struts 2.0 framework </li></ul></ul><ul><ul><li>Interceptors are similar to Filters in servlet environment, they allow you to execute your code before and after Action. </li></ul></ul><ul><ul><li>Common functionality is implemented as interceptor </li></ul></ul><ul><ul><ul><li>Setting parameters </li></ul></ul></ul><ul><ul><ul><li>Validation workflow </li></ul></ul></ul><ul><li>Value Stack </li></ul><ul><ul><li>Used for carrying data from action class to JSP page </li></ul></ul><ul><ul><li>Value Stack, Stack of objects </li></ul></ul><ul><ul><ul><li>Temporary Objects </li></ul></ul></ul><ul><ul><ul><li>Action Object </li></ul></ul></ul><ul><ul><ul><li>Named object </li></ul></ul></ul>
  19. 19. Struts : Forward to JSP request flow
  20. 20. Struts : Forward to Action request flow
  21. 21. Main Artifacts
  22. 22. Additions to portlet.xml <ul><li>Jsr168Dispatcher is portlet dispatcher class </li></ul><ul><li>viewNameSpace defines default namespace for view mode </li></ul><ul><li>defaultViewAction defines default action for view mode </li></ul>
  23. 23. Additions to web.xml <ul><li>Configure to setup PreparatorServlet </li></ul><ul><li>Configure to setup spring integration </li></ul>
  24. 24. Struts Configuration <ul><li>Import default configuration from struts-portlet-default.xml </li></ul><ul><li>Divide configuration in different namespaces </li></ul>
  25. 25. Struts Action <ul><li>Optionally extend from ActionSupport class </li></ul><ul><li>Combines Action, ActionForm and Model class </li></ul><ul><li>The execute() method does not take PortletRequest and PortletResponse object </li></ul>
  26. 26. Struts Action contd. <ul><li>Setting form values in Contact class </li></ul><ul><li>No need for contactList, model class </li></ul>
  27. 27. Struts JSP <ul><li>OGNL expressions for reading values from Value stack </li></ul><ul><li>Read i18n messages from <ActionClass>.properties file </li></ul><ul><li>Struts tags use Freemarker Template for generating markup </li></ul><ul><li>You can extend tag by overriding template </li></ul><ul><li>XHTML Theme - No HTML Markup in the JSP </li></ul>
  28. 28. Struts Tags <ul><li>The form field tag is responsible for </li></ul><ul><ul><li>Generating two column layout </li></ul></ul><ul><ul><li>Generating form elements as well as surrounding table element </li></ul></ul><ul><li>Every form field tag is responsible for generating one row in table </li></ul><ul><ul><li>Display label on the left side of the form field </li></ul></ul><ul><ul><li>Display actual form field on the right side </li></ul></ul><ul><ul><li>Display the field error above the form field </li></ul></ul><ul><li><s:textfield label=&quot;Name&quot; name=&quot;contact.firstName&quot;/> </li></ul><ul><li> rendered as (with error message) </li></ul>
  29. 29. Struts Tags contd. <ul><li>This is how datepicker form field and popup look like </li></ul><ul><li><s:datetimepicker label=&quot;DOB&quot; name=&quot;contact.dateOfBirth&quot;/> </li></ul><ul><li>rendered as </li></ul>
  30. 30. Support for Different View Technologies <ul><li>Same tag library available in JSP, Freemarker and Velocity </li></ul><ul><li>Insert.ftl </li></ul><ul><li>insert.vm </li></ul>
  31. 31. Form Validation in Struts 2.0 <ul><li>Can be use several different types </li></ul><ul><ul><li>Programmatically by implementing validate() method in Action class </li></ul></ul><ul><ul><li>Declaratively using XWork’s Validation framework </li></ul></ul><ul><ul><li>Client side validation </li></ul></ul><ul><li>Create <ActionClass>-validation.xml </li></ul><ul><li>Sample uses of XWork validation </li></ul>
  32. 32. Type Conversion <ul><li>Routine type conversion in the framework is transparent </li></ul><ul><ul><li>Boolean, boolean, Integrer, int, Float, float, Long, log, Double, double </li></ul></ul><ul><ul><li>Date with the locale associated with current request </li></ul></ul><ul><li>Register custom type conversion class </li></ul><ul><ul><li><ActionClass> for class specific conversion </li></ul></ul><ul><ul><ul><li>Point=com.ascendant.converter.PointConverter </li></ul></ul></ul><ul><ul><li>Xwork-conversion-properties for global conversion </li></ul></ul><ul><li>Custom type conversion for more complex objects </li></ul><ul><ul><li>Create class extending StrutsTypeConverter class </li></ul></ul><ul><ul><ul><li>convertFromString() </li></ul></ul></ul><ul><ul><ul><li>convertToString() </li></ul></ul></ul>
  33. 33. Struts Plug-ins <ul><li>Many popular optional features of the framework are distributed as plug-ins </li></ul><ul><ul><li>Spring </li></ul></ul><ul><ul><li>Tiles </li></ul></ul><ul><ul><li>File upload </li></ul></ul><ul><li>Plug-ins are used for </li></ul><ul><ul><li>Introducing new Extension point implementation class </li></ul></ul><ul><ul><ul><li>ObjectFactory : Spring plug-in implements StrutsSpringObjectFactory </li></ul></ul></ul><ul><ul><ul><li>Mutlipart parser: Allows using Pell’s multi part parser for parsing multi-part request </li></ul></ul></ul><ul><ul><li>Define new packages with results, interceptors or actions </li></ul></ul><ul><ul><ul><li>Results: Tiles plug-in introduces Tiles Results type </li></ul></ul></ul><ul><ul><li>Override framework constants </li></ul></ul>
  34. 34. Spring Integration <ul><li>Allows Actions, Interceptors and Results to be created by Spring </li></ul><ul><li>Struts created object can be auto wired by spring after creation </li></ul><ul><li>Provides two interceptors that auto wire actions if not using the Spring Objectfactory </li></ul><ul><li>Add entry for StrutsSpringObjectFactory in </li></ul><ul><ul><li>struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory </li></ul></ul>
  35. 35. <ul><li> Spring 2.0: </li></ul><ul><li>Sean Newby, Senior Consultant, Perficient Inc. </li></ul><ul><li>Email: </li></ul>
  36. 36. Spring Intro <ul><li>Spring is a popular Java Application Framework that has gained significant momentum in the past few years. </li></ul><ul><li>Made up of several modules that can be used independently </li></ul><ul><ul><li>Inversion of Control Container (Core) </li></ul></ul><ul><ul><li>AOP module </li></ul></ul><ul><ul><li>DAO module </li></ul></ul><ul><ul><li>MVC module </li></ul></ul><ul><li>Portlet MVC became a part of the general Spring 2.0 release in November of 2006. </li></ul>
  37. 37. Client Selection Example <ul><li>At a previous client that decided to Spring MVC. </li></ul><ul><li>Reasons Spring MVC was selected. </li></ul><ul><ul><li>Similar in design to IBM Struts implementation. Had considered JSF, but no developers had any experience. JSF seemed to be more of a paradigm shift. </li></ul></ul><ul><ul><li>Developers already had experience with other elements of Spring. </li></ul></ul><ul><ul><li>Confident that would be able to find answers to issues in the Spring community. </li></ul></ul><ul><ul><li>Addressed use case we needed to solve (Wizard Portlet). </li></ul></ul><ul><ul><li>Designed around portlet api, addressed Render and Action separately. </li></ul></ul>
  38. 38. Key Portlet MVC objects / concepts <ul><li>DispatcherPortlet </li></ul><ul><ul><li>The controller portlet that handles all requests to the portlet application. Similar to ActionPortlet or ActionServlet in the Struts framework. </li></ul></ul><ul><li>Controller </li></ul><ul><ul><li>Location in Framework where your code begins. Similar to Struts Action class. </li></ul></ul><ul><ul><li>DispatcherPortlet passed request to configured Controller to handle request. Separate methods for render and action phases. </li></ul></ul><ul><ul><li>Several default implementations to handle common use cases: </li></ul></ul><ul><ul><ul><li>ParameterizableViewController – Simple controller that passes to a view. </li></ul></ul></ul><ul><ul><ul><li>SimpleFormController – Controller to handle form submissions. </li></ul></ul></ul><ul><ul><ul><li>AbstractWizardController – Controller to implement wizard like form. Form that extends over several pages. </li></ul></ul></ul><ul><li>HandlerMapping </li></ul><ul><ul><li>Determines which Controller will be called. </li></ul></ul><ul><ul><li>Several out of the box implementations. </li></ul></ul>
  39. 39. Key Portlet MVC objects / concepts cont. <ul><li>ModelAndView </li></ul><ul><ul><li>Object that is returned by Controllers to DispatcherPortlet. </li></ul></ul><ul><ul><li>Contains the Model that needs to be displayed by the view. Also contains the “name” of the view. </li></ul></ul><ul><ul><li>Behavior is similar to a regular Map object. </li></ul></ul><ul><li>ViewResolver </li></ul><ul><ul><li>Maintains a clean separation of View technology. </li></ul></ul><ul><ul><li>Several Default ViewResolvers </li></ul></ul><ul><ul><ul><li>JSP </li></ul></ul></ul><ul><ul><ul><li>Velocity </li></ul></ul></ul><ul><ul><ul><li>XSLT </li></ul></ul></ul><ul><li>Command Objects </li></ul><ul><ul><li>JavaBean type objects. Object is bound to request parameters, usually from form submission. </li></ul></ul><ul><ul><li>Similar to Struts ActionForm, except is does not extend framework specific class. </li></ul></ul>
  40. 40. Simplified Render Sequence Diagram <ul><li>Some steps have been omitted for clarity. </li></ul>
  41. 41. Simplified Action Sequence Diagram <ul><li>Some steps have been omitted for clarity. </li></ul>
  42. 42. Getting Started setting up a Spring Portlet <ul><li>WEB-INF/web.xml and WEB-INF/portlet.xml </li></ul><ul><li>WEB-INF/context/applicationContext.xml – main application wide config file. Values can be overridden in portlet config. </li></ul><ul><li>WEB-INF/<PORTLETNAME>-portlet.xml – individual config file for each portlet. </li></ul><ul><li>WEB-INF/lib/spring.jar – main spring file.* </li></ul><ul><li>WEB-INF/lib/spring-portlet.jar – additions for Spring Portlet MVC </li></ul><ul><li>WEB-INF/lib/spring-modules-validation.jar – additions for validation of forms. </li></ul><ul><li>*could pick out specific Spring jar’s to reduce size of application. </li></ul>
  43. 43. Main Artifacts
  44. 44. Additions to Web.xml <ul><li>Configuration to set up Spring MVC servlet. </li></ul><ul><li>Portlet MVC leverages Servlet base code. </li></ul>
  45. 45. Portlet.xml <ul><li>portlet-class is Portlet MVC class </li></ul><ul><li>portlet-name = <PortletName>-portlet.xml Spring MVC config file. </li></ul>
  46. 46. Spring IoC Core (Dependency Injection) <ul><li>Don’t really need to understand to use Portlet MVC, but it is helpful. </li></ul><ul><li>From Spring Documentation: </li></ul><ul><ul><li>The basic principle behind Dependency Injection (DI) is that objects define their dependencies (that is to say the other objects they work with) only through constructor arguments, arguments to a factory method, or properties which are set on the object instance after it has been constructed or returned from a factory method. Then, it is the job of the container to actually inject those dependencies when it creates the bean. This is fundamentally the inverse, hence the name Inversion of Control (IoC), of the bean itself being in control of instantiating or locating its dependencies on its own using direct construction of classes, or something like the Service Locator pattern. </li></ul></ul><ul><ul><li>It becomes evident upon usage that code gets much cleaner when the DI principle is applied, and reaching a higher grade of decoupling is much easier when beans do not look up their dependencies, but are provided with them (and additionally do not even know where the dependencies are located and of what actual class they are). </li></ul></ul><ul><li>Really enables “Programming to the interface” </li></ul>
  47. 47. Spring config basics <ul><li>Everything is defined as a bean. </li></ul><ul><li>Container will call methods on defined beans. </li></ul><ul><ul><li>Passes in a String </li></ul></ul><ul><ul><li>Passes in a reference to another bean </li></ul></ul>
  48. 48. Spring Config Basics - inject another bean <ul><li>Creates two beans </li></ul><ul><ul><li>locationDao = new LocationDaoHardCodedImpl() </li></ul></ul><ul><ul><li>locationService = new LocationServiceImpl() </li></ul></ul><ul><li>locationService has a locationDao “injected” into it. </li></ul><ul><ul><li>“name” is method to call (setLocationDao) </li></ul></ul><ul><ul><li>“ref” indicates pass in reference to another defined bean </li></ul></ul>
  49. 49. Spring Config Basics – inject a String <ul><li>Creates a bean referred to as “displayIndexController” </li></ul><ul><ul><li>“value” indicates pass in String </li></ul></ul><ul><ul><li>Injects a String in the first property </li></ul></ul><ul><ul><li>Injects a bean in the second property </li></ul></ul>
  50. 50. Portlet MVC application.xml entries - View <ul><li>Defines where named “views” are located. </li></ul><ul><li>Defines what view technology to use. </li></ul><ul><li>Sample uses jsp’s located in /WEB-INF/jsp/ directory </li></ul>
  51. 51. Portlet MVC application.xml entries - Messages <ul><li>Defines message bundle to use for i18n. </li></ul>
  52. 52. Portlet MVC application.xml entries - Exception <ul><li>Define default views for exceptions. </li></ul><ul><li>PortletSecurityException goes to notAuthorized view. </li></ul><ul><li>UnavailableException goes to notAvailable view. </li></ul>
  53. 53. Sample Portlets <ul><li>Spring Display </li></ul><ul><ul><li>Example of a ParameterizableViewController </li></ul></ul><ul><ul><li>Displays dynamic data </li></ul></ul><ul><li>Spring Form </li></ul><ul><ul><li>Example of a SimpleFormController </li></ul></ul><ul><ul><li>Handles a form submission </li></ul></ul><ul><li>Spring Wizard </li></ul><ul><ul><li>Example of an AbstractWizardFormController </li></ul></ul><ul><ul><li>Presents a form over several pages </li></ul></ul><ul><ul><li>Assists with navigating back and forth </li></ul></ul>
  54. 54. SpringDisplay-portlet.xml – ParameterDispatchController <ul><li>Declares controller used, referred to as displayIndexController. </li></ul><ul><li>Property viewName corresponds to jsp that will be displayed. </li></ul>
  55. 55. PortletModeParameterHandlerMapping <ul><li>Allows you to call other controller from the view. </li></ul>
  56. 56. DisplayIndexController <ul><li>ParameterizedViewController implementation </li></ul>
  57. 57. SpringForm-portlet.xml - SimpleFormController <ul><li>formView – view to display form initially </li></ul><ul><li>successView – confirmation page once form submitted </li></ul><ul><li>commandClass – form backing object, like ActionForm </li></ul><ul><li>commandName – how to refer to commandClass in view </li></ul><ul><li>validator – validation to use </li></ul>
  58. 58. FormIndexController <ul><li>SimpleFormController implementation. </li></ul>
  59. 59. formIndex.jsp <ul><li>Uses Spring 2.0 style form tags </li></ul><ul><li>commandName is form backing object </li></ul><ul><li>errors path=“*”, show validation errors for all fields </li></ul><ul><li>path=“name”, binds to name property of location object </li></ul>
  60. 60. Form Validation in Spring MVC <ul><li>Can use several different types </li></ul><ul><ul><li>Programmatically through Validator interface </li></ul></ul><ul><ul><li>Declaratively using Apache Commons Validation Framework </li></ul></ul><ul><ul><li>Declaratively using Valang </li></ul></ul><ul><li>Sample uses Valang validation </li></ul>
  61. 61. SpringWizard-portlet.xml <ul><li>pages – List of view that are available through the wizard. </li></ul><ul><ul><li>Order is significant. </li></ul></ul><ul><ul><li>wizardBasicInfo is page 0. </li></ul></ul><ul><ul><li>wizardContactInfo is page 1. </li></ul></ul><ul><ul><li>wizardBillingInfo is page 2. </li></ul></ul>
  62. 62. WizardIndexController
  63. 63. wizardContactInfo.jsp <ul><li>Middle step in wizard </li></ul><ul><li>JSP wizard navigation code, _target[PAGEINDEX] </li></ul><ul><li>Uses older Spring 1.0 form tags </li></ul><ul><li>_page1, pageAttribute from configuration file </li></ul>
  64. 64. Spring MVC Pros / Cons <ul><li>Pros </li></ul><ul><ul><li>Easy for experienced Struts Developers to transition. </li></ul></ul><ul><ul><li>Strong community, should be viable solution for some time. </li></ul></ul><ul><ul><li>Modular, pick and choose features. Entry point to use more of the Spring framework. </li></ul></ul><ul><ul><li>Design goal of the framework is to be non-evasive, your code does not depend on the framework. </li></ul></ul><ul><ul><ul><li>Class extension or Interface implementation. </li></ul></ul></ul><ul><ul><li>Good documentation for open source project. </li></ul></ul><ul><li>Cons </li></ul><ul><ul><li>Can be xml config intensive. </li></ul></ul><ul><ul><li>Can not call IBM and create a PMR for support. </li></ul></ul>
  65. 65. Additional Information and Resources <ul><li>Websphere Portal Business Solutions Catalog : </li></ul><ul><ul><li> </li></ul></ul><ul><li>Webspere Portal Product Information: </li></ul><ul><ul><li> </li></ul></ul><ul><li>WebSphere Portal Information Center Documentation: </li></ul><ul><ul><li> </li></ul></ul>
  66. 66. Summary <ul><li>IBM Perspective </li></ul><ul><li>Struts 2.0 </li></ul><ul><li>Spring 2.0 </li></ul>
  67. 67. Avoid Boring People: Lessons from a Life in Science (Hardcover) by James D. Watson (Author)
  68. 68. Programming Portlets : From JSR 168 to IBM WebSphere Portal Extensions Ron Lynn , Joey Bernal , Peter Blinstrubas , Stefan Hepper , Usman Memon , Varadarajan ( Varad ) Ramamoorthy