Your SlideShare is downloading. ×
Next Generation Spring MVC with Spring Roo
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Next Generation Spring MVC with Spring Roo

5,631
views

Published on

Next Generation Spring MVC with Spring Roo

Next Generation Spring MVC with Spring Roo

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,631
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
107
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Chicago, October 19 - 22, 2010 Next Generation Spring MVC with Spring Roo Stefan Schmidt & Keith Donald
  • 2. Agenda •  Mastering Spring MVC with Spring Roo •  Keeping up with project domain changes •  View scaffolding & customization •  How social is your application? •  Does your application speak Spanish? •  How secure is your application? •  Going with the flow
  • 3. Mastering Spring MVC with Spring ROO
  • 4. Master Spring MVC with Spring Roo •  Best-practice Spring MVC out of the box –  REST support –  Round tripping of View artifacts –  Strong Templating support –  Theming support –  Pagination support –  i18n & i11n built-in –  Form validation based on JSR 303 –  Tested on popular Web browsers & Web containers
  • 5. REST Support - Form Handling Resource GET PUT POST DELETE Collection URI such as http://tld.com/pizzashop/ toppings List members of the collection (pagination possible) Not used. Create new resource Not used. Member URI such as http://tld.com/pizzashop/ toppings/5 Retrieve addressed resource Update the addressed resource Not used. Delete the addressed resource Member URI such as http://tld.com/pizzashop/ toppings?form Creates a initialized but empty form for the resource (create use-case) Not used. Not used. Not used. Member URI such as http://tld.com/pizzashop/ toppings/5?form Creates an initialized form pre- populated with data of resource (update use-case) Not used. Not used. Not used.
  • 6. REST Support - Customizable JSON Binding •  Roo offers two methods for integrating JSON binding: –  Option 1: Spring MVC detects Jackson •  @RequestBody & @ResponseBody •  ContentNegotiatingViewResolver –  Option 2: Built-in JSON handling managed in domain layer •  Customizable FlexJson integration
  • 7. Spring Roo MVC Scaffolding Options •  Generation of Web artifacts –  controller scaffold •  generate a controller for a given entity –  controller all •  generate controllers for all entities without an existing controller –  controller class •  generate a simple Spring @MVC controller with a post and a get method
  • 8. DEMO View scaffolding
  • 9. Keeping up with project domain changes
  • 10. Keeping up with project domain changes Past: Roo 1.0.x all-or-nothing approach –  either manage view templates manually after initial scaffold, –  or abstain from customization of JSP view artifacts Future: Roo 1.1.x intelligent round-tripping –  introduction of customizable tag library –  reduction of JSP code by ~90% –  JSPs are now user editable
  • 11. JSP View Round-Tripping •  Customizable Tag libraries –  every tag has three common attributes •  ‘id’ is used by Roo to identify tags via Xpath (required) •  ‘z’ is used to store a hash code which determines who ‘owns’ the tag (required) •  ‘render’ can be used to omit form rendering of the tag
  • 12. JSP View Round Tripping Cont. Example jspx file: <form:update  id="fu_com_foo_Person"  modelAttribute="person"  path="/people"                                  z="3lX+WZW4CQVBb7OlvB0AvdgbGRQ=">      <field:datetime  dateTimePattern="${person_birthday_date_format}"  field="birthDay"                                            id="c_com_foo_Person_birthDay"  z="dXnEoWaz4rI4CKD9mlz+clbSUP4="/>      <field:select  field="car"  id="c_com_foo_Person_car"  itemValue="id"  items="${cars}"                                            path="/cars"  z="z2LA3LvNKRO9OISmZurGjEczHkc="/>      <field:select  field="cars"  id="c_com_foo_Person_cars"  itemValue="id"  items="${cars}"                                            multiple="true"  path="/cars"  z="c0rdAISxzHsNvJPFfAmEEGz2LU4="/>   </form:update>  
  • 13. Hash Key Calculation Things included in hash code calulation Things not included in hash key calculation Element name (name only, not namespace) Name space of element names Attribute names present in element White spaces used in the element Attribute values present in the element Potential child elements The ‘z’ attribute and its value Any attribute (and value) whose name starts with '_' The order of the attributes does not contribute to the value of a hash key
  • 14. DEMO View round-tripping
  • 15. View Scaffolding & Customization
  • 16. View Scaffolding & Customization •  Roo MVC views offer numerous customization points: –  Spring Theming support via CSS (and graphics) –  Global template structural adjustments via Tiles –  Page structure changes in JSP pages –  Portable templates through JSP tag library – 
  • 17. Roo Default Tag Library •  Spring JavaScript •  Dojo Toolkit •  Easy XML-based tags (no .java required) •  Tags for –  form handling –  field rendering –  util (pagination, page decoration, language selection, …)
  • 18. DEMO View customization
  • 19. How social is your application?
  • 20. Embedding Social Features
  • 21. Embedding Social Features Roo offers two shell commands to install features: •  Option 1 –  web mvc embed generic --url http://www.youtube.com/watch?v=Gb1Z0lfl52I –  automatic detection of social feature based on domain name –  easiest way to get a feature embedded •  Option 2 –  web mvc embed map --provider GOOGLE_MAPS --location "Sydney, Australia” –  web mvc embed finances --stockSymbol VMW –  specification of type of social feature –  better supported through tab completion
  • 22. DEMO Embedding Social Features
  • 23. Does your app speak Spanish?
  • 24. i18n & l11n Support •  Roo MVC scaffolding now defaults to locale ‘en’ –  install more languages with ‘web mvc install --language es’ command –  choice between 6 languages –  very easy publishing of new languages •  addon create i18n --topLevelPackage com.foo.ru --locale ru --messageBundle <path-to>/messages_fr.properties •  see slides for session ‘Hello, RooBot: Writing and Distributing Your Own Spring Roo Add-Ons’
  • 25. i18n & l11n Support •  Roo MVC scaffolding uses two artifacts for managing localization (l11n) & internationalization (i18n) –  application.properties •  application / domain specific messages •  managed by Roo round tripping –  messages_XX.properties •  non- application / domain specific messages •  never touched by Roo after initial install
  • 26. How secure is your application?
  • 27. Integrating Spring Security •  One simple command –  security setup –  URL-based security with applicationContext-security.xml <http  auto-­‐config="true"  use-­‐expressions="true">      <form-­‐login  login-­‐processing-­‐url="/resources/j_spring_security_check"  login-­‐                                    page="/login"  authentication-­‐failure-­‐url="/login?login_error=t"/>      <logout  logout-­‐url="/resources/j_spring_security_logout"/>      <intercept-­‐url  pattern="/choices/**"  access="hasRole('ROLE_ADMIN')”/>        <intercept-­‐url  pattern="/resources/**"  access="permitAll"  />      <intercept-­‐url  pattern="/**"  access="permitAll"  />   </http>  
  • 28. Going with the Flow
  • 29. Spring Web Flow •  One simple command –  web flow –  integrates Spring Web Flow into application
  • 30. DEMO Securing Your Application Spring Web Flow Selenium Tests
  • 31. Resources & Links •  Home → http://www.springsource.org/roo –  Contains links to all other resources •  Forum → http://forum.springsource.org –  Roo team actively monitor forum and answer queries •  Issues → http://jira.springframework.org/browse/ROO •  Twitter → @SpringRoo –  Follow for updates, or include in tweets so we see them •  Contact details –  Keith Donald @kdonald, kdonald@vmware.com –  Stefan Schmidt @schmidtstefan, schmidts@vmware.com
  • 32. Q&A