SlideShare une entreprise Scribd logo
1  sur  80
Building Java Portlets with Spring MVC ,[object Object],[object Object],[object Object],[object Object],[object Object],© Copyright Unicon, Inc., 2008.  Some rights reserved.  This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. To view a copy of this license, visit  http://creativecommons.org/licenses/by-nc-sa/3.0/us/
Speaker Background ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet Review ,[object Object]
Diagram from Java ™  Portlet Specification, Version 2.0 Public Draft
Java Portlet Standards ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlets and Servlets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multiple Request Phases ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Diagram from Java ™  Portlet Specification, Version 2.0 Public Draft
Portlet Modes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet Window States ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet URL Handling ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Spring MVC Framework ,[object Object]
Using A Framework ,[object Object],[object Object],[object Object],[object Object]
Spring MVC ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dispatcher (Servlet/Portlet) Request Handler Mapping View Resolver Response Controller View ModelAndView Map (Model) viewName
Spring Views ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Spring Controllers ,[object Object],[object Object],[object Object],[object Object]
Other MVC Features ,[object Object],[object Object],[object Object],[object Object],[object Object]
Spring Web MVC Resources ,[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]
Spring Portlet MVC Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Configuring Spring Portlet MVC ,[object Object]
web.xml: ContextLoaderLister ,[object Object],[object Object],<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> No different from Servlet Spring Web MVC
web.xml: contextConfigLocation ,[object Object],<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/service-context.xml /WEB-INF/data-context.xml </param-value> </context-param> No different from Servlet Spring Web MVC
web.xml: ViewRendererServlet ,[object Object],<servlet> <servlet-name>view-servlet</servlet-name> <servlet-class> org.springframework.web.servlet.ViewRendererServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>view-servlet</servlet-name> <url-pattern>/WEB-INF/servlet/view</url-pattern> </servlet-mapping>
ViewRendererServlet ,[object Object],[object Object],[object Object],[object Object]
portlet.xml <portlet> <portlet-name>example</portlet-name> <portlet-class> org.springframework.web.portlet.DispatcherPortlet </portlet-class> <init-param> <name> contextConfigLocation </name> <value> /WEB-INF/context/example-portlet.xml </value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> <portlet-mode>edit</portlet-mode> <portlet-mode>help</portlet-mode> </supports> <portlet-info> <title>Example Portlet</title> </portlet-info> </portlet>
DispatcherPortlet ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
View Resolver &  Exception Resolver ,[object Object]
Resolving Views ,[object Object],<bean id=&quot;viewResolver&quot; class=&quot;org.springframework.web.servlet.view. InternalResourceViewResolver&quot;> <property name=&quot;cache&quot; value=&quot;false&quot; /> <property name=&quot;viewClass&quot; value=&quot;org.springframework.web.servlet.view.JstlView&quot; /> <property name=&quot;prefix&quot; value=&quot;/WEB-INF/jsp/&quot; /> <property name=&quot;suffix&quot; value=&quot;.jsp&quot; /> </bean> Can be shared between multiple portlets & servlets
Map  Exceptions  to  View Names  (used by View Resolver) <bean id=&quot;exceptionResolver&quot; class=&quot;org.springframework.web.portlet.handler. SimpleMappingExceptionResolver&quot;> <property name=&quot;defaultErrorView&quot; value=&quot;error&quot;/> <property name=&quot;exceptionMappings&quot;> <value> javax.portlet.PortletSecurityException=unauthorized javax.portlet.UnavailableException=unavailable </value> </property> </bean> Resolving Exceptions ,[object Object]
More on Resolvers ,[object Object],[object Object],[object Object]
Internationalization & Localization ,[object Object]
Internationalization ,[object Object],button.home = Home button.edit = Edit button.next = Next button.previous = Previous button.finish = Finish button.cancel = Cancel exception.notAuthorized.title = Access Not Permitted exception.notAuthorized.message = You do not have permission to access this area.
MessageSource ,[object Object],<bean id=&quot;messageSource&quot; class=&quot;org.springframework.context.support. ResourceBundleMessageSource&quot;> <property name=&quot;basenames&quot;> <list> <value>messages</value> </list> </property> </bean>
Using Messages in Views ,[object Object],[object Object],<%@ taglib prefix=&quot;spring&quot; uri=&quot;http://www.springframework.org/tags&quot; %> ... <p><spring:message code=&quot;exception.contactAdmin&quot;/></p>
Localization ,[object Object],[object Object],[object Object],[object Object],[object Object]
Handler Mapping ,[object Object]
HandlerMapping ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Most of these become obsolete in Spring 2.5 because the Annotation-based Mapping is now preferred
PortletModeHandlerMapping <bean id=&quot;portletModeHandlerMapping&quot; class=&quot;org.springframework.web.portlet.handler. PortletModeHandlerMapping&quot;> <property name=&quot;portletModeMap&quot;> <map> <entry key=&quot;view&quot; value-ref=&quot;viewController&quot;/> <entry key=&quot;edit&quot; value-ref=&quot;editController&quot;/> <entry key=&quot;help&quot; value-ref=&quot;helpController&quot;/> </map> </property> </bean> <bean id=&quot;viewController&quot; class=&quot;ViewController&quot;/> ...
ParameterHandlerMapping ,[object Object],<bean id=&quot;handlerMapping“ class=&quot;org.springframework.web.portlet.handler. ParameterHandlerMapping&quot;> <property name=&quot;parameterMap&quot;> <map> <entry key=&quot;add&quot; value-ref=&quot;addHandler&quot;/> <entry key=&quot;remove&quot; value-ref=&quot;removeHandler&quot;/> </map> </property> </bean>
PortletModeParameterHandlerMapping <bean id=&quot;handlerMapping&quot; class=&quot;…PortletModeParameterHandlerMapping&quot;>  <property name=&quot;portletModeParameterMap&quot;> <map> <entry key=&quot;view&quot;> <map> <entry key=&quot;add&quot; value-ref=&quot;addHandler&quot;/> <entry key=&quot;remove&quot; value-ref=&quot;removeHandler&quot;/> </map> </entry> <entry key=&quot;edit&quot;> <map> <entry key=&quot;prefs” value-ref=&quot;prefsHandler&quot;/> </map> </entry> </map> </property> </bean>
More on  HandlerMapping ,[object Object],[object Object]
Mapping and Portlet Lifecycle ,[object Object],[object Object],[object Object]
Controllers & AbstractController ,[object Object]
Controllers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Most of these become obsolete in Spring 2.5 because the Annotation-based Mapping is now preferred
The Controller Interface public interface  Controller  { ModelAndView  handleRenderRequest  ( RenderRequest request, RenderResponse response)  throws Exception; void  handleActionRequest  ( ActionRequest request, ActionResponse response)  throws Exception; }
PortletModeNameViewController ,[object Object],[object Object],[object Object]
AbstractController ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Form Controllers ,[object Object]
Command Controllers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SimpleFormController ,[object Object],[object Object],[object Object],[object Object],[object Object]
SimpleFormController Form ,[object Object],[object Object],[object Object],[object Object],[object Object]
SimpleFormController Submit ,[object Object],[object Object],[object Object],[object Object]
AbstractWizardFormController ,[object Object],[object Object],[object Object],[object Object],[object Object]
More AbstractWizardFormController ,[object Object],[object Object],[object Object],[object Object],[object Object]
Annotation-Based Controllers ,[object Object]
Annotation-Based Controllers ,[object Object],[object Object],[object Object],[object Object]
Annotation Bean Definitions <context:annotation-config/> <bean class=&quot;org.springframework.web.portlet.mvc. annotation.DefaultAnnotationHandlerMapping&quot;> <property name=&quot;interceptors&quot;> <bean class=&quot;org.springframework.web.portlet.handler. ParameterMappingInterceptor&quot;/> </property> </bean> <bean class=&quot; org.sample.MyView Controller&quot;/> <bean class=&quot;org.sample.MyEditController&quot;/> <bean class=&quot;org.sample.MyHelpController&quot;/>
Spring MVC Annotations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dispatching Annotation Examples @Controller @RequestMapping(&quot;VIEW&quot;) @SessionAttributes(&quot;item&quot;) public class  MyViewController  { @RequestMapping public String listItems(Model model) { model.addAttribute(&quot;items&quot;,  this.itemService.getAllItems()); return &quot;itemList&quot;; } @RequestMapping(params=&quot;action=view&quot;) public String viewPet( @RequestParam(&quot;item&quot;)  int itemId, Model model) { model.addAttribute(&quot;item&quot;, this.itemService.getItem(itemId)); return &quot;itemDetails&quot;; } ...
Dispatching Annotation Examples ... @ModelAttribute(&quot;dateFormat&quot;) protected String dateFormat(PortletPreferences prefs) { return preferences.getValue(&quot;dateFormat&quot;,  itemService.DEFAULT_DATE_FORMAT); } @InitBinder public void initBinder(PortletRequestDataBinder binder, PortletPreferences preferences) { String format = preferences.getValue(&quot;dateFormat&quot;, ItemService.DEFAULT_DATE_FORMAT); SimpleDateFormat dateFormat =  new SimpleDateFormat(formatString); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } ...
Handler Interceptors ,[object Object]
HandlerInterceptor ,[object Object],[object Object],[object Object],[object Object]
HandlerInterceptor Interface public interface  HandlerInterceptor  { boolean  preHandleAction ( ActionRequest request, ActionResponse response, Object handler) throws Exception; void  afterActionCompletion ( ActionRequest request, ActionResponse response, Object handler, Exception ex) throws Exception; boolean  preHandleRender ( RenderRequest request, RenderResponse response, Object handler) throws Exception; void  postHandleRender ( RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws Exception; void  afterRenderCompletion ( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception; }
Useful Portlet Interceptors ,[object Object],[object Object]
Configuring Interceptors <bean id=&quot;parameterMappingInterceptor&quot;  class=&quot;org.springframework.web.portlet.handler. ParameterMappingInterceptor&quot; /> <bean id=&quot;portletModeParameterHandlerMapping&quot; class=&quot;org.springframework.web.portlet.handler. PortletModeParameterHandlerMapping&quot;> <property name=&quot;interceptors&quot;> <list> <ref bean=&quot;parameterMappingInterceptor&quot;/> </list> </property> <property name=&quot;portletModeParameterMap&quot;> ... </property> </bean>
File Uploads & Redirects ,[object Object]
Handling File Uploads ,[object Object],[object Object],[object Object],[object Object],[object Object],<bean id=&quot;portletMultipartResolver&quot; class=&quot;org.springframework.web.portlet.multipart. CommonsPortletMultipartResolver&quot;> <property name=&quot;maxUploadSize“ value=“2048”/> </bean>
Performing Redirects ,[object Object],[object Object],[object Object]
Adapting Other Frameworks ,[object Object]
Adapting Other Frameworks ,[object Object],[object Object],[object Object],[object Object],[object Object]
Reuse Existing Portlets ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet 2.0 (JSR 286) Support ,[object Object]
Major Changes in Portlet 2.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet 2.0 In Spring 3.0 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Annotations for Portlet 2.0 Support ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Portlet 2.0 Examples @ActionMapping(”delete”) public void deleteItem(...) { ... } @EventMapping(”reload”) public void reloadData(...) { ... } @RenderMapping(&quot;maximized&quot;, params=&quot;action=search&quot;) public String displaySearch(...) { ... } @ResourceMapping(”picklist”) public ModelAndView pickList (...) {...}
Questions & Answers John A. Lewis Chief Software Architect Unicon, Inc. [email_address] www.unicon.net

Contenu connexe

Tendances

Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
Guo Albert
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
guest764934
 
Sun JSF Presentation
Sun JSF PresentationSun JSF Presentation
Sun JSF Presentation
Gaurav Dighe
 

Tendances (20)

Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring MVC Architecture Tutorial
Spring MVC Architecture TutorialSpring MVC Architecture Tutorial
Spring MVC Architecture Tutorial
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Java Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC FrameworkJava Server Faces + Spring MVC Framework
Java Server Faces + Spring MVC Framework
 
Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)Spring MVC 3.0 Framework (sesson_2)
Spring MVC 3.0 Framework (sesson_2)
 
SpringMVC
SpringMVCSpringMVC
SpringMVC
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Struts Introduction Course
Struts Introduction CourseStruts Introduction Course
Struts Introduction Course
 
Jsf2.0 -4
Jsf2.0 -4Jsf2.0 -4
Jsf2.0 -4
 
Jsf intro
Jsf introJsf intro
Jsf intro
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
Spring framework in depth
Spring framework in depthSpring framework in depth
Spring framework in depth
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Sun JSF Presentation
Sun JSF PresentationSun JSF Presentation
Sun JSF Presentation
 

Similaire à Spring Portlet MVC

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
Sunil Patil
 
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
Sunil Patil
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe
 

Similaire à Spring Portlet MVC (20)

Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC Seminar
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
MVC
MVCMVC
MVC
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
 
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
 
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
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
 
JavaEE6 my way
JavaEE6 my wayJavaEE6 my way
JavaEE6 my way
 
JEE Course - The Web Tier
JEE Course - The Web TierJEE Course - The Web Tier
JEE Course - The Web Tier
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Marata
MarataMarata
Marata
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
 
Spring MVC 5 & Hibernate 5 Integration
Spring MVC 5 & Hibernate 5 IntegrationSpring MVC 5 & Hibernate 5 Integration
Spring MVC 5 & Hibernate 5 Integration
 
MVC 4
MVC 4MVC 4
MVC 4
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - Indiandotnet
 
Session 1
Session 1Session 1
Session 1
 

Plus de John Lewis

Jasig uMobile - Open Source Enterprise Mobile Campus Solution
Jasig uMobile - Open Source Enterprise Mobile Campus SolutionJasig uMobile - Open Source Enterprise Mobile Campus Solution
Jasig uMobile - Open Source Enterprise Mobile Campus Solution
John Lewis
 
Agile Engineering
Agile EngineeringAgile Engineering
Agile Engineering
John Lewis
 

Plus de John Lewis (13)

Jasig uMobile - Open Source Enterprise Mobile Campus Solution
Jasig uMobile - Open Source Enterprise Mobile Campus SolutionJasig uMobile - Open Source Enterprise Mobile Campus Solution
Jasig uMobile - Open Source Enterprise Mobile Campus Solution
 
IMS LIS Outcomes and Sakai: Standardizing Grade Exchange
IMS LIS Outcomes and Sakai: Standardizing Grade ExchangeIMS LIS Outcomes and Sakai: Standardizing Grade Exchange
IMS LIS Outcomes and Sakai: Standardizing Grade Exchange
 
New Opportunites to Connect Learning with LIS and LTI
New Opportunites to Connect Learning with LIS and LTINew Opportunites to Connect Learning with LIS and LTI
New Opportunites to Connect Learning with LIS and LTI
 
Open Source Your Project (With Jasig)
Open Source Your Project (With Jasig)Open Source Your Project (With Jasig)
Open Source Your Project (With Jasig)
 
Sakai uPortal Integration Options
Sakai uPortal Integration OptionsSakai uPortal Integration Options
Sakai uPortal Integration Options
 
Agile Engineering
Agile EngineeringAgile Engineering
Agile Engineering
 
Scrum Process
Scrum ProcessScrum Process
Scrum Process
 
Securing Portlets With Spring Security
Securing Portlets With Spring SecuritySecuring Portlets With Spring Security
Securing Portlets With Spring Security
 
Shibboleth Guided Tour Webinar
Shibboleth Guided Tour WebinarShibboleth Guided Tour Webinar
Shibboleth Guided Tour Webinar
 
Leveraging Open Source
Leveraging Open SourceLeveraging Open Source
Leveraging Open Source
 
Java Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) SpecificationJava Portlet 2.0 (JSR 286) Specification
Java Portlet 2.0 (JSR 286) Specification
 
Open Source Licensing
Open Source LicensingOpen Source Licensing
Open Source Licensing
 
Real World Identity Managment
Real World Identity ManagmentReal World Identity Managment
Real World Identity Managment
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Spring Portlet MVC

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Diagram from Java ™ Portlet Specification, Version 2.0 Public Draft
  • 7.
  • 8.
  • 9.
  • 10. Diagram from Java ™ Portlet Specification, Version 2.0 Public Draft
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Dispatcher (Servlet/Portlet) Request Handler Mapping View Resolver Response Controller View ModelAndView Map (Model) viewName
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28. portlet.xml <portlet> <portlet-name>example</portlet-name> <portlet-class> org.springframework.web.portlet.DispatcherPortlet </portlet-class> <init-param> <name> contextConfigLocation </name> <value> /WEB-INF/context/example-portlet.xml </value> </init-param> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> <portlet-mode>edit</portlet-mode> <portlet-mode>help</portlet-mode> </supports> <portlet-info> <title>Example Portlet</title> </portlet-info> </portlet>
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41. PortletModeHandlerMapping <bean id=&quot;portletModeHandlerMapping&quot; class=&quot;org.springframework.web.portlet.handler. PortletModeHandlerMapping&quot;> <property name=&quot;portletModeMap&quot;> <map> <entry key=&quot;view&quot; value-ref=&quot;viewController&quot;/> <entry key=&quot;edit&quot; value-ref=&quot;editController&quot;/> <entry key=&quot;help&quot; value-ref=&quot;helpController&quot;/> </map> </property> </bean> <bean id=&quot;viewController&quot; class=&quot;ViewController&quot;/> ...
  • 42.
  • 43. PortletModeParameterHandlerMapping <bean id=&quot;handlerMapping&quot; class=&quot;…PortletModeParameterHandlerMapping&quot;> <property name=&quot;portletModeParameterMap&quot;> <map> <entry key=&quot;view&quot;> <map> <entry key=&quot;add&quot; value-ref=&quot;addHandler&quot;/> <entry key=&quot;remove&quot; value-ref=&quot;removeHandler&quot;/> </map> </entry> <entry key=&quot;edit&quot;> <map> <entry key=&quot;prefs” value-ref=&quot;prefsHandler&quot;/> </map> </entry> </map> </property> </bean>
  • 44.
  • 45.
  • 46.
  • 47.
  • 48. The Controller Interface public interface Controller { ModelAndView handleRenderRequest ( RenderRequest request, RenderResponse response) throws Exception; void handleActionRequest ( ActionRequest request, ActionResponse response) throws Exception; }
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60. Annotation Bean Definitions <context:annotation-config/> <bean class=&quot;org.springframework.web.portlet.mvc. annotation.DefaultAnnotationHandlerMapping&quot;> <property name=&quot;interceptors&quot;> <bean class=&quot;org.springframework.web.portlet.handler. ParameterMappingInterceptor&quot;/> </property> </bean> <bean class=&quot; org.sample.MyView Controller&quot;/> <bean class=&quot;org.sample.MyEditController&quot;/> <bean class=&quot;org.sample.MyHelpController&quot;/>
  • 61.
  • 62. Dispatching Annotation Examples @Controller @RequestMapping(&quot;VIEW&quot;) @SessionAttributes(&quot;item&quot;) public class MyViewController { @RequestMapping public String listItems(Model model) { model.addAttribute(&quot;items&quot;, this.itemService.getAllItems()); return &quot;itemList&quot;; } @RequestMapping(params=&quot;action=view&quot;) public String viewPet( @RequestParam(&quot;item&quot;) int itemId, Model model) { model.addAttribute(&quot;item&quot;, this.itemService.getItem(itemId)); return &quot;itemDetails&quot;; } ...
  • 63. Dispatching Annotation Examples ... @ModelAttribute(&quot;dateFormat&quot;) protected String dateFormat(PortletPreferences prefs) { return preferences.getValue(&quot;dateFormat&quot;, itemService.DEFAULT_DATE_FORMAT); } @InitBinder public void initBinder(PortletRequestDataBinder binder, PortletPreferences preferences) { String format = preferences.getValue(&quot;dateFormat&quot;, ItemService.DEFAULT_DATE_FORMAT); SimpleDateFormat dateFormat = new SimpleDateFormat(formatString); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } ...
  • 64.
  • 65.
  • 66. HandlerInterceptor Interface public interface HandlerInterceptor { boolean preHandleAction ( ActionRequest request, ActionResponse response, Object handler) throws Exception; void afterActionCompletion ( ActionRequest request, ActionResponse response, Object handler, Exception ex) throws Exception; boolean preHandleRender ( RenderRequest request, RenderResponse response, Object handler) throws Exception; void postHandleRender ( RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws Exception; void afterRenderCompletion ( RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception; }
  • 67.
  • 68. Configuring Interceptors <bean id=&quot;parameterMappingInterceptor&quot; class=&quot;org.springframework.web.portlet.handler. ParameterMappingInterceptor&quot; /> <bean id=&quot;portletModeParameterHandlerMapping&quot; class=&quot;org.springframework.web.portlet.handler. PortletModeParameterHandlerMapping&quot;> <property name=&quot;interceptors&quot;> <list> <ref bean=&quot;parameterMappingInterceptor&quot;/> </list> </property> <property name=&quot;portletModeParameterMap&quot;> ... </property> </bean>
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79. Portlet 2.0 Examples @ActionMapping(”delete”) public void deleteItem(...) { ... } @EventMapping(”reload”) public void reloadData(...) { ... } @RenderMapping(&quot;maximized&quot;, params=&quot;action=search&quot;) public String displaySearch(...) { ... } @ResourceMapping(”picklist”) public ModelAndView pickList (...) {...}
  • 80. Questions & Answers John A. Lewis Chief Software Architect Unicon, Inc. [email_address] www.unicon.net