SlideShare a Scribd company logo
How to develop nice
JUZU
Portlet for eXo Platform
Copyright 2015 eXo Platform
A presentation
by Tuyen - Portal Team
Copyright 2015 eXo Platform
Agenda
Copyright 2015 eXo Platform
Enjoy...
1. Introduction to Juzu
2. Juzu feature
3. Develop Juzu Portlet for eXo Platform
4. Migrate your 0.6.2 Juzu Portlet to 1.0.0
You said
JUZU
Juzu what…?
Copyright 2015 eXo Platform
JUZU What…?
Copyright 2015 eXo Platform
Juzu is a Web Framework base on MVC
concepts for developing powerful web/portlets
applications
But… WHY Juzu ? (Too many MVC web framework?)
Copyright 2015 eXo Platform
WHY Juzu ? (Why don’t use existing one)
Copyright 2015 eXo Platform
● All framework target for developing web app
● Too Complex in configuration with XML
● Play framework is simple and good but does not follow JavaEE
standard
Juzu combine idea of Play framework with JavaEE standard
and target for developing both Portlet and Web application.
History and technology
Copyright 2015 eXo Platform
● Inspired from Play framework
● Base on MVC concepts
● Modular oriented
● Integrates with IoC frameworks
● Groovy and Mustache template engine
Juzu applications (Chat application)
Copyright 2015 eXo Platform
Juzu applications (homepage and branding portlets)
Copyright 2015 eXo Platform
A review of nice
CONCEPTS
of Juzu
Copyright 2015 eXo Platform
Concepts of Juzu
Copyright 2015 eXo Platform
● Simplicity
● Typesafe
● Extensibility
Simplicity
Copyright 2015 eXo Platform
@Inject
@Path("index.gtmpl")
Template index;
@View
public Response.Content index() {
return index.ok();
}
<action name="hello"
class="com.tutorialspoint.struts2.HelloWorldAction"
method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>● No more XML
● Use Annotation
Typesafe (Detect error at Compile time)
Copyright 2015 eXo Platform
@Inject
@Path("index.gtmpl")
package.template.index index;
@View
public Response.Content index() {
return index.with().location("Ha Noi").ok();
}
@View
public Response.Content more() {...}
#{param name=location/}
You are at ${location}.
<a href="@{Controller.more()}">get more information</a>
Typesafe (Detect error at Compile time)
Copyright 2015 eXo Platform
@Inject
@Path("index.gtmpl")
package.template.index index;
@View
public Response.Content index() {
return index.with().location("Ha Noi").ok();
}
@View
public Response.Content more() {...}
#{param name=myLocation/}
You are at ${location}.
<a href="@{Controller.more()}">get more information</a>
compile error
Extensibility (Easy to develop and deliver plugin)
Copyright 2015 eXo Platform
public class AjaxService extends ApplicationService {...}
ajax-plugin.jar
org.exoplatform.commons.juzu.ajax.AjaxService
META-INF/services/juzu.impl.plugin.application.ApplicationService
uses the java.util.ServiceLoader discovery mechanism for
finding plugin services
How to develop nice
JUZU PORTLET
for eXo Platform
Copyright 2015 eXo Platform
Develop Juzu portlet
Copyright 2015 eXo Platform
● Create new Juzu project
● Controller
● Business service and Injector
● Template
● Asset manager
● Plugin: Ajax, WebJar
JuZcret…
Copyright 2015 eXo Platform
● Funny Juzu application
● Tutorial: http://blog.exoplatform.com/en/2014/11/18/learn-how-to-develop-great-
juzu-portlets-for-exo-platform
Create new Juzu project
Copyright 2015 eXo Platform
From maven archetype:
mvn archetype:generate 
-DarchetypeGroupId=org.juzu 
-DarchetypeArtifactId=juzu-archetype 
-DarchetypeVersion=1.0.0-cr1 
-DjuzuServer=gatein 
-DgroupId=org.juzu.tutorial 
-DartifactId=tutorial-juzcret 
-Dversion=1.0.0-SNAPSHOT 
-DinteractiveMode=false
Project structure
Copyright 2015 eXo Platform
WEB-INF
application deployment descriptor
package-info.java
configuration for application
Controller
Juzu controller
templates
templates used in application
Project structure (JuZcret application)
Copyright 2015 eXo Platform
Juzu Controller (simple controller)
Copyright 2015 eXo Platform
public class JuZcretApplication {...}
@View
public Response.Content index() {
return Response.ok("Hello world!!!");
}
@Application(defaultController = org.juzu.tutorial.JuZcretApplication.class)
package org.juzu.tutorial;
package-info.java
Juzu Service
Copyright 2015 eXo Platform
public interface SecretService {...}
@Application(defaultController = ...)
@Bindings({
@Binding(
value = org.juzu.tutorial.services.SecretService.class,
implementation = org.juzu.tutorial.services.SecretServiceMemImpl.class
)
})
package org.juzu.tutorial;
package-info.java
public class SecretServiceMemImpl implements SecretService {...}
Juzu Service (inject to controller)
Copyright 2015 eXo Platform
public interface SecretService {...}
public class JuZcretApplication {
@Inject
SecretService secretService;
@Inject
@Path("secretWall.gtmpl")
templates.secretWall secretWall;
...
}
@View
public Response.Content index() {
return secretWall.with()
.secretList(secretService.getScretsList()).ok();
}
Juzu Template
Copyright 2015 eXo Platform
public class JuZcretApplication {
...
@Inject
@Path("secretWall.gtmpl")
org.juzu.tutorial.templates.secretWall secretWall;
...
}
@View
public Response.Content index() {
return secretWall.with().secretsList("My list of secret").ok();
}
#{param name=secretsList/}
Here is my secret list:
${secretsList}
secretWall.gtmpl
Juzu Template (template expression)
Copyright 2015 eXo Platform
@View
public Response.Content index() {
return secretWall.with().secretsList(secretService.getSecrets()).ok();
}
#{param name=secretsList/}
<ul class="secret-wall-list">
<% secretsList.each { secret -> %>
<li>
${secret.message}
</li>
<%}%>
</ul>
secretWall.gtmpl
Form and Action controller
Copyright 2015 eXo Platform
<form action="@{JuZcretApplication.addSecret()}" method="POST" role="form">
...
<textarea rows="3" name="msg" placeholder="Write your secret here"></textarea>
Image URL: <input name="imgURL" placeholder="...">
...
<button type="submit">Share</button>
</form>
@Action
public Response.View addSecret(String msg, String imgURL) {
secretService.addSecret(msg, imgURL);
return JuZcretApplication_.index();
}
JuZcret application
Copyright 2015 eXo Platform
CSS and Javascript
Copyright 2015 eXo Platform
vs
Asset manager (@Stylesheet and Less plugin)
Copyright 2015 eXo Platform
Less plugin will take care of compiling automatically the Less file to CSS file during the maven
compilation
<dependency>
<groupId>org.juzu</groupId>
<artifactId>juzu-plugins-less4j</artifactId>
<version>1.0.0-cr1</version>
</dependency>
@Less(@Stylesheet("styles/juzcret.less"))
@Stylesheets({@Stylesheet(value = "styles/my.css")})
@Assets("*")
package org.juzu.tutorial;
package-info.java
JuZcret UI
Copyright 2015 eXo Platform
Asset manager (@Script and WebJar plugin)
Copyright 2015 eXo Platform
@WebJars(@WebJar("jquery"))
@Scripts({
@Script(id = "jquery", value = "jquery/1.10.2/jquery.js"),
@Script(value = "javascripts/secret.js", depends = "jquery")
})
@Assets("*")
package org.juzu.tutorial;
package-info.java
<dependency>
<artifactId>juzu-plugins-webjars</artifactId>
<groupId>org.juzu</groupId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
</dependency>
Resource Controller
Copyright 2015 eXo Platform
@Resource
public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) {
...
Comment result = secretService.addComment(secretId, comment);
if (result != null) {
return Response.ok(new JSONObject(result).toString()).withMimeType("text/json");
} else {
return Response.status(503);
}
}
@Resource
public Response addLike(String secretId, SecurityContext context) {...}
Controller (map request parameter to Bean types)
Copyright 2015 eXo Platform
@Resource
public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) {
...
}
public class Comment extends Model {
private String userId;
private String content;
...
}
Ajax plugin
Copyright 2015 eXo Platform
@Ajax
@Resource
public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) {...}
$(document).on('click.juzu.secret.addComment', '.btn-comment', function () {
...
var jLike = $(this);
jLike.jzAjax('JuZcretApplication.addComment()', {
data: {...},
success: function (data) {
...
}
});
return false;
});
JuZcret Like and Comment
Copyright 2015 eXo Platform
Internalization and Localization
Copyright 2015 eXo Platform
Juzu support i18n natively in the core. We just need to modify all the labels in all our
templates.
<form action="@{JuZcretApplication.enableComment()}" method="POST" role="form">
<h5>&{label.configuration}</h5>
<input type="checkbox" name="enableComment" <%=enableComment ? "checked" : "" %>/>
&{label.enableComment}
<button type="submit">&{label.save}</button>
</form>
@Inject
ResourceBundle bundle;
Controller.java
template.gtmpl
Internalization and Localization
Copyright 2015 eXo Platform
Template (tag)
Copyright 2015 eXo Platform
#{foo}bar#{/foo}
#{foo/}
#{include path=dispatched.gtmpl/}
#{decorate path=box.gtmpl/}
<div style="border: 1px solid black">
#{insert/}
</div>
#{title value=Home/}
#{param name=color/}
Template (Java Custom tag)
Copyright 2015 eXo Platform
public class TitleTag extends TagHandler {
public TitleTag() {
super("title");
}
@Override
public void render(TemplateRenderContext context, Renderable body, Map<String, String> args) throws IOException {
String title = args.get("value");
if (title != null) {
context.setTitle(title);
}
body.render(context);
}
}
Template (Simple Custom tag)
Copyright 2015 eXo Platform
@Application
@Tags(@Tag(name = "mytag", path = "mytag.gtmpl"))
package my.application;
Hello ${parameters.name}
#{mytag name=”my name”/}
mytag.gtmpl
template
Template (reuse simple custom tag)
Copyright 2015 eXo Platform
custom-tags.jar
my.application.tags.mytag
META-INF/services/juzu.template.TagHandler
@Application
@Tags(@Tag(name = "mytag", path = "mytag.gtmpl"))
package my.application;
Juzu 1.0
New Features
Copyright 2015 eXo Platform
Juzu 1.0 (new features)
Copyright 2015 eXo Platform
● Asset minification
● Bean validation plugin
● Request parameter types
● JSON responding
● Jackson plugin
● Application error handler
Juzu 1.0 New Features (asset minification)
Copyright 2015 eXo Platform
@Scripts(@Script(value = "jquery.js", minified = "jquery.min.js"))
package my.application;
@Scripts(@Script(value = "jquery.js"), minifier = NormalizeJSMinifier.class),
package my.application;
Juzu allows to provide a minified version of an asset that will be used in prod run mode
@Scripts(@Script(value = "jquery.js"), minifier = ClosureMinifier.class),
package my.application;
On-the-fly minification
Generate minified
version at runtime
Juzu 1.0 New Features (asset minification - Less plugin)
Copyright 2015 eXo Platform
In Less plugin: a minify option can be used to minify generated css file.
This option will trim the white-space when processing the file
@Less(@Stylesheet(value = "stylesheet.less", minify = true))
package my.application;
Juzu 1.0 New Features (Request parameter type)
Copyright 2015 eXo Platform
@Action
@Route("/login")
public Response login(@Mapped User user) {
...
}
@Action
public Response.Content sum(Integer left, int right) {
...
}
@View
public Response.Content show(@Format("yyyy.MM.dd G 'at' HH:mm:ss z") Date date) throws Exception {
...
}
@View
public Response.Content sum(int[] values) {
...
}
Primary type
Date time
Bean type Multivalued type
Juzu 1.0 New Features (JSON Responding - too complex in 0.6)
Copyright 2015 eXo Platform
private Response.Content<Stream.Char> createJSONResponse(final Map<String, String> data) {
return new Response.Content<Stream.Char>(200, Stream.Char.class) {
@Override
public String getMimeType() { return "application/json"; }
@Override
public void send(Stream.Char stream) throws IOException {
stream.append("{");
Iterator<Map.Entry<String, String>> i = data.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<String, String> entry = i.next();
stream.append(""" + entry.getKey() + """).append(":").append(""" + entry.getValue() + """);
if (i.hasNext()) { stream.append(","); }
}
stream.append("}");
}
};
}
}
Juzu 1.0 New Features (JSON Responding - very easily in 1.0.0)
Copyright 2015 eXo Platform
@Resouces
public Response.Content getResources() {
JSONObject json = new JSONObject();
parameters.put("key", "value");
…
return Response.ok(json.toString()).withMimeType("application/json");
}
Juzu 1.0 New Features (Jackson plugin)
Copyright 2015 eXo Platform
@Action
public void post(com.fasterxml.jackson.databind.JsonNode tree) {
...
}
@Action
@Route("/post")
public Response.View action(@Jackson MyObj obj) throws IOException {
...
}
The Jackson plugin decodes json entities using the Jackson framework. It can decode to a
Jackson native tree or perform mapping to Java object using Jackson mapper.
Juzu 1.0 New Features (Jackson plugin - response JSON)
Copyright 2015 eXo Platform
Producing a JSON response can done using the Jackson plugin. It can encode a native JsonTree or
an object using the Jackson mapper.
@View
@MimeType.JSON
@Jackson
public MyObj index() {
return new MyObj("Hello World");
}
@View
@MimeType.JSON
public TreeNode index() {
JsonNodeFactory factory = JsonNodeFactory.instance;
return factory.factory.textNode("Hello World");
}
Juzu 1.0 New Features (Validation)
Copyright 2015 eXo Platform
@View
public Response.Content doSomething(@javax.validation.constraints.NotNull String s) {
return Response.ok("The parameter 's' should never be null");
}
Juzu provides controller handler parameter validation via the Bean Validation framework.
Juzu 1.0 New Features (Application error handler)
Copyright 2015 eXo Platform
public class ErrorHandler implements Handler<Response.Error, Response> {
@Override
public Response handle(Response.Error argument) {
return Response.content(500, "An error occured");
}
}
@Application(errorController = ErrorHandler.class)
package my.application;
@View
public Response.Content doSomething(@javax.validation.constraints.NotNull String s) {
return Response.ok("The parameter 's' should never be null");
} If validation error
package-info.java
How to
MIGRATE
from 0.6.2 to 1.0.0
Copyright 2015 eXo Platform
Controller method
Copyright 2015 eXo Platform
Controller method must return Response object
@View
public void index() {
index.render(parameters);
}
@View
public Response index() {
return index.ok(parameters);
}
Template#render() is removed
Copyright 2015 eXo Platform
use method juzu.template.Template#ok()
@View
public void index() {
index.render(parameters);
}
@View
public Response index() {
return index.ok(parameters);
}
RenderContext is removed
Copyright 2015 eXo Platform
If you want to use these context objects:
juzu.request.ApplicationContext
juzu.request.UserContext
juzu.request.SecurityContext
….
Just inject them into controller method
@View
public Response.Content index(ApplicationContext applicationContext,
SecurityContext securityContext, UserContext userContext){...}
Localization
Copyright 2015 eXo Platform
<form action="@{JuZcretApplication.enableComment()}" method="POST" role="form">
<h5>&{label.configuration}</h5>
<input type="checkbox" name="enableComment" <%=enableComment ? "checked" : "" %>/>
&{label.enableComment}
<button type="submit">&{label.save}</button>
</form>
@Inject
ResourceBundle bundle;
Controller.java
template.gtmpl
class *Plugin is renamed to *Service
Copyright 2015 eXo Platform
public class AjaxService extends ApplicationService {...}
ajax-plugin.jar
org.exoplatform.commons.juzu.ajax.AjaxService
META-INF/services/juzu.impl.plugin.application.ApplicationService
ApplicationPlugin
rename to
META-INF/services/juzu.impl.plugin.application.ApplicationPlugin
rename to
It’s time for
THANK YOU
see you soon ...
Copyright 2015 eXo Platform

