7. 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
12. 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
13. 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>
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=myLocation/}
You are at ${location}.
<a href="@{Controller.more()}">get more information</a>
compile error
15. 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
16. How to develop nice
JUZU PORTLET
for eXo Platform
Copyright 2015 eXo Platform
17. Develop Juzu portlet
Copyright 2015 eXo Platform
● Create new Juzu project
● Controller
● Business service and Injector
● Template
● Asset manager
● Plugin: Ajax, WebJar
22. 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
23. 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 {...}
24. 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();
}
25. 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
30. 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
37. 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
44. 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);
}
45. 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);
}
46. 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){...}
48. 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