forked from juzu/juzuweb.org.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatures.html
More file actions
315 lines (280 loc) · 12.2 KB
/
features.html
File metadata and controls
315 lines (280 loc) · 12.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Juzu Web Framework</title>
<!-- Juzuweb CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/site.css" rel="stylesheet">
<!--[if lt IE 9]><script src="js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="js/bootstrap-3.1/html5shiv.js"></script>
<script src="js/bootstrap-3.1/respond.min.js"></script>
<![endif]-->
<!-- Juzuweb Favicons -->
</head>
<body class="body-page">
<div id="wrapper" class="wrapper">
<div class="inner">
<nav id="navbarTop" class="navbar navbar-top affix" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Juzu Web Framework</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="index.html">Home</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" >Project <b class="caret-square"></b></a>
<ul class="dropdown-menu">
<li><a href="features.html"><span>Features</span></a></li>
<li><a href="https://github.com/juzu/juzu/blob/master/roadmap.asciidoc"><span>Road map</span></a></li>
<li><a href="https://github.com/juzu/juzu"><span>Contribute</span></a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" >Documentation <b class="caret-square"></b></a>
<ul class="dropdown-menu">
<li><a href="tutorial/index.html"><span>Tutorial</span></a></li>
<li><a href="reference/index.html"><span>Reference</span></a></li>
<li><a href="javadoc/index.html" target="blank_"><span>Javadoc</span></a></li>
</ul>
</li>
<li><a href="screencasts.html">Screencasts</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav><!-- /.navbar-top -->
<div class="page docs-content">
<a name="features"></a>
<div class="container">
<h1 id="features" class="title-section">Features</h1>
<h1 class="page-header">Deployment</h1>
<p>Juzu deploys on
</p><ul>
<li>Any servlet container</li>
<li><a href="http://www.gatein.org">GateIn</a>: 3.2 and 3.3</li>
<li><a href="http://www.liferay.com">Liferay</a>: tested on Liferay 6.10 and 5.x</li>
<li>The Vert.x Platform</li>
</ul>
<p></p>
<h1 class="page-header">Dependency Injection integration</h1>
<p>
Juzu leverages the JSR-330 specification to perform dependency injection, this specification is supported by the most
popular dependency injection frameworks such as Weld, Spring and Guice.
</p>
<h2>Scopes</h2>
<p>The <code>@inject</code> specification provides the notion of scope and Juzu leverages it to manage the life
cycle of the various objects. Juzu provides a set of scope that can be used to control the scope of objects:</p>
<ul>
<li>Application scope (<code>@Singleton</code> annotation provides by <code>@inject</code> specification)</li>
<li>Request scope</li>
<li>Session scope</li>
<li>Flash scope</li>
</ul>
<h2>Inversion Of Control</h2>
<h3>Configuration</h3>
<p>
The IOC container implementation can be done in the <code>web.xml</code> file:
</p>
<pre><context-param>
<param-name>juzu.inject</param-name>
<param-value>weld</param-value>
<!--
<value>spring</value>
-->
</context-param></pre>
<h1 class="page-header">Programming</h1>
<h2>Controller</h2>
<p>Juzu programming model is inspired by the Play! Framework that provides a simple and efficient programming
model for the web.</p>
<p>Controller are methods annotated with <code>@Action</code> or <code>@View</code>:</p>
<pre>
@Action
public Response purchaseProduct(String productId) { ... }
@View
public void showProduct(String productId) { ... }</pre>
<p>The <code>productId</code> defines the name of the parameter when a link is build in templates:</p>
<pre><a href="@{showProduct(productId='tomato'">Tomato</a></pre>
<p>It also works for forms and should be used like this:</p>
<pre><form action="@{purchaseProduct" method="POST">
<select name="productId">
...
</select>
</form></pre>
<p>Controller method takes String argument at the moment, later support for other types will be added.
Multivalued string are supported with the <code>String[]</code> or <code>List<String></code> types.</p>
<h2>Templating</h2>
<p>Juzu templates engine is based on Groovy and provide a powerful set of instructions.</p>
<h3>Template URL resolution</h3>
<p>Juzu validates the application templates during the compilation phase and will attempt to resolve any link
against a controller method: application links are validated at compilation time.</p>
<pre><a href="@{index()}">Link</a></pre>
<h3>Template parameters</h3>
<p>Template can have parameters</p>
<pre>${r"#{param name=temperature/}
The ${temperature}"}</pre>
<p>Such parameters that can be used in a type safe way in a controller that renders the template</p>
<pre>template.with().temperature("30").render();</pre>
<h3>Template declaration</h3>
<pre>@Path("myTemplate.gtml")
private Template myTemplate;</pre>
<p>Takes the corresponding template file and generates the corresponding Groovy source code to be compiled.</p>
<h3>Template injection</h3>
<pre>@Inject
@Path("MyTemplate.gtmpl");
private Template template;</pre>
<h3>Tag library</h3>
<p>The Tab library supports a few tags at the moment</p>
<ul>
<li><em>decorate</em> : decorate a template with another template</li>
<li><em>param</em> : declare a template parameter and provide a typed interface for invoking a template from a controller</li>
<li><em>include</em> : include a template in a template</li>
<li><em>title</em> : set the portlet title</li>
</ul>
<p>The taglib API is not yet pluggable but will be.</p>
<h2>Web programming</h2>
<p>Juzu makes client side programming easy as it supports declarative assets for JavaScript, Stylesheet and JavaScript Asynchronous Module
Definition.</p>
<h3>Declare an asset</h3>
<pre>@Application
@Assets(scripts = { @Script(id = "jquery", src="jquery.js") })
package my.app;</pre>
<h3>Declare a JavaScript module</h3>
<pre>@Application
@Defines({
@Require(id = "jquery", path="jquery.js"),
@Define(
id = "mymodule",
path="mymodule.js",
dependencies = {@Dependency(id = "jquery", alias = "$")}
)
})
package my.app;</pre>
<h2>Modular architecture</h2>
<p>Juzu can be extended with plugins and template engines.</p>
<h3>LESS plugin</h3>
<p>The LESS plugin compiles <em>.less</em> files to <em>.css</em> files during the compilation of the project:</p>
<pre>@Less(value = "bootstrap.less", minify = true)
package my.app;
</pre>
<h3>Webjars plugin</h3>
<p>Reuse web assets in your project with the Webjars support:</p>
<pre>@Application
@WebJars("jquery.js")
@Assets(scripts = { @Script(id = "jquery", src="jquery.js") })
package my.app;
</pre>
<h3>Portlet plugin</h3>
<p>The portlet plugin is able to generate a Portlet class for running the Juzu application. It also provides
dependency injection for Portlet Preferences:</p>
<pre>@Inject
PortletPreferences prefs;
</pre>
<h3>Mustache templates</h3>
<p>The <a href="http://mustache.github.com/">Mustache</a> template engine provides logic-free templating.</p>
<h1 class="page-header">Maven archetype</h1>
<p>The command line to use for creating a simple Juzu application using the Maven archetype</p>
<pre>
mvn archetype:generate \
-DarchetypeGroupId=org.juzu \
-DarchetypeArtifactId=juzu-archetype \
-DarchetypeVersion=0.7.0 \
-DgroupId=<my.groupid> \
-DartifactId=<my-artifactId></pre>
<h1 class="page-header">Building your app <small>Universal build</small></h1>
<p>Juzu integrates at the heart of the Java compiler thanks to Annotation Processing Tools (APT). APT allows to
perform code generation in a fully portable manner, it just work with the Java compiler in a very transparent
manner and thus is integrated with any build system or IDE that uses a Java 6 compiler.
</p>
<h2>Build time validation</h2>
<p>Validates various things during at build time.</p>
<h2>Compiler integration</h2>
<h3>URL literal generation</h3>
<p>
URL literal emulates first call support for application URLs, it allows an application to uses valid URLs at
build time.
</p>
<p>A controller method such as</p>
<pre>
public class Controller {
@View
public void showProduct(String productId) { }
}</pre>
<p>Generates an url literal like</p>
<pre>
public class Controller_ {
public static URLBuilder showProduct(String productId) { ... }
}</pre>
<p>That can be used</p>
<pre>URLBuilder url = Controller_.showProduct("myproduct");</pre>
<h3>Eclipse incremental support</h3>
<p>
Eclipse compiler works in a different fashion than the Oracle compiler. Juzu annotation processor was designed
to work nicely with the Eclipse compiler and provide incremental updates to the files generated by the application.
</p>
<h2>Live mode</h2>
<p>Juzu features a dev mode in which the application is recompiled in real time.</p>
<h2>Error reporting</h2>
<p>
Juzu should report error through the Java Compiler, making error reporting integrated universally with build
systems and IDE.
</p>
</div><!-- /.container -->
</div><!-- /.page /Features-->
</div><!-- /.inner -->
</div><!-- /#wrapper /.wrapper -->
<footer id="footer">
<div class="inner">
<p class="copy-right">Copyright ©2013. All rights reserved. <a href="#" title="Juzu Web Framework">Juzu</a></p>
</div>
</footer><!-- /#footer -->
<!-- Juzuweb Javascript -->
<!-- Currenly using Jquery v.1.7.1 because Jquery Address conflict with Jequery v.11.0 -->
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap-3.1/jquery.address-1.5.min.js"></script>
<script type="text/javascript" src="js/bootstrap-3.1/dropdown.js"></script>
<script type="text/javascript" src="js/bootstrap-3.1/collapse.js"></script>
<script type="text/javascript" src="js/bootstrap-3.1/juzu.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// The page navigation
$.address.change(function(event){
// Get anchor
var anchor = event.value.substring(1);
if (anchor == "")
anchor = "home";
//
var page = $(".page:has(a[name=" + anchor + "])");
if (page.length == 1) {
page.filter(function() {
return this != window.previous;
}).each(function() {
// Do show/hide
$(".page").hide();
$(this).show();
// Reset page to top
$(window).scrollTop(0);
// Update previous
window.previous = this;
});
} else {
// Should log something somehow
}
});
});
</script>
</body>
</html>