Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.juzu
Class Response

    java.lang.Object
      org.juzu.Response

Direct Known Subclasses:
  Response.Action, Response.Mime

    public class Response

extends Object

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.

## Action response

### Redirection response

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");

### Proceed to render phase

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

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 response
- `notFound()` creates a not found response

Response 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();
           }
        }

`

Author:
  Julien Viet

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

### Response

    public Response()

Method Detail

### redirect

    public static Response.Action.Redirect redirect(String location)

### ok

    public static Response.Mime ok(String content)

### ok

    public static Response.Render ok(String title,
                                     String content)

### notFound

    public static Response.Resource notFound()

### notFound

    public static Response.Resource notFound(String content)

### status

    public static Response.Resource status(int code)

### status

    public static Response.Resource status(int code,
                                           String content)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 eXo Platform SAS. All Rights Reserved.