This session will provide an overview of the different technics available to developers to create advanced modules, the extension points and explain when it is preferable to use one approach or another depending on the scenario.
4. How to render content to users
Display your content
4
5. Display your content
Jahia rendering system
Use render service for every node
Render chain ends up with view call
Views : one folder per component type
A module can override exisiting views
5
6. Display your content
Simple JSPs
Simple to use
Can use all jahia taglibs / JSTL
Include your own taglib for complex code
6
7. Display your content
Groovy scripts
Better for complex code with method
declaration, recursions, …
Limited rendering
Cannot use any taglib, but access to Jahia
/JCR API
Example : navigation menu
7
8. Display your content
Webflow
MVC model
Can call controller class to prepare view
Use JSPs for views
Allows user interaction
Example : administration components
Using Spring Web Flow - Friday, 02:00 PM
8
9. Display your content
Spring controller
Same as a servlet
Can return any content type
No mapping with nodes, need to define your
own parameters
Can be declared in a module
9
10. Different ways to let the user modify the content
Create and update
content
10
11. Create and update content
REST API
Create a single node, update properties
Can be used in AJAX or simple HTML forms
Can redirect to a jahia page, or return Json
11
12. Create and update content
Json REST API
Create nodes, update properties, full Json
More powerful
HATEOAS, Use HAL style links
Can be used only in AJAX
Jahia 7 new Rest API, 11:45 AM
12
13. Create and update content
Actions
Custom code, can use all Jahia / JCR API
Can be used in AJAX or simple forms
Can redirect to a jahia page
Can return info to the user only in AJAX
13
14. Create and update content
Webflow
Custom code, can use all Jahia / JCR API
Stateful
Cannot be used with AJAX calls
Using Spring Web Flow - Friday, 02:00 PM
14
15. How to listen to content modifications
React to events
15
16. React to events
Rules
Easy to create and modify
Many simple conditions/consequences available - look
at existing DSL files
Module can register reusable custom services and
DSL
Rule can start background jobs, workflows, …
Rule can replace action, when combined with Rest API
Cluster : triggered only on the server which created the
event
16
17. React to events
Listeners
Direct access to all JCR events (node or
properties added/removed/updated)
Easier to debug
Can have a performance impact
Cluster : can listen to event on other servers
17
18. How to transform your content after rendering
Post process your content
18
19. Post process your content
Macros
Simple groovy scripts
Can be called on whole page :
WEB-INF/macros
##username## , ##requestParameters##
or per module :
WEB-INF/modules-macros
##authorName## , ##creationdate##
Page level macros are not cached !
Available in edit engine for editors
19
20. Post process your content
Render Filter
Used to prepare and/or alter the rendering
Can be placed anywhere in the render chain
- need to specify a correct priority !
Use different scopes : whole page or module
Example : set up connection with external
system, transform content after rendering …
20
21. Post process your content
Errors JSPs or Error Handlers
Use JSPs error only to display message
Use error handler to catch exceptions and
handle some processing
Example : Wiki redirects 404 to creation form
21
22. Always check how your content is cached in live …
Cache management
22
23. Cache management
Use expiration settings carefully
Default expiration set to 4h
Reduce expiration time for content which can
change with time
Never set expiration=0 for content with heavy
processing ( queries, … ), customize cache
key or use AJAX calls instead !
23
24. Cache management
Cache key
Cache fragment = HTML rendering of a
component, without its submodules
Each fragment has a key
Key is composed of multiple parts : node
path, view used, language, acls, request
parameters, context site, …
24
25. Cache management
ACL Cache key
Users with different roles on the node see
different things - different fragments
generated by default
Customizable implementation
Correctly set with cache.dependsOnVisibilityOf
property
Example : jnt:contentList
cache.dependsOnVisibilityOf=$currentNode/[^/]*
25
26. Cache management
Cache Key customization
Define parameters that are known to alter
the rendering
Test the node type before adding things in
the key
Beware of number of dimensions - cache
size can grow quickly !
Example : add user segment to the key
26
28. Use shared services
Workflows : define processes which imply user
interaction
JBPM 6 / BPMN 2
Create workflows for any type of operation
Start workflow with actions
User tasks appear in dashboard
Define workflow participant through the roles
Create custom work handlers
28
29. Use shared services
Social module : activity feed
Create an activity type
[jnt:socialActivity] > jnt:baseSocialActivity
Set up a rule to trigger activities creation
Add activity of type {activityType} on {node}
with parameters {params}
Define a recorder that will populate activity
nodes
void recordActivity(…)
Create views for your activities
29
30. Use shared services
Atmosphere
Develop asynchronous web application
Push / broadcast content to users
Extending Jahia with NoSQL - Thursday, 04:45 PM
30
31. Use shared services
CAMEL
Can send or receive events through different
channels
Configure routes in Gateway service
Can receive mail using decoders
Supports Enterprise Integration Pattern
Example : Wise mail integration
31
32. Use shared services
Spring Data
Extending Jahia with NoSQL - Thursday, 04:45 PM
External providers
External Data Provider - Friday, 09:45 AM
32