5. What is the Juzu?
- Juzu is an open source project developed on GitHub project licensed under
the LGPL 2.1 license
- Source repository: https://github.com/juzu/juzu
- Website: http://juzuweb.org/
- Author: Julien Viet
www.exoplatform.com - Copyright 2012 eXo Platform 5
6. What is the Juzu?
- Juzu is a web framework based on MVC concepts for developing Portlet
applications.
- Develop powerful web applications
- Emphasises on simplicity and type safety
www.exoplatform.com - Copyright 2012 eXo Platform 6
8. Concepts in Juzu
MVC - Model-View-Controller
→ Spring, Struts,.. and Juzu
www.exoplatform.com - Copyright 2012 eXo Platform 8
9. Request lifecycle in Juzu
- View phase: Produce markup output aggregated within a page
- Action phase: Process an action
- Resource phase: produce any kind of output as a full response (i.e not in a
page)
www.exoplatform.com - Copyright 2012 eXo Platform 9
10. Request lifecycle in Juzu
View phase
- View phases are mapped on GET requests
- Idempotent
- View parameters are identified to query parameters
www.exoplatform.com - Copyright 2012 eXo Platform 10
11. Request lifecycle in Juzu
Action phase
- Processing a link
- The action phase is mapped on POST requests
- Not idempotent
- Action parameters are identified to form parameters
- Action phase and POST requests should not be invoked more than one time
www.exoplatform.com - Copyright 2012 eXo Platform 11
12. Request lifecycle in Juzu
Resource phase
- GET request
- Entire response
- Use for Ajax, static resources like image, javascript, etc
www.exoplatform.com - Copyright 2012 eXo Platform 12
13. Juzu Controllers
Controller is part C of MVC model
- They are annotated methods of juzu application
- Kinds of controllers are mapped to phases (View, Action, Resource)
+ @org.juzu.View
+ @org.juzu.Action
+ @org.juzu.Resource
www.exoplatform.com - Copyright 2012 eXo Platform 13
14. Juzu running mode
- prod: production
- dev: development
www.exoplatform.com - Copyright 2012 eXo Platform 14
15. Juzu Application
Juzu app is a portlet application
- Package info
Store application information
- Controllers
- Templates
- Models
www.exoplatform.com - Copyright 2012 eXo Platform 15
16. Type safe parameters
Say about expression parameters in templates:
- Easily to pass parameters from Controllers to templates
- type safe with error checking automatically
- By Annotation processor and Eclipse code completion
www.exoplatform.com - Copyright 2012 eXo Platform 16
19. JuzuPortlet
- Is known as front controller of Juzu application
- Navigate to Controllers
- Navigate to running mode
- Navigate to dependency injection container
...
www.exoplatform.com - Copyright 2012 eXo Platform 19
20. Define UI fragments
- #{insert/}
Insert a template into a template
<div class="ShindigOAuth">
<div class="ONavigation">
<a href="@{OAuthStore.index()}"><<< Back to List</a>
</div>
<br />
#{insert/}
</div>
- #{decorator}
Hook a template into a template
#{decorate path=main.gtmpl/}
www.exoplatform.com - Copyright 2012 eXo Platform 20
22. Template type safe parameters
- Means errors checking during compile time
- Use tag #param in template
#{param name=location/}
#{param name=temperature/}
The weather temperature in ${location} is ${temperature} degrees.
- Use paramters in controller
@Path("index.gtmpl")
@Inject
org.exoplatform.example.templates.index index;
@View
public void index()
{
index.with().location("Ha Noi").temperature("30").render();
}
www.exoplatform.com - Copyright 2012 eXo Platform 22
23. Actions
Actions are method annotated by the @Action annotation
- In Templates:
@{...}
- In Controllers:
@Action
public Response add(String location)
{
}
Example:
<form action="@{add()}" method="post">
<input type="text" name="location" value=""/>
<input type="submit"/>
</form>
www.exoplatform.com - Copyright 2012 eXo Platform 23
24. Form and Bean mapping
- org.juzu.Param
@Param
public class Setting
{
private String path;
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
}
- Submit parameter meet to properties of @Param object
<input type="text" name="path" value="" />
www.exoplatform.com - Copyright 2012 eXo Platform 24