More Related Content

Viewers also liked

Distributing your product where your customers are
Distributing your product where your customers areDistributing your product where your customers are
Distributing your product where your customers are
Bunrath Bo
 
Sansiri Business Direction 2014
Sansiri Business Direction 2014Sansiri Business Direction 2014
Sansiri Business Direction 2014
SansiriPLC
 
Green Cluster Summit - GCDPo @BAZI
Green Cluster Summit - GCDPo @BAZIGreen Cluster Summit - GCDPo @BAZI
Green Cluster Summit - GCDPo @BAZI
rafabortoli
 
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
ArabNet ME
 
Ipsos Mobile Survey
Ipsos Mobile SurveyIpsos Mobile Survey
Ipsos Mobile Survey
T.S. Lim
 
Animation meet web
Animation meet webAnimation meet web
Animation meet web
Taufshwara Diasriandaru
 
ESOMAR Telephone and Internet Coverage around the World 2016
ESOMAR Telephone and Internet Coverage around the World 2016ESOMAR Telephone and Internet Coverage around the World 2016
ESOMAR Telephone and Internet Coverage around the World 2016
T.S. Lim
 

Viewers also liked (7)

Distributing your product where your customers are
Distributing your product where your customers areDistributing your product where your customers are
Distributing your product where your customers are
 
