At the heart of every organization are processes and data stored away in systems of record. Often, the related business logic is implemented with the Spring Framework. Magnolia CMS enables you to bring up this data for direct interaction with your customers, members or citizens through your interaction channels – the web, mobile and others – to generate significant additional value both for them and for your organization.
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Blossom on the web
1. Blossom on the Web
Spring and Content Management
Tobias Mattsson, Senior Software 07.03.2014 at Magnolia Amplify
Engineer
Magnolia is a registered trademark owned by Magnolia
1 Version 1.1
International Ltd.
Thursday, 7 March 2013
2. Spring Framework
Spring is a java based application framework
• Focus on web applications and enterprise
applications
• One of the most popular frameworks in the Java
space
Pioneered a broad feature set
• Lightweight container
• Dependency Injection (DI)
• Aspect Oriented Programming (AOP)
• Enterprise Service Abstraction
Magnolia is a registered trademark owned by Magnolia
2 Version 1.1
International Ltd.
Thursday, 7 March 2013
3. Spring is everywhere
2.5 million developers use Spring (two thirds!)
More than half of the Fortune 500 power their Java
applications with Spring
More than 70 percent of enterprises cite improved
productivity, faster project completion, improved
portability and application quality as reasons for
using Spring
Magnolia is a registered trademark owned by Magnolia
3 Version 1.1
International Ltd.
Thursday, 7 March 2013
4. Spring projects
Spring Web MVC
Spring WebFlow
Spring Security
Spring WebServices
Spring Social
• Twitter, Facebook, LinkedIn etc
Spring Data
• MongoDB, Neo4j, Riak, Cassandra etc
Magnolia is a registered trademark owned by Magnolia
4 Version 1.1
International Ltd.
Thursday, 7 March 2013
5. Spring and the CMS
Magnolia is a registered trademark owned by Magnolia
5 Version 1.1
International Ltd.
Thursday, 7 March 2013
6. Blossom integrates it for you
Integrates Spring into the Magnolia module
mechanism
• Module Lifecycle
Extends Spring Web MVC for templating
And additional bridging
Magnolia is a registered trademark owned by Magnolia
6 Version 1.1
International Ltd.
Thursday, 7 March 2013
7. Spring Web MVC with Content
No configuration just code
Based on annotations
Non-intrusive
Spring centric approach
• The controller is the template
• The controller is the component
• and they’re automatically available in Magnolia
Magnolia is a registered trademark owned by Magnolia
7 Version 1.1
International Ltd.
Thursday, 7 March 2013
8. Spring Web MVC
@Controller
public class ExampleController {
@RequestMapping("/customers/list")
public String render(ModelMap model) {
model.put("title", "List of all customers");
model.put("customers", customerService.findAllCustomers());
return "customers/list";
}
}
Magnolia is a registered trademark owned by Magnolia
8 Version 1.1
International Ltd.
Thursday, 7 March 2013
9. Templates
@Controller
@Template(title = "Main template", id = "blossomSample:pages/main")
public class MainTemplate {
@RequestMapping("/mainTemplate")
public String render(Node page, ModelMap model) {
return "pages/main.ftl";
}
}
Magnolia is a registered trademark owned by Magnolia
9 Version 1.1
International Ltd.
Thursday, 7 March 2013
10. Areas
@Controller
@Template(title = "Main template", id = "blossomSample:pages/main")
public class MainTemplate {
@Controller
@Area("main")
public static class MainArea {
@RequestMapping("/mainTemplate/main")
public String render() {
return "areas/mainArea.ftl";
}
}
...
}
Magnolia is a registered trademark owned by Magnolia
10 Version 1.1
International Ltd.
Thursday, 7 March 2013
11. Components
@Controller
@Template(title = "Shopping Cart", id = "blossomSample:components/shoppingCart")
@TemplateDescription("Shopping cart")
public class ShoppingCartComponent {
@RequestMapping("/shoppingCart")
public String handleRequest() {
...
return "components/shoppingCart.ftl";
}
...
}
Magnolia is a registered trademark owned by Magnolia
11 Version 1.1
International Ltd.
Thursday, 7 March 2013
12. Specifying what goes into an area
@Controller
@Area("promos")
@AvailableComponentClasses({TextComponent.class, ShoppingCartComponent.class})
public static class PromosArea {
@RequestMapping("/mainTemplate/promos")
public String render() {
return "areas/promosArea.ftl";
}
}
Magnolia is a registered trademark owned by Magnolia
12 Version 1.1
International Ltd.
Thursday, 7 March 2013
13. Inheritance
@Controller
@Area("promos")
@Inherits
@AvailableComponentClasses({TextComponent.class, ShoppingCartComponent.class})
public static class PromosArea {
@RequestMapping("/mainTemplate/promos")
public String render() {
return "areas/promos.jsp";
}
}
Magnolia is a registered trademark owned by Magnolia
13 Version 1.1
International Ltd.
Thursday, 7 March 2013
14. Dialogs
Dialogs are created using code, not configuration
Based on annotations
Dynamic behavior
Validation of dialog input
Detected and automatically available in Magnolia
Magnolia is a registered trademark owned by Magnolia
14 Version 1.1
International Ltd.
Thursday, 7 March 2013
15. Dialog factories
@DialogFactory("page-dialog")
public class PageDialog {
@TabFactory("Content")
public void contentTab(TabBuilder tab) {
tab.addEdit("title", "Title", "Title of this page");
tab.addCheckbox("navigation", "Navigation", "Include page in menu");
}
@TabFactory("Meta")
public void metaTab(TabBuilder tab) {
tab.addEdit("author", "Author", "");
tab.addEdit("keywords", "Keywords", "Keywords for this page");
tab.addEdit("description", "Description", "Concise page explanation");
}
}
Magnolia is a registered trademark owned by Magnolia
15 Version 1.1
International Ltd.
Thursday, 7 March 2013
16. Dialog inheritance
public abstract class BaseDialog {
@TabFactory("Meta")
public void metaTab(TabBuilder tab) {
tab.addEdit("keywords", "Keywords", "Keywords for this page");
tab.addEdit("description", "Description", "Concise page explanation");
}
}
@DialogFactory("news-properties")
@TabOrder("Content", “Meta”)
public class NewsPageDialog extends BaseDialog {
@TabFactory("Content")
public void contentTab(TabBuilder tab) {
tab.addEdit("subject", "Subject", "News subject");
tab.addDate("date", "Publication Date", "Date of publication");
tab.addFckEditor("text", "Text", "");
tab.addFile("image", "Image", "");
}
}
Magnolia is a registered trademark owned by Magnolia
16 Version 1.1
International Ltd.
Thursday, 7 March 2013
17. Inline dialogs
@Controller
@Template(title = "Main template", id = "blossomSample:pages/main")
public class MainTemplate {
@RequestMapping("/mainTemplate")
public String render(Node page, ModelMap model) {
return "pages/main.ftl";
}
@TabFactory("Content")
public void propertiesDialog(TabBuilder tab) {
tab.addEdit("title", "Title", "");
}
}
Magnolia is a registered trademark owned by Magnolia
17 Version 1.1
International Ltd.
Thursday, 7 March 2013
18. Inline dialogs
@Controller
@Template(title = "Main template", id = "blossomSample:pages/main")
public class MainTemplate {
@Controller
@Area("main")
public static class MainArea {
@TabFactory("Content")
public void contentTab(TabBuilder tab) {
tab.addEdit("borderWidth", "Border width",
"Width of the border around the area");
}
@RequestMapping("/mainTemplate/main")
public String render() {
return "areas/mainArea.ftl";
}
}
...
}
Magnolia is a registered trademark owned by Magnolia
18 Version 1.1
International Ltd.
Thursday, 7 March 2013
19. Dynamic dialogs
@Controller
@Template(id="blossomSample:components/book", title="Book")
public class BookComponent {
@Inject
private BookStoreWebService webService;
@TabFactory("Content")
public void contentTab(TabBuilder tab) {
tab.addSelect("id", "Book", "Select the book", webService.getBooks());
}
@RequestMapping("/book")
public String handleRequest(ModelMap model, Node content) {
String bookId = content.getProperty("id").getString();
model.put("book", webService.getBook(bookId));
return "components/book.ftl";
}
}
Magnolia is a registered trademark owned by Magnolia
19 Version 1.1
International Ltd.
Thursday, 7 March 2013
20. Validation
@DialogFactory("page-properties")
public class PagePropertiesDialog {
@TabFactory("Meta")
public void metaTab(TabBuilder tab) {
tab.addEdit("description", "Description", "A concise page explanation");
}
@TabValidator("Meta")
public void validateMetaTab(DialogTab tab) {
if (tab.getSub("description").getValue().length() < 20)
AlertUtil.setMessage("Meta description needs to be longer");
}
}
Magnolia is a registered trademark owned by Magnolia
20 Version 1.1
International Ltd.
Thursday, 7 March 2013
21. Pre-execution
Portal like semantics
Allows a component to fully process a request
Developers can implement backing logic entirely in
the components
Magnolia is a registered trademark owned by Magnolia
21 Version 1.1
International Ltd.
Thursday, 7 March 2013
22. View technologies
Best of both worlds approach
Magnolia and Spring constructs work side by side
Built-in support for Freemarker and JSP
Everything Spring supports work out-of-the-box,
such as JSON, PDF, XML and RSS
Magnolia is a registered trademark owned by Magnolia
22 Version 1.1
International Ltd.
Thursday, 7 March 2013
23. Blossom in the wild
Magnolia is a registered trademark owned by Magnolia
23 Version 1.1
International Ltd.
Thursday, 7 March 2013
24. Maglev - Magnolia and Grails
Brings Magnolia to the Grails platform
Development entirely in groovy and GSP
Grails productivity
Builds on Blossom
Magnolia is a registered trademark owned by Magnolia
24 Version 1.1
International Ltd.
Thursday, 7 March 2013
25. Summary
Enables access to Spring features and technologies
• Directly in templates, components and dialogs
Spring centric approach on templating
• Based on annotations
• Connects the CMS with Spring Web MVC
Code over configuration
• Versioning
• Collaboration
Magnolia is a registered trademark owned by Magnolia
25 Version 1.1
International Ltd.
Thursday, 7 March 2013
26. Questions?
Magnolia is a registered trademark owned by Magnolia
26 Version 1.1
International Ltd.
Thursday, 7 March 2013
27. Thanks for listening!
Tobias Mattsson, Senior Software 07.03.2013 at Magnolia Amplify
Engineer tobias.mattsson@magnolia-cms.com
Magnolia International Ltd.
www.magnolia-cms.com
Magnolia is a registered trademark owned by Magnolia
27 Version 1.1
International Ltd.
Thursday, 7 March 2013