SlideShare a Scribd company logo
1 of 68
Session Number:  D22 Jump START your Portlet development with Open Source Frameworks! Sean Newby, Perficient Sunil Patil, Ascendant Technology LLC Peter Blinstrubas, IBM
Agenda ,[object Object],[object Object],[object Object]
[object Object],[object Object]
Why Use a Framework for Portlet Development? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Frameworks for Portlet Development ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is the Struts Portlet Framework? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What is the Struts Portlet Framework? ,[object Object],[object Object]
Struts 1.x in General ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
IBM and JSF ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSF General ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],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.
Portlet Factory General ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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
[object Object],[object Object],[object Object]
Struts 2.0 Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Client Selection Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Key Struts 2.0 objects/concepts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Key Struts 2.0 objects/concepts Cont. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Struts : Forward to JSP request flow
Struts : Forward to Action request flow
Main Artifacts
Additions to portlet.xml ,[object Object],[object Object],[object Object]
Additions to web.xml ,[object Object],[object Object]
Struts Configuration ,[object Object],[object Object]
Struts Action ,[object Object],[object Object],[object Object]
Struts Action contd. ,[object Object],[object Object]
Struts JSP ,[object Object],[object Object],[object Object],[object Object],[object Object]
Struts Tags ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Struts Tags contd. ,[object Object],[object Object],[object Object]
Support for Different View Technologies ,[object Object],[object Object],[object Object]
Form Validation in Struts 2.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Conversion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Struts Plug-ins ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring Integration ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
Spring Intro ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Client Selection Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Key Portlet MVC objects / concepts  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Key Portlet MVC objects / concepts cont. ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Simplified Render Sequence Diagram ,[object Object]
Simplified Action Sequence Diagram ,[object Object]
Getting Started setting up a Spring Portlet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Main Artifacts
Additions to Web.xml ,[object Object],[object Object]
Portlet.xml ,[object Object],[object Object]
Spring IoC Core (Dependency Injection) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Spring config basics ,[object Object],[object Object],[object Object],[object Object]
Spring Config Basics - inject another bean ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring Config Basics – inject a String ,[object Object],[object Object],[object Object],[object Object]
Portlet MVC application.xml entries - View ,[object Object],[object Object],[object Object]
Portlet MVC application.xml entries - Messages ,[object Object]
Portlet MVC application.xml entries - Exception ,[object Object],[object Object],[object Object]
Sample Portlets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SpringDisplay-portlet.xml – ParameterDispatchController ,[object Object],[object Object]
PortletModeParameterHandlerMapping ,[object Object]
DisplayIndexController ,[object Object]
SpringForm-portlet.xml - SimpleFormController ,[object Object],[object Object],[object Object],[object Object],[object Object]
FormIndexController ,[object Object]
formIndex.jsp ,[object Object],[object Object],[object Object],[object Object]
Form Validation in Spring MVC ,[object Object],[object Object],[object Object],[object Object],[object Object]
SpringWizard-portlet.xml ,[object Object],[object Object],[object Object],[object Object],[object Object]
WizardIndexController
wizardContactInfo.jsp ,[object Object],[object Object],[object Object],[object Object]
Spring MVC Pros / Cons ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Additional Information and Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object]
Avoid Boring People: Lessons from a Life in Science (Hardcover) by  James D. Watson  (Author)
Programming  Portlets : From JSR 168 to IBM  WebSphere  Portal Extensions   Ron Lynn ,  Joey Bernal ,  Peter  Blinstrubas ,  Stefan  Hepper ,  Usman   Memon ,  Varadarajan  ( Varad )  Ramamoorthy

More Related Content

What's hot

Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCJohn Lewis
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)Prashanth Shivakumar
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSFSoftServe
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)Carles Farré
 
Establishing and analyzing traceability between artifacts
Establishing and analyzing traceability between artifactsEstablishing and analyzing traceability between artifacts
Establishing and analyzing traceability between artifactsIBM Rational software
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overviewodedns
 
Creating an artifact at the project level
Creating an artifact at the project levelCreating an artifact at the project level
Creating an artifact at the project levelIBM Rational software
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewEugene Bogaart
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview QuestionsSyed Shahul
 
