Unlock Enterprise Databases to Create New Online Services with Magnolia and Grails

566 views

Published on

This webinar is extremely useful for Java and Grails developers of all levels, as well as IT professionals and system integrators interested in application integration for business solutions.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
566
On SlideShare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Unlock Enterprise Databases to Create New Online Services with Magnolia and Grails

  1. 1. Magnolia + Grails = Maglev Peter Wayner WebCast1 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  2. 2. Maglev Table-driven data with Grails Template-driven pages with Magnolia Peter Wayner WebCast2 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  3. 3. Is it possible to mix the ease of Grails with the Magnolia?3 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  4. 4. Yes! With Maglev, a plugin4 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  5. 5. Why? Grails is a Java-based Web App Framework Grails is open source Grails is template-driven (GSP and JSP) Grails is extendable with plugins.5 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  6. 6. Magnolia is Similar Magnolia is a Java-based Content Management System Magnolia is open source Magnolia is template-driven (Freemarker and JSP) Magnolia is extendable with plugins.6 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  7. 7. Invention Developed by Kimmo Björnsson and Åke Argéus, Lead Developers, Bonheur AB They saw that the two tools that complemented each other well. They turned Magnolia into a plugin that lives in Grails.7 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  8. 8. Let’s mix them together Maglev bundles together all of Magnolia into a Grails plugin. It’s plugged into Grails, but Magnolia ends up driving the front. Grails handles the table-driven objects. Magnolia handles the templates8 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  9. 9. Benefits Rapid prototyping. Grails builds databases quickly. Data/Content integration. Magnolia knits together content well. Separation of code from presentation. (Grails handles backend, Magnolia the front.)9 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  10. 10. Example Affiliate marketing for a web site needs a table of URLs. If someone clicks on the URL, the web site gets some revenue. Lets store them in a table. Display them in a Magnolia template.10 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  11. 11. Grails just needs an object definition class AffiliateItem { String name // The item being advertised. Date dateCreated // When started. String url // Where the item can be purchased. String shortDescription // A short description. String longDescription // A long description. Date startDate // When available. Date stopDate // The last day it is available. }11 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  12. 12. Grails lets you add constraints class AffiliateItem { static constraints = { name blank:false, unique:true url url:true,blank:false, unique:true shortDescription maxSize:26 longDescription widget:textarea } /// ….12 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  13. 13. Just add a controller class AffiliateItemController{ static scaffold = true }13 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  14. 14. One button and Grails Finishes Grails builds CRUD (create, update, delete) routines for object tables. You start up Grails and it analyzes your object definition. Then it creates all of the code necessary to let you build up tables filled with the objects.14 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  15. 15. Just some of the code built by Grails for free package testgrails1 import org.springframework.dao.DataIntegrityViolationException class AffiliateItemController { static allowedMethods = [save: "POST", update: "POST", delete: "POST"] def index() { redirect(action: "list", params: params) } def list() { params.max = Math.min(params.max ? params.int(max) : 10, 100) [affiliateItemInstanceList: AffiliateItem.list(params), affiliateItemInstanceTotal: AffiliateItem.count()] } def create() { [affiliateItemInstance: new AffiliateItem(params)] } def save() { def affiliateItemInstance = new AffiliateItem(params) if (!affiliateItemInstance.save(flush: true)) { render(view: "create", model: [affiliateItemInstance: affiliateItemInstance]) return } flash.message = message(code: default.created.message, args: [message(code: affiliateItem.label, default: AffiliateItem), affiliateItemInstance.id]) redirect(action: "show", id: affiliateItemInstance.id) } def show() { def affiliateItemInstance = AffiliateItem.get(params.id) if (!affiliateItemInstance) { flash.message = message(code: default.not.found.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "list") return } [affiliateItemInstance: affiliateItemInstance] } def edit() { def affiliateItemInstance = AffiliateItem.get(params.id) if (!affiliateItemInstance) { flash.message = message(code: default.not.found.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "list") return } [affiliateItemInstance: affiliateItemInstance] } def update() { def affiliateItemInstance = AffiliateItem.get(params.id) if (!affiliateItemInstance) { flash.message = message(code: default.not.found.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "list") return } if (params.version) { def version = params.version.toLong() if (affiliateItemInstance.version > version) { affiliateItemInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: affiliateItem.label, default: AffiliateItem)] as Object[], "Another user has updated this AffiliateItem while you were editing") render(view: "edit", model: [affiliateItemInstance: affiliateItemInstance]) return } } affiliateItemInstance.properties = params if (!affiliateItemInstance.save(flush: true)) { render(view: "edit", model: [affiliateItemInstance: affiliateItemInstance]) return } flash.message = message(code: default.updated.message, args: [message(code: affiliateItem.label, default: AffiliateItem), affiliateItemInstance.id]) redirect(action: "show", id: affiliateItemInstance.id) } def delete() { def affiliateItemInstance = AffiliateItem.get(params.id) if (!affiliateItemInstance) { flash.message = message(code: default.not.found.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "list") return } try { affiliateItemInstance.delete(flush: true) flash.message = message(code: default.deleted.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "list") } catch (DataIntegrityViolationException e) { flash.message = message(code: default.not.deleted.message, args: [message(code: affiliateItem.label, default: AffiliateItem), params.id]) redirect(action: "show", id: params.id) } } }15 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  16. 16. What the user sees16 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  17. 17. What Magnolia Does Magnolia just needs a controller that can search the tables for what it wants. A template can format what is found.17 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  18. 18. MainTemplateController import info.magnolia.module.blossom.annotation.Template @Template(id = "grailsModule:pages/demoTemplate", title = "Demo template") class MainTemplateController { def index() { [count:AffiliateItem.count(), items:AffiliateItem.list()] } }18 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  19. 19. MainTemplateController There are some static methods for looking through the tables of AffiliateItems. import info.magnolia.module.blossom.annotation.Template @Template(id = "grailsModule:pages/demoTemplate", title = "Demo template") class MainTemplateController { def index() { [count:AffiliateItem.count(), items:AffiliateItem.list()] } }19 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  20. 20. MainTemplateController The index method calls the static search methods and bundles the results into a data structure for the template. You can add extra search logic and filtering here. import info.magnolia.module.blossom.annotation.Template @Template(id = "grailsModule:pages/demoTemplate", title = "Demo template") class MainTemplateController { def index() { [count:AffiliateItem.count(), items:AffiliateItem.list()] } }20 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  21. 21. MainTemplateController The Template annotation connects the controller with the templates. import info.magnolia.module.blossom.annotation.Template @Template(id = "grailsModule:pages/demoTemplate", title = "Demo template") class MainTemplateController { def index() { [count:AffiliateItem.count(), items:AffiliateItem.list()] } }21 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  22. 22. Index.gsp <div class="body"> There are <i> <%= count %></i> AffiliateItems <ul> <g:each in="${items}" var="x"> <li><a href=”${x.url}”>${x.name}</a> -- <i>${x.longDescription}</i></li> </g:each> </ul> </div>22 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  23. 23. Index.gsp The count is just a number collected from the AffiliateItem.count() static routine in the Controller. <div class="body"> There are <i> <%= count %></i> AffiliateItems <ul> <g:each in="${items}" var="x"> <li><a href=”${x.url}”>${x.name}</a> -- <i>${x.longDescription}</i></li> </g:each> </ul> </div>23 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  24. 24. Index.gsp Grails loops through the list of objects created by the AffiliateItem.list() method in the Controller. <div class="body"> There are <i> <%= count %></i> AffiliateItems <ul> <g:each in="${items}" var="x"> <li><a href=”${x.url}”>${x.name}</a> -- <i>${x.longDescription}</i></li> </g:each> </ul> </div>24 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  25. 25. Magnolia Takes Over Index.gsp becomes a template for Magnolia Magnolia glues it together into the web site like all of the other templates and blocks The Grails blocks sit next to the others.25 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  26. 26. What Next? More complicated templates. More logic in the Controllers. Magnolia glues them all together in a nice layout.26 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  27. 27. Resources Introduction http://wiki.magnolia-cms.com/display/TALKOOT/Creating+Database- driven+Web+Applications+with+Magnolia+CMS,+Groovy+and+Maglev Maglev quickstart https://github.com/Bonheur/maglev/wiki/Quick- Start Maglev downloads https://github.com/Bonheur/maglev/downloads Maglev JIRA site. http://jira.magnolia- cms.com/browse/MAGLEV http://www.magnolia-cms.com/community/magnolia- conference/program/presentation- day/presentations/bonheur-ab.html27 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  28. 28. 28 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  29. 29. Section title with abstract29 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  30. 30. Section title with image30 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  31. 31. List of points without subtopics Lay the foundation for future success Improve usability Simplify customization Lower the entry barrier Don’t change what works Provide a migration path31 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  32. 32. Title and bullets Editor • Exposed by View (HasEditors) • Populate View with data • Retrieve values entered by user Driver • Injects values into editors • Updates underlying model (node, bean) • Validates data Used in various editable views • DialogView, TreeView, ParagraphEditView…32 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  33. 33. Title and bullets – 2 columns Enterprise Edition Community Edition • Best choice for mission • Basic content critical websites management • Supported by the vendor functionality • Advanced enterprise • Supported by the features community • Visible source via • Free for unlimited use Magnolia Network • Open source Agreement • Cost effective • Cost effective • Double the Speed • Double the Speed33 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  34. 34. Title, bullets & picture POJOs (Definitions) • Dialogs, trees, actions • Vaadin independent Contributed in various ways • Configuration • Annotations • Programmatically UI Builder builds the Vaadin components34 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  35. 35. Title and picture horizontal35 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  36. 36. 1 2 3 4 Series 1, 2, 3, 4 Each step one slide36 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  37. 37. Where does great content come from?37 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  38. 38. It takes about ten seconds to explain how to create content!38 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  39. 39. Keyboard LTR/RTL Accessibility Touch Mobile Clouds AdminCentral Configuration UI Page editing Wizards Authoring DevelopmentSearch Clipboard Saved lists Developer mode39 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.
  40. 40. Final slide First Last, Role DD.MM.YYYY at Venue/Customer Magnolia International Ltd. first.last@magnolia-cms.com www.magnolia-cms.com40 Version 1.1 Magnolia is a registered trademark owned by Magnolia International Ltd.

×