Sansiri Business Direction 2014
Sansiri Business Direction 2014Sansiri Business Direction 2014
Sansiri Business Direction 2014
 
Green Cluster Summit - GCDPo @BAZI
Green Cluster Summit - GCDPo @BAZIGreen Cluster Summit - GCDPo @BAZI
Green Cluster Summit - GCDPo @BAZI
 
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
Enabling Online Mobile Payment in MENA talk by T-Pay; ArabNet Beirut 2015
 
Ipsos Mobile Survey
Ipsos Mobile SurveyIpsos Mobile Survey
Ipsos Mobile Survey
 
Animation meet web
Animation meet webAnimation meet web
Animation meet web
 
ESOMAR Telephone and Internet Coverage around the World 2016
ESOMAR Telephone and Internet Coverage around the World 2016ESOMAR Telephone and Internet Coverage around the World 2016
ESOMAR Telephone and Internet Coverage around the World 2016
 

More from eXo Platform

Workshop blockchain au service de l engagement - 20-3-2019
Workshop blockchain au service de l engagement - 20-3-2019Workshop blockchain au service de l engagement - 20-3-2019
Workshop blockchain au service de l engagement - 20-3-2019
eXo Platform
 
Digitalisation RH –Avec ou sans les DRH
Digitalisation RH –Avec ou sans les DRHDigitalisation RH –Avec ou sans les DRH
Digitalisation RH –Avec ou sans les DRH
eXo Platform
 
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
eXo Platform
 