Basic concepts and terminology for the Requirements Management application
Basic concepts and terminology for the Requirements Management applicationBasic concepts and terminology for the Requirements Management application
Basic concepts and terminology for the Requirements Management applicationIBM Rational software
 

What's hot (19)

Tu1 1 5l
Tu1 1 5lTu1 1 5l
Tu1 1 5l
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)WCF (Windows Communication Foundation_Unit_01)
WCF (Windows Communication Foundation_Unit_01)
 
Introduction to JSF
Introduction toJSFIntroduction toJSF
Introduction to JSF
 
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
[DSBW Spring 2009] Unit 07: WebApp Design Patterns & Frameworks (1/3)
 
XML Unit 01
XML Unit 01XML Unit 01
XML Unit 01
 
Identifying and managing change
Identifying and managing changeIdentifying and managing change
Identifying and managing change
 
Establishing and analyzing traceability between artifacts
Establishing and analyzing traceability between artifactsEstablishing and analyzing traceability between artifacts
Establishing and analyzing traceability between artifacts
 
JEE Course - JEE Overview
JEE Course - JEE  OverviewJEE Course - JEE  Overview
JEE Course - JEE Overview
 
JSF 2.2
JSF 2.2JSF 2.2
JSF 2.2
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
J2ee seminar
J2ee seminarJ2ee seminar
J2ee seminar
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
Creating an artifact at the project level
Creating an artifact at the project levelCreating an artifact at the project level
Creating an artifact at the project level
 
Java Enterprise Edition 6 Overview
Java Enterprise Edition 6 OverviewJava Enterprise Edition 6 Overview
Java Enterprise Edition 6 Overview
 
Hibernate Interview Questions
Hibernate Interview QuestionsHibernate Interview Questions
Hibernate Interview Questions
 
Java J2EE
Java J2EEJava J2EE
Java J2EE
 
Basic concepts and terminology for the Requirements Management application
Basic concepts and terminology for the Requirements Management applicationBasic concepts and terminology for the Requirements Management application
Basic concepts and terminology for the Requirements Management application
 

Viewers also liked

Web site optimization
Web site optimizationWeb site optimization
Web site optimizationSunil Patil
 
Flex In Portal Final
Flex In Portal   FinalFlex In Portal   Final
Flex In Portal FinalSunil Patil
 
Exposicion Tarjetas Madre Grupo 1
Exposicion Tarjetas Madre Grupo 1Exposicion Tarjetas Madre Grupo 1
Exposicion Tarjetas Madre Grupo 1wilmer92
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworksSunil Patil
 
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...Alexander Wiseman
 
Comparing National and Non-national Student Achievement in Saudi Arabia:
Comparing National and Non-national Student Achievement in Saudi Arabia: Comparing National and Non-national Student Achievement in Saudi Arabia:
Comparing National and Non-national Student Achievement in Saudi Arabia: Alexander Wiseman
 
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...Alexander Wiseman
 

Viewers also liked (7)

Web site optimization
Web site optimizationWeb site optimization
Web site optimization
 
Flex In Portal Final
Flex In Portal   FinalFlex In Portal   Final
Flex In Portal Final
 
Exposicion Tarjetas Madre Grupo 1
Exposicion Tarjetas Madre Grupo 1Exposicion Tarjetas Madre Grupo 1
Exposicion Tarjetas Madre Grupo 1
 
D22 portlet development with open source frameworks
D22 portlet development with open source frameworksD22 portlet development with open source frameworks
D22 portlet development with open source frameworks
 
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...
The Consistency and Controversy of Gender: Egalitarian Educational Norms and ...
 
Comparing National and Non-national Student Achievement in Saudi Arabia:
Comparing National and Non-national Student Achievement in Saudi Arabia: Comparing National and Non-national Student Achievement in Saudi Arabia:
Comparing National and Non-national Student Achievement in Saudi Arabia:
 
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...
Wiseman, A. W. (2013, May). The Global “Crisis” in Education and the US Polic...
 

Similar to D22 Portlet Development With Open Source Frameworks

Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie projectscottw
 
What's New for Presentation in Visual Studio 2008 SP1
What's New for Presentation in Visual Studio 2008 SP1What's New for Presentation in Visual Studio 2008 SP1
What's New for Presentation in Visual Studio 2008 SP1ukdpe
 
