|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.juzu.Response
public class Response
A response object signalling to the portal the action to take after an interaction. This object is usually returned after the invocation of a controller method and instructs the aggregator the action to take.
A Response.Process.Action.Redirect response instructs the aggregator to make a redirection to a valid URL after the
interaction, this kind of response is created using the factory method redirect(String):
return Response.redirect("http://www.exoplatform.org");
A Response.Process.Action.Render response instructs the aggreator to proceed to the render phase of a valid
view controller, this kind of response can be created using an ActionContext, however
the the preferred way is to use a controller companion class that carries method factories for creating render
responses.
Type safe Response.Action.Render factory method are generated for each view or resource controller methods.
The signature of an render factory is obtained by using the same signature of the controller method.
public class MyController {
@Action
public Response.Action.Render myAction() {
return MyController_.myRender("hello");
}
@View
public void myRender(String param) {
}
}
Mime response are used by the Phase.RENDER and the Phase.RESOURCE phases.
Both contains a content to be streamed to the client but still they have some noticeable differences.
The Response.Mime class is the base response class which will work well for the two phases. However the
Phase.RENDER can specify an optional title and the Phase.RESOURCE can
specify an optional status code for the user agent response.
Responses are created using the Response factory methods such as
ok(java.lang.String) creates an ok responsenotFound() creates a not found responseResponse can also created from Template directly:
public class MyController {
@Inject @Path("index.gtmpl") Template index;
@View
public Response.Mime myView() {
return index.ok();
}
@Inject @Path("error.gtmpl") Template error;
@Resource
public Response.Mime myView() {
return error.notFound();
}
}
The Template.Builder can also create responses:
public class MyController {
@Inject @Path("index.gtmpl") index index;
@View
public Response.Mime myView() {
return index.with().label("hello").ok();
}
}
| Nested Class Summary | |
|---|---|
static class |
Response.Action
|
static class |
Response.Mime
|
static class |
Response.Render
|
static class |
Response.Resource
|
static interface |
Response.Stream
|
static interface |
Response.Update
|
| Constructor Summary | |
|---|---|
Response()
|
|
| Method Summary | |
|---|---|
static Response.Resource |
notFound()
|
static Response.Resource |
notFound(String content)
|
static Response.Mime |
ok(String content)
|
static Response.Render |
ok(String title,
String content)
|
static Response.Action.Redirect |
redirect(String location)
|
static Response.Resource |
status(int code)
|
static Response.Resource |
status(int code,
String content)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Response()
| Method Detail |
|---|
public static Response.Action.Redirect redirect(String location)
public static Response.Mime ok(String content)
public static Response.Render ok(String title,
String content)
public static Response.Resource notFound()
public static Response.Resource notFound(String content)
public static Response.Resource status(int code)
public static Response.Resource status(int code,
String content)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||