L’Intranet, socle de l’entreprise digitale !
L’Intranet, socle de l’entreprise digitale !L’Intranet, socle de l’entreprise digitale !
L’Intranet, socle de l’entreprise digitale !
eXo Platform
 
Un hub collaboratif unique et intégré : les pour et les contre
Un hub collaboratif unique et intégré : les pour et les contreUn hub collaboratif unique et intégré : les pour et les contre
Un hub collaboratif unique et intégré : les pour et les contre
eXo Platform
 
Intranet Project: Roll-out Strategy & Pain Points to consider
Intranet Project: Roll-out Strategy & Pain Points to considerIntranet Project: Roll-out Strategy & Pain Points to consider
Intranet Project: Roll-out Strategy & Pain Points to consider
eXo Platform
 
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and DockerHow we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
eXo Platform
 
Peut-on décider un changement de culture d'entreprise?
Peut-on décider un changement de culture d'entreprise? Peut-on décider un changement de culture d'entreprise?
Peut-on décider un changement de culture d'entreprise?
eXo Platform
 
Conférence sur la Digital Workplace au Salon Intranet & Collaboratif
Conférence sur la Digital Workplace au Salon Intranet & CollaboratifConférence sur la Digital Workplace au Salon Intranet & Collaboratif
Conférence sur la Digital Workplace au Salon Intranet & Collaboratif
eXo Platform
 
eXo Platform - Votre plateforme de travail collaboratif
eXo Platform - Votre plateforme de travail collaboratifeXo Platform - Votre plateforme de travail collaboratif
eXo Platform - Votre plateforme de travail collaboratif
eXo Platform
 
Solutions to your employee disengagement
Solutions to your employee disengagementSolutions to your employee disengagement
Solutions to your employee disengagement
eXo Platform
 