IBM WebSphere Portal 6.1 Preview - What's New
IBM WebSphere Portal 6.1 Preview - What's NewIBM WebSphere Portal 6.1 Preview - What's New
IBM WebSphere Portal 6.1 Preview - What's NewDvir Reznik
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit frameworkSunil Kumar
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Osconvijayrvr
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Ajax toolkit-framework
Ajax toolkit-frameworkAjax toolkit-framework
Ajax toolkit-frameworkWBUTTUTORIALS
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011Paul Rogers
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011Paul Rogers
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsNuno Caneco
 

Similar to D22 Portlet Development With Open Source Frameworks (20)

Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 
Struts Interceptors
Struts InterceptorsStruts Interceptors
Struts Interceptors
 
Widgets - the Wookie project
Widgets - the Wookie projectWidgets - the Wookie project
Widgets - the Wookie project
 
What's New for Presentation in Visual Studio 2008 SP1
What's New for Presentation in Visual Studio 2008 SP1What's New for Presentation in Visual Studio 2008 SP1
What's New for Presentation in Visual Studio 2008 SP1
 
IBM WebSphere Portal 6.1 Preview - What's New
IBM WebSphere Portal 6.1 Preview - What's NewIBM WebSphere Portal 6.1 Preview - What's New
IBM WebSphere Portal 6.1 Preview - What's New
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
Ajax toolkit framework
Ajax toolkit frameworkAjax toolkit framework
Ajax toolkit framework
 
Krishnagopal Thogiti_Java
Krishnagopal Thogiti_JavaKrishnagopal Thogiti_Java
Krishnagopal Thogiti_Java
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Ibm
IbmIbm
Ibm
 
MVC
MVCMVC
MVC
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Ajax toolkit-framework
Ajax toolkit-frameworkAjax toolkit-framework
Ajax toolkit-framework
 
SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011SilverStripe Meetup 03/03/2011
SilverStripe Meetup 03/03/2011
 
SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011SilverStripe Meetup Presentation 03/03/2011
SilverStripe Meetup Presentation 03/03/2011
 
Struts course material
Struts course materialStruts course material
Struts course material
 
Ram Prasad P.S.S
Ram Prasad P.S.SRam Prasad P.S.S
Ram Prasad P.S.S
 
Stateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystemsStateful mock servers to the rescue on REST ecosystems
Stateful mock servers to the rescue on REST ecosystems
 
Struts
StrutsStruts
Struts
 

D22 Portlet Development With Open Source Frameworks

  • 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.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 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.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. Struts : Forward to JSP request flow
  • 20. Struts : Forward to Action request flow
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67. Avoid Boring People: Lessons from a Life in Science (Hardcover) by James D. Watson (Author)
  • 68. Programming Portlets : From JSR 168 to IBM WebSphere Portal Extensions Ron Lynn , Joey Bernal , Peter Blinstrubas , Stefan Hepper , Usman Memon , Varadarajan ( Varad ) Ramamoorthy

