|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjuzu.Response
public abstract 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.Update 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.Update 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.Update 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.Content 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.CharSequence) creates an ok responsenotFound(java.lang.CharSequence) creates a not found responseResponse can also created from Template directly:
public class MyController {
@Inject @Path("index.gtmpl") Template index;
@View
public Response.Render myView() {
return index.render();
}
@Inject @Path("error.gtmpl") Template error;
@Resource
public Response.Content myView() {
return error.notFound();
}
}
The Template.Builder can also create responses:
public class MyController {
@Inject @Path("index.gtmpl") index index;
@View
public Response.Content myView() {
return index.with().label("hello").render();
}
}
| Nested Class Summary | |
|---|---|
static class |
Response.Content<S extends Stream>
|
static class |
Response.Redirect
A response instructing to execute an HTTP redirection after the current interaction. |
static class |
Response.Render
|
static class |
Response.Update
A response instructing to execute a render phase of a controller method after the current interaction. |
| Method Summary | ||
|---|---|---|
static Response.Content<Stream.Char> |
content(int code,
CharSequence content)
|
|
static Response.Content<Stream.Binary> |
content(int code,
InputStream content)
|
|
static Response.Content<Stream.Char> |
content(int code,
Streamable<Stream.Char> content)
|
|
static Response.Content<Stream.Binary> |
content(int code,
String mimeType,
InputStream content)
|
|
PropertyMap |
getProperties()
|
|
static Response.Content<Stream.Char> |
notFound(CharSequence content)
|
|
static Response.Content<Stream.Char> |
ok(CharSequence content)
|
|
static Response.Content<Stream.Binary> |
ok(InputStream content)
|
|
static Response.Content<Stream.Binary> |
ok(String mimeType,
InputStream content)
|
|
static Response.Redirect |
redirect(String location)
|
|
static Response.Render |
render(CharSequence content)
|
|
static Response.Render |
render(String title,
CharSequence content)
|
|
|
with(PropertyType<T> propertyType,
T propertyValue)
Set a property, if the value is null, the property is removed. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public <T> Response with(PropertyType<T> propertyType,
T propertyValue)
throws NullPointerException
propertyType - the property typepropertyValue - the property value
NullPointerException - if the property type is nullpublic final PropertyMap getProperties()
public static Response.Redirect redirect(String location)
public static Response.Render render(CharSequence content)
public static Response.Render render(String title,
CharSequence content)
public static Response.Content<Stream.Char> ok(CharSequence content)
public static Response.Content<Stream.Binary> ok(String mimeType,
InputStream content)
public static Response.Content<Stream.Binary> ok(InputStream content)
public static Response.Content<Stream.Char> notFound(CharSequence content)
public static Response.Content<Stream.Char> content(int code,
CharSequence content)
public static Response.Content<Stream.Char> content(int code,
Streamable<Stream.Char> content)
public static Response.Content<Stream.Binary> content(int code,
InputStream content)
public static Response.Content<Stream.Binary> content(int code,
String mimeType,
InputStream content)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||