Introduce Bootstrap 3 to Develop Responsive Design Application
Introduce Bootstrap 3 to Develop Responsive Design ApplicationIntroduce Bootstrap 3 to Develop Responsive Design Application
Introduce Bootstrap 3 to Develop Responsive Design Application
eXo Platform
 
Modèles Business Open Source - Success story eXo
Modèles Business Open Source - Success story eXoModèles Business Open Source - Success story eXo
Modèles Business Open Source - Success story eXo
eXo Platform
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van Nghi
eXo Platform
 

More from eXo Platform (14)

Workshop blockchain au service de l engagement - 20-3-2019
Workshop blockchain au service de l engagement - 20-3-2019Workshop blockchain au service de l engagement - 20-3-2019
Workshop blockchain au service de l engagement - 20-3-2019
 
Digitalisation RH –Avec ou sans les DRH
Digitalisation RH –Avec ou sans les DRHDigitalisation RH –Avec ou sans les DRH
Digitalisation RH –Avec ou sans les DRH
 
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
De l'Intranet institutionnel à la Digital Workplace : la démarche du groupe d...
 
L’Intranet, socle de l’entreprise digitale !
L’Intranet, socle de l’entreprise digitale !L’Intranet, socle de l’entreprise digitale !
L’Intranet, socle de l’entreprise digitale !
 
Un hub collaboratif unique et intégré : les pour et les contre
Un hub collaboratif unique et intégré : les pour et les contreUn hub collaboratif unique et intégré : les pour et les contre
Un hub collaboratif unique et intégré : les pour et les contre
 
Intranet Project: Roll-out Strategy & Pain Points to consider
Intranet Project: Roll-out Strategy & Pain Points to considerIntranet Project: Roll-out Strategy & Pain Points to consider
Intranet Project: Roll-out Strategy & Pain Points to consider
 
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and DockerHow we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
How we migrate 350+ Maven CI jobs to Pipeline as Code with Jenkins 2 and Docker
 
Peut-on décider un changement de culture d'entreprise?
Peut-on décider un changement de culture d'entreprise? Peut-on décider un changement de culture d'entreprise?
Peut-on décider un changement de culture d'entreprise?
 
Conférence sur la Digital Workplace au Salon Intranet & Collaboratif
Conférence sur la Digital Workplace au Salon Intranet & CollaboratifConférence sur la Digital Workplace au Salon Intranet & Collaboratif
Conférence sur la Digital Workplace au Salon Intranet & Collaboratif
 
eXo Platform - Votre plateforme de travail collaboratif
eXo Platform - Votre plateforme de travail collaboratifeXo Platform - Votre plateforme de travail collaboratif
eXo Platform - Votre plateforme de travail collaboratif
 
Solutions to your employee disengagement
Solutions to your employee disengagementSolutions to your employee disengagement
Solutions to your employee disengagement
 
Introduce Bootstrap 3 to Develop Responsive Design Application
Introduce Bootstrap 3 to Develop Responsive Design ApplicationIntroduce Bootstrap 3 to Develop Responsive Design Application
Introduce Bootstrap 3 to Develop Responsive Design Application
 
Modèles Business Open Source - Success story eXo
Modèles Business Open Source - Success story eXoModèles Business Open Source - Success story eXo
Modèles Business Open Source - Success story eXo
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van Nghi
 

Recently uploaded

一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
kalichargn70th171
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Paul Brebner
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
kalichargn70th171
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
kalichargn70th171
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
Luigi Fugaro
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
Pedro J. Molina
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
Alina Yurenko
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
kalichargn70th171
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
OnePlan Solutions
 

Recently uploaded (20)