Editor's Notes

  1. Mention that planned availability for Lotus Quickr is late 2Q. Therefore, some of the details in this presentation might change before then.
  2. The typical portlet starts off small and later is enhanced. The business logic is distributed throughout the portlet. The business logic then changes over time causing a rewrite of the portlet. Model View Controller design pattern has been around a long time. This design pattern advocates separating the view aspect from the model and using a controller to orchestrate the flow. Portlet development adds some unique features over the servlet world. Portlet supports modes Portlet must be able to redisplay a view. ( if a user is interacting with other portlets, each portlet on the page must save the state so the view can be redisplayed. ) Options Write the portlet in portal api, but be careful to design the application correctly Develop a custom framework for portlet development. Some customers have done this in the servlet world and have ported it to the portlet world Use an existing framework!
  3. There are numerous features of Portlet Factory specifically intended to ensure the unsurpassed competitive differentiation of WebSphere Portal, as well as contributing to increased customer success and satisfaction. With its tight WebSphere Portal integration and automation via Builders it dramatically simplifies the development of complex portlets – including multi-page transactional composite portlets via integrations to existing applications and systems like SAP and Domino, among others. In addition, Portlet Factory’s patented Profiling technology generates multiple portlet variations from one code base. This feature enables developers to quickly vary portlets across any number of multiple user dimensions (roles, geography, brands) and greatly simplifies code maintenance, by automatically propagating changes. Finally, developers can target multiple computing environments (portal, web, rich-client, phone, PDA) from a single application, which means developers can repurpose applications with minimal development effort. It is also important to understand that Portlet Factory extensible and not limited to the capabilities provided out of the box. For example, J2EE developers can capture an organization’s proprietary APIs as a custom function that they can then add to the tool’s palette so other developers may use it. In doing this, they can ensure all developers are accessing and using the API the same way, enforcing consistent design patterns and architecture.
  4. Mention that planned availability for Lotus Quickr is late 2Q. Therefore, some of the details in this presentation might change before then.
  5. The Jsr168Dispatcher is a controller portlet that is responsible for handling all the client request. You can think about it as something similar to ActionServlet in Struts 1.0 framework. Actions in struts framework are combination of Actions, ActionForm and Model classes. What i meant by that is, Lets say if you want to handle simple form submission, then in Struts 1.0 framework you will have to create 3 different classes. First is ActionForm class which is simple Java Bean with properties matching to your html form. Second is Action class which is a place where you write your business logic and third is Model class that is used for carrying data from Action class to JSP. In case of struts framework your Action class is combination of all three classes. First it will have java bean properties matching your html form, then it will have execute() method where you write your business logic and same Action class object is available to JSP page at the time of markup generation so it also plays the role of Model class. The basic concept of Results is same as that of Struts 1.0 framework, which is that execute() method of your Action class will return result code and based on that framework will dispatch control to JSP for final markup generation. Only difference is that Struts framework wraps request dispatching functionality in separate class in order to maintain clear separation of view layer
  6. Interceptors is this basic concept that allows you to execute some code before or after execute method of your action class. In fact most of the struts framework logic such as setting action properties with values submitted by user or exception handling is implemented in interceptors. The Struts framework also allows you to group set of interceptors together into stack and define the order in which they are executed. Every application will have a default interceptor stack and then your allowed to override that value at individual action level. For example if your application does not need ability to handle file upload then you can remove that interceptor from your applications default interceptor stack. Value stack as name suggests is simply stack of object that is used for carrying data from your action class to JSP page. When using the value stack there is no need to keep track of which scope the target object is in. If you want the attribute “firstname”, then you query the value stack for this attribute. Each stack element, in the provided order, is asked whether it has the property. If it does, then the value is returned and we are done. If not, then the next element down is queried. This continues until the end of the stack is reached. This is a great feature, as you don’t care where the value is – the action, the model, or the request object – you just know that if the value exists it will be returned.
  7. Take a look at this sequence diagram that describes sequence of events that happen when Dispatcher portlet gets request. First thing that dispatcher portlet does is that it finds out action class that should be used to handle this request along with interceptor stack that should be applied to the action. Once the interceptor stack is decided, it starts calling all the interceptors in the stack one by one followed by call to execute method of your action class. Inside the execute method you will execute your business logic, populate model class and based on the outcome of business logic return a result code. Struts framework will use return code of your execute method to find out the location of JSP that should be used to generate final markup Before ending action phase struts framework will store both your action object as well as final location of the JSP in the portlet session. After that whenever dispatcher portlet gets render request instead of re executing action class, it will read location of JSP from the session and forward control to it for markup generation.
  8. But the question is, What if your developing say Stock Ticker portlet and want to query stock service every time for latest update. If that's the case then first you should create a separate action class and add render phase logic in it. Then you should change your struts.xml file so that success code for first action maps to action URL of the second action. Once you do that your action phase request processing will remain same. But in the render phase Struts framework will forward control to your render action, which can execute render logic and then forward control to JSP page for final markup generation. I will show you an example of how to do this on the later slide.
  9. Lets walk through steps that are required to build Struts portlet. You can download sample code for this session from Conference web site. In order to build struts portlet, you will have to create 3 set of files First is I18n and validation related resources. The actual struts configuration is stored in couple of files first is struts.properties and second is struts.xml And since we want to use spring integration, we will have to create applicationContext.xml file. Now lets start taking closer look at each of these files
  10. The Jsr168Dispatcher is main dispatcher portlet so you should set it as portlet class. Value of viewNameSpace initialization parameter defines default namespace for the view mode Value of defaultViewAction defines, default action for view mode. If you want to support any other portlet mode then you need to set parameters for that.
  11. The web.xml file will have two section, in the spring setup configuration first set contextConfigLocation parameter pointing to location of spring context file and then define ContextLoaderListerner which will be responsible for loading your spring configuration. The Struts portlet community wanted to use same tag library as that of servlet environment but problem was that struts tag library has dependency on ServletContext, httpServletrequest and HttpServletResponse object. But these objects are not available in Portlet environment. In order to solve this problem they introduced PreparatorServlet. The way it works is before forwarding control to actual JSP for markup generation, Struts framework will forward control to PreparatorServlet. This servlet will store object of HttpServletRequest, Response and ServletContext in thread local variable. Since the JSP page is called in the same thread as that of the the preparatorServlet, custom tag library will get access to these objects.
  12. This is how your struts configuration file would look like The Struts framework allows you to break your configuration in multiple namespaces to facilitate parallel development. It uses combination of packagename and actionname to uniquely identify action class that will be used to handle particular request. For example in our sample code selectAction class will be used only for handling selectAction in the view mode. If you have more than one developers working on one portlet, you can break your configuration into multiple files and then import those files into your struts.xml. In fact most of the struts framework configuration such as definitions for built-in interceptors and result classes is defined in struts-portlet-default.xml. You should always import struts-portlet-default.xml in your configuration file and extend your packages from struts-portlet-default to take advantage of built in functionality. Take a look at Forward Control to JSP block, in this we are saying that whenever it gets request for deleteAction it should forward control deleteAction class. Since we are using Spring integration actual action class name is defined in spring configuration file. Then we are saying that if delete action returns success framework should forward control to list.jsp. Success is default value for result code so you can omit it if you want. The forward control to action block is example of how you can forward control to some other action class for handling render phase. The interceptor-ref element is example of how you can apply particular interceptor stack to your action class.
  13. In our struts.xml file we have mapped deleteAction url to DelteAction class. So the way it works is when you go to contact spread sheet, select a contact and say delete then struts framework will create new object of DeleteAction, set its contactId property and call its execute() method. In the execute method first we delete that contact then query database to get updated contactList and store it in contactList variable that list.jsp will use to display contact spreadsheet. Did you notice that the execute() method does not get object of either PortletRequest or PortletResponse, this is because one of the design goals of Struts frameworks was to make unit testing easy. In the unit test case of DeleteAction, you can create its object set contactId and call execute() method, and there is no need to mock portletrequest, response objects. The way portlet containers work is that they use separate thread for handling every request. The Struts framework tries to take advantage of this fact by storing all the objects related to the request such as portlet request, response or session in ThreadLocal object and the PortletActionContext class provides static methods to access these object anywhere you want in current request. But as we know static methods make unit testing difficult so Struts framework defines one more way to access portlet specific object. Lets say your interested in PortletPreferences object, if that's the case then first you should implement PortletPreferencesAware interface in your action and then define portletPreferences as bean property in your action class along with setter method. If you do that then at runtime framework will inject portletpreferences object in your action class.
  14. This is another example of action class. Now if your HTML form has more than 4-5 parameters then instead of adding each of these parameter as property in your action class you may want to create separate JavaBeans and add those input parameters as properties into it. In our sample code contact form has 5 fields so we had created contact bean with 5 properties. You will have to change your JSP page to use contact.propertyname expression for getting or setting properties from contact bean, Also we want to delegate control to SelectAction for actual markup generation. So we don’t need model class related functionality in our Action class. Only thing that our execute method does is insert contact then return SUCCESS return code. The Struts framework will forward control to SelectAction for handling render phase and it will take care of populating contactList variable before forwarding control to list.jsp for actual markup generation.
  15. This is how typical JSP page looks like. The Struts JSPs use OGNL as expression language for getting and setting properties from beans. OGNL does everything that JSP expression language does and in addition to that it has some advanced features such as projections, filters Projection is this cool feature that allows you to set project particular property of bean into temporary collection. For example, Lets say you have this list of contact objects and you want to display first names of all the contacts in combo box, in normal case you will have to write some JSP scriplet for this. But In OGNL you can use projections to project firstName property of every contact objects into another collection and then use that collection for displaying firstName combo. Developers of the struts tag library had couple of design goals. First they wanted to provide consistent look and feel through out the application and second they wanted to provide extendible tags. So the way struts tag library works is every custom tag has one Java file and one template file associated with it. For example when you use texfield tag first control will go to TextField.java which will perform some basic logic such as reading value of the java bean property from value stack and then it will forward control to TextField.ftl which is freemarker template file for actual markup generation of input tag. In addition to this Struts tag library has concept of theme which allows you to group set of template files that provide similar look and feel. Did you notice that our JSP page does not use any HTML markup elements such as <table>,<tr> or td that is because we are using XHTML theme and it takes care of displaying forms in two column layout.
  16. The XHTML implementation of The form tag is responsible for creating the form element as well as the surrounding table. The rest of the form element tags are responsible for creating one row each in the table. In which label is displayed on the left and actual form element is displayed on the right. In addition to being responsible for creating a single row, each tag is also responsible for displaying any validation or type conversion errors that may be associated with that field. If you don't want Struts tag library to create two column layout for you, you can change your theme to simple and take complete control on markup.
  17. In addition to simple form tags struts tag library also provides few out of box widgets such as date picker. In our sample code we are using datetimepicker tag for date of birth input The datetimepicker tag generates 3 things first a label on the left hand side, after that input box, followed by button. When you click on the button it will open a calendar control like this that you can use for selecting date.
  18. In addition to powerful tag library struts framework also has support for different view technologies such as Freemarker and Velocity. Take a look at how you can create insert.jsp page using either Velocity or Freemarker templating language. Good thing about struts is that it provides native access to struts tags from both Freemarker and Velocity.
  19. Ability to validate user input is another common requirements and Struts framework provides quite few choices for how you want to implement your validation rules.. If you decide to use programmatic validation then you can implement validate() method in your Action class and add your validation rules there. But if you decide to use declarative validation then you will have to create ActionClassName-validation.xml file in the same package as that of your action class. For example take a look at how validation.xml file for our Insert Action As you can see the concept is very much similar to Apache Commons validation framework but it is bit more flexible. If you decide to implement your custom validation rules then you can create class implementing Validation interface and register it with validation framework.
  20. Other common problem in web applications is that web is type agnostic i.e. everything is string but java is strictly typed language. So you need some mechanism to convert string data into specific type and other way round. In Struts routine type conversion such as int, double, date is transparent. For example, in our sample code date of birth field is date of type. So only thing that you should do is declare it as date type while creating contact java bean and struts framework will take care of converting string to date when setting form values and converting from date to string when displaying data to user. Another good thing about type conversion is that struts framework also takes care of locale specific formatting of date type.
  21. Struts framework provides simple plug-in architecture so that developers can extend the framework by just adding a simple JAR to web applications class path. In fact most of the optional features such as Spring and Tiles integration are implemented as plug-in. If you remember even struts 1.0 has concept of plug-in, that allowed you to execute some code at application startup and shutdown. But in Struts 2.0 plug-ins are much more powerful. Struts framework defines 12 different extension points that you can extend in your plug-in. For example Spring plug-in provides its own object factory that allows you to use Spring framework for actual object creation
  22. In our sample code we are using Spring framework as object factory. What that means is whenever Struts framework wants to create new object for either Action or Result class it will ask Spring framework for that. You can configure this by adding entry for struts.objectFactory in struts.properties file. For example when Struts framework gets selectAction request it will ask Spring framework for object of SelectContac class. Now we have defined selectContact as bean in spring configuration file and it has dependency on contactDAO. So Spring framework will first create object of selectAction class inject contactDAO object in it and then return that object to struts for further processing. In our sample code we talked about how you can use Spring framework for integration between View and data access layer. But Spring framework also has its own implementation of Portlet MVC framework, my friend Sean is going to talk about it in detail.
  23. Mention that planned availability for Lotus Quickr is late 2Q. Therefore, some of the details in this presentation might change before then.