一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
What is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdfWhat is Continuous Testing in DevOps - A Definitive Guide.pdf
What is Continuous Testing in DevOps - A Definitive Guide.pdf
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
Why Apache Kafka Clusters Are Like Galaxies (And Other Cosmic Kafka Quandarie...
 
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdfThe Comprehensive Guide to Validating Audio-Visual Performances.pdf
The Comprehensive Guide to Validating Audio-Visual Performances.pdf
 
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdfSoftware Test Automation - A Comprehensive Guide on Automated Testing.pdf
Software Test Automation - A Comprehensive Guide on Automated Testing.pdf
 
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
WMF 2024 - Unlocking the Future of Data Powering Next-Gen AI with Vector Data...
 
Orca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container OrchestrationOrca: Nocode Graphical Editor for Container Orchestration
Orca: Nocode Graphical Editor for Container Orchestration
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
Going AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applicationsGoing AOT: Everything you need to know about GraalVM for Java applications
Going AOT: Everything you need to know about GraalVM for Java applications
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical OperationsEnsuring Efficiency and Speed with Practical Solutions for Clinical Operations
Ensuring Efficiency and Speed with Practical Solutions for Clinical Operations
 

eXoer on the grill: How to develop nice Juzu Portlet for eXo Platform

  • 1. How to develop nice JUZU Portlet for eXo Platform Copyright 2015 eXo Platform
  • 2. A presentation by Tuyen - Portal Team Copyright 2015 eXo Platform
  • 3. Agenda Copyright 2015 eXo Platform Enjoy... 1. Introduction to Juzu 2. Juzu feature 3. Develop Juzu Portlet for eXo Platform 4. Migrate your 0.6.2 Juzu Portlet to 1.0.0
  • 5. JUZU What…? Copyright 2015 eXo Platform Juzu is a Web Framework base on MVC concepts for developing powerful web/portlets applications
  • 6. But… WHY Juzu ? (Too many MVC web framework?) Copyright 2015 eXo Platform
  • 7. WHY Juzu ? (Why don’t use existing one) Copyright 2015 eXo Platform ● All framework target for developing web app ● Too Complex in configuration with XML ● Play framework is simple and good but does not follow JavaEE standard Juzu combine idea of Play framework with JavaEE standard and target for developing both Portlet and Web application.
  • 8. History and technology Copyright 2015 eXo Platform ● Inspired from Play framework ● Base on MVC concepts ● Modular oriented ● Integrates with IoC frameworks ● Groovy and Mustache template engine
  • 9. Juzu applications (Chat application) Copyright 2015 eXo Platform
  • 10. Juzu applications (homepage and branding portlets) Copyright 2015 eXo Platform
  • 11. A review of nice CONCEPTS of Juzu Copyright 2015 eXo Platform
  • 12. Concepts of Juzu Copyright 2015 eXo Platform ● Simplicity ● Typesafe ● Extensibility
  • 13. Simplicity Copyright 2015 eXo Platform @Inject @Path("index.gtmpl") Template index; @View public Response.Content index() { return index.ok(); } <action name="hello" class="com.tutorialspoint.struts2.HelloWorldAction" method="execute"> <result name="success">/HelloWorld.jsp</result> </action>● No more XML ● Use Annotation
  • 14. Typesafe (Detect error at Compile time) Copyright 2015 eXo Platform @Inject @Path("index.gtmpl") package.template.index index; @View public Response.Content index() { return index.with().location("Ha Noi").ok(); } @View public Response.Content more() {...} #{param name=location/} You are at ${location}. <a href="@{Controller.more()}">get more information</a>
  • 15. Typesafe (Detect error at Compile time) Copyright 2015 eXo Platform @Inject @Path("index.gtmpl") package.template.index index; @View public Response.Content index() { return index.with().location("Ha Noi").ok(); } @View public Response.Content more() {...} #{param name=myLocation/} You are at ${location}. <a href="@{Controller.more()}">get more information</a> compile error
  • 16. Extensibility (Easy to develop and deliver plugin) Copyright 2015 eXo Platform public class AjaxService extends ApplicationService {...} ajax-plugin.jar org.exoplatform.commons.juzu.ajax.AjaxService META-INF/services/juzu.impl.plugin.application.ApplicationService uses the java.util.ServiceLoader discovery mechanism for finding plugin services
  • 17. How to develop nice JUZU PORTLET for eXo Platform Copyright 2015 eXo Platform
  • 18. Develop Juzu portlet Copyright 2015 eXo Platform ● Create new Juzu project ● Controller ● Business service and Injector ● Template ● Asset manager ● Plugin: Ajax, WebJar
  • 19. JuZcret… Copyright 2015 eXo Platform ● Funny Juzu application ● Tutorial: http://blog.exoplatform.com/en/2014/11/18/learn-how-to-develop-great- juzu-portlets-for-exo-platform
  • 20. Create new Juzu project Copyright 2015 eXo Platform From maven archetype: mvn archetype:generate -DarchetypeGroupId=org.juzu -DarchetypeArtifactId=juzu-archetype -DarchetypeVersion=1.0.0-cr1 -DjuzuServer=gatein -DgroupId=org.juzu.tutorial -DartifactId=tutorial-juzcret -Dversion=1.0.0-SNAPSHOT -DinteractiveMode=false
  • 21. Project structure Copyright 2015 eXo Platform WEB-INF application deployment descriptor package-info.java configuration for application Controller Juzu controller templates templates used in application
  • 22. Project structure (JuZcret application) Copyright 2015 eXo Platform
  • 23. Juzu Controller (simple controller) Copyright 2015 eXo Platform public class JuZcretApplication {...} @View public Response.Content index() { return Response.ok("Hello world!!!"); } @Application(defaultController = org.juzu.tutorial.JuZcretApplication.class) package org.juzu.tutorial; package-info.java
  • 24. Juzu Service Copyright 2015 eXo Platform public interface SecretService {...} @Application(defaultController = ...) @Bindings({ @Binding( value = org.juzu.tutorial.services.SecretService.class, implementation = org.juzu.tutorial.services.SecretServiceMemImpl.class ) }) package org.juzu.tutorial; package-info.java public class SecretServiceMemImpl implements SecretService {...}
  • 25. Juzu Service (inject to controller) Copyright 2015 eXo Platform public interface SecretService {...} public class JuZcretApplication { @Inject SecretService secretService; @Inject @Path("secretWall.gtmpl") templates.secretWall secretWall; ... } @View public Response.Content index() { return secretWall.with() .secretList(secretService.getScretsList()).ok(); }
  • 26. Juzu Template Copyright 2015 eXo Platform public class JuZcretApplication { ... @Inject @Path("secretWall.gtmpl") org.juzu.tutorial.templates.secretWall secretWall; ... } @View public Response.Content index() { return secretWall.with().secretsList("My list of secret").ok(); } #{param name=secretsList/} Here is my secret list: ${secretsList} secretWall.gtmpl
  • 27. Juzu Template (template expression) Copyright 2015 eXo Platform @View public Response.Content index() { return secretWall.with().secretsList(secretService.getSecrets()).ok(); } #{param name=secretsList/} <ul class="secret-wall-list"> <% secretsList.each { secret -> %> <li> ${secret.message} </li> <%}%> </ul> secretWall.gtmpl
  • 28. Form and Action controller Copyright 2015 eXo Platform <form action="@{JuZcretApplication.addSecret()}" method="POST" role="form"> ... <textarea rows="3" name="msg" placeholder="Write your secret here"></textarea> Image URL: <input name="imgURL" placeholder="..."> ... <button type="submit">Share</button> </form> @Action public Response.View addSecret(String msg, String imgURL) { secretService.addSecret(msg, imgURL); return JuZcretApplication_.index(); }
  • 30. CSS and Javascript Copyright 2015 eXo Platform vs
  • 31. Asset manager (@Stylesheet and Less plugin) Copyright 2015 eXo Platform Less plugin will take care of compiling automatically the Less file to CSS file during the maven compilation <dependency> <groupId>org.juzu</groupId> <artifactId>juzu-plugins-less4j</artifactId> <version>1.0.0-cr1</version> </dependency> @Less(@Stylesheet("styles/juzcret.less")) @Stylesheets({@Stylesheet(value = "styles/my.css")}) @Assets("*") package org.juzu.tutorial; package-info.java
  • 33. Asset manager (@Script and WebJar plugin) Copyright 2015 eXo Platform @WebJars(@WebJar("jquery")) @Scripts({ @Script(id = "jquery", value = "jquery/1.10.2/jquery.js"), @Script(value = "javascripts/secret.js", depends = "jquery") }) @Assets("*") package org.juzu.tutorial; package-info.java <dependency> <artifactId>juzu-plugins-webjars</artifactId> <groupId>org.juzu</groupId> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> </dependency>
  • 34. Resource Controller Copyright 2015 eXo Platform @Resource public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) { ... Comment result = secretService.addComment(secretId, comment); if (result != null) { return Response.ok(new JSONObject(result).toString()).withMimeType("text/json"); } else { return Response.status(503); } } @Resource public Response addLike(String secretId, SecurityContext context) {...}
  • 35. Controller (map request parameter to Bean types) Copyright 2015 eXo Platform @Resource public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) { ... } public class Comment extends Model { private String userId; private String content; ... }
  • 36. Ajax plugin Copyright 2015 eXo Platform @Ajax @Resource public Response addComment(String secretId, @Mapped Comment comment, SecurityContext context) {...} $(document).on('click.juzu.secret.addComment', '.btn-comment', function () { ... var jLike = $(this); jLike.jzAjax('JuZcretApplication.addComment()', { data: {...}, success: function (data) { ... } }); return false; });
  • 37. JuZcret Like and Comment Copyright 2015 eXo Platform
  • 38. Internalization and Localization Copyright 2015 eXo Platform Juzu support i18n natively in the core. We just need to modify all the labels in all our templates. <form action="@{JuZcretApplication.enableComment()}" method="POST" role="form"> <h5>&{label.configuration}</h5> <input type="checkbox" name="enableComment" <%=enableComment ? "checked" : "" %>/> &{label.enableComment} <button type="submit">&{label.save}</button> </form> @Inject ResourceBundle bundle; Controller.java template.gtmpl
  • 40. Template (tag) Copyright 2015 eXo Platform #{foo}bar#{/foo} #{foo/} #{include path=dispatched.gtmpl/} #{decorate path=box.gtmpl/} <div style="border: 1px solid black"> #{insert/} </div> #{title value=Home/} #{param name=color/}
  • 41. Template (Java Custom tag) Copyright 2015 eXo Platform public class TitleTag extends TagHandler { public TitleTag() { super("title"); } @Override public void render(TemplateRenderContext context, Renderable body, Map<String, String> args) throws IOException { String title = args.get("value"); if (title != null) { context.setTitle(title); } body.render(context); } }
  • 42. Template (Simple Custom tag) Copyright 2015 eXo Platform @Application @Tags(@Tag(name = "mytag", path = "mytag.gtmpl")) package my.application; Hello ${parameters.name} #{mytag name=”my name”/} mytag.gtmpl template
  • 43. Template (reuse simple custom tag) Copyright 2015 eXo Platform custom-tags.jar my.application.tags.mytag META-INF/services/juzu.template.TagHandler @Application @Tags(@Tag(name = "mytag", path = "mytag.gtmpl")) package my.application;
  • 44. Juzu 1.0 New Features Copyright 2015 eXo Platform
  • 45. Juzu 1.0 (new features) Copyright 2015 eXo Platform ● Asset minification ● Bean validation plugin ● Request parameter types ● JSON responding ● Jackson plugin ● Application error handler
  • 46. Juzu 1.0 New Features (asset minification) Copyright 2015 eXo Platform @Scripts(@Script(value = "jquery.js", minified = "jquery.min.js")) package my.application; @Scripts(@Script(value = "jquery.js"), minifier = NormalizeJSMinifier.class), package my.application; Juzu allows to provide a minified version of an asset that will be used in prod run mode @Scripts(@Script(value = "jquery.js"), minifier = ClosureMinifier.class), package my.application; On-the-fly minification Generate minified version at runtime
  • 47. Juzu 1.0 New Features (asset minification - Less plugin) Copyright 2015 eXo Platform In Less plugin: a minify option can be used to minify generated css file. This option will trim the white-space when processing the file @Less(@Stylesheet(value = "stylesheet.less", minify = true)) package my.application;
  • 48. Juzu 1.0 New Features (Request parameter type) Copyright 2015 eXo Platform @Action @Route("/login") public Response login(@Mapped User user) { ... } @Action public Response.Content sum(Integer left, int right) { ... } @View public Response.Content show(@Format("yyyy.MM.dd G 'at' HH:mm:ss z") Date date) throws Exception { ... } @View public Response.Content sum(int[] values) { ... } Primary type Date time Bean type Multivalued type
  • 49. Juzu 1.0 New Features (JSON Responding - too complex in 0.6) Copyright 2015 eXo Platform private Response.Content<Stream.Char> createJSONResponse(final Map<String, String> data) { return new Response.Content<Stream.Char>(200, Stream.Char.class) { @Override public String getMimeType() { return "application/json"; } @Override public void send(Stream.Char stream) throws IOException { stream.append("{"); Iterator<Map.Entry<String, String>> i = data.entrySet().iterator(); while (i.hasNext()) { Map.Entry<String, String> entry = i.next(); stream.append(""" + entry.getKey() + """).append(":").append(""" + entry.getValue() + """); if (i.hasNext()) { stream.append(","); } } stream.append("}"); } }; } }
  • 50. Juzu 1.0 New Features (JSON Responding - very easily in 1.0.0) Copyright 2015 eXo Platform @Resouces public Response.Content getResources() { JSONObject json = new JSONObject(); parameters.put("key", "value"); … return Response.ok(json.toString()).withMimeType("application/json"); }
  • 51. Juzu 1.0 New Features (Jackson plugin) Copyright 2015 eXo Platform @Action public void post(com.fasterxml.jackson.databind.JsonNode tree) { ... } @Action @Route("/post") public Response.View action(@Jackson MyObj obj) throws IOException { ... } The Jackson plugin decodes json entities using the Jackson framework. It can decode to a Jackson native tree or perform mapping to Java object using Jackson mapper.
  • 52. Juzu 1.0 New Features (Jackson plugin - response JSON) Copyright 2015 eXo Platform Producing a JSON response can done using the Jackson plugin. It can encode a native JsonTree or an object using the Jackson mapper. @View @MimeType.JSON @Jackson public MyObj index() { return new MyObj("Hello World"); } @View @MimeType.JSON public TreeNode index() { JsonNodeFactory factory = JsonNodeFactory.instance; return factory.factory.textNode("Hello World"); }
  • 53. Juzu 1.0 New Features (Validation) Copyright 2015 eXo Platform @View public Response.Content doSomething(@javax.validation.constraints.NotNull String s) { return Response.ok("The parameter 's' should never be null"); } Juzu provides controller handler parameter validation via the Bean Validation framework.
  • 54. Juzu 1.0 New Features (Application error handler) Copyright 2015 eXo Platform public class ErrorHandler implements Handler<Response.Error, Response> { @Override public Response handle(Response.Error argument) { return Response.content(500, "An error occured"); } } @Application(errorController = ErrorHandler.class) package my.application; @View public Response.Content doSomething(@javax.validation.constraints.NotNull String s) { return Response.ok("The parameter 's' should never be null"); } If validation error package-info.java
  • 55. How to MIGRATE from 0.6.2 to 1.0.0 Copyright 2015 eXo Platform
  • 56. Controller method Copyright 2015 eXo Platform Controller method must return Response object @View public void index() { index.render(parameters); } @View public Response index() { return index.ok(parameters); }
  • 57. Template#render() is removed Copyright 2015 eXo Platform use method juzu.template.Template#ok() @View public void index() { index.render(parameters); } @View public Response index() { return index.ok(parameters); }
  • 58. RenderContext is removed Copyright 2015 eXo Platform If you want to use these context objects: juzu.request.ApplicationContext juzu.request.UserContext juzu.request.SecurityContext …. Just inject them into controller method @View public Response.Content index(ApplicationContext applicationContext, SecurityContext securityContext, UserContext userContext){...}
  • 59. Localization Copyright 2015 eXo Platform <form action="@{JuZcretApplication.enableComment()}" method="POST" role="form"> <h5>&{label.configuration}</h5> <input type="checkbox" name="enableComment" <%=enableComment ? "checked" : "" %>/> &{label.enableComment} <button type="submit">&{label.save}</button> </form> @Inject ResourceBundle bundle; Controller.java template.gtmpl
  • 60. class *Plugin is renamed to *Service Copyright 2015 eXo Platform public class AjaxService extends ApplicationService {...} ajax-plugin.jar org.exoplatform.commons.juzu.ajax.AjaxService META-INF/services/juzu.impl.plugin.application.ApplicationService ApplicationPlugin rename to META-INF/services/juzu.impl.plugin.application.ApplicationPlugin rename to
  • 61. It’s time for THANK YOU see you soon ... Copyright 2015 eXo Platform