xoplatform.org");
Proceed to render phase
A Response.View
response instructs Juzu to proceed to the render phase of a valid view controller, this kind of response can be created using an {@link juzu.request.ActionContext}, however the best way is to use a controller companion class that carries method factories for creating render responses.
Type safe {@link juzu.Response.View} factory method are generated for each view or resource controllermethods. The signature of an render factory is obtained by using the same signature of the controller method.
public class MyController { @Action public {@link juzu.Response.View} myAction() {return MyController_.myView("hello"); } @View public void myView(String param) { } }
Mime response
Mime response are used by the {@link juzu.request.Phase#VIEW} and the {@link juzu.request.Phase#RESOURCE} phases.Both contains a content to be streamed to the client but still they have some noticeable differences.
The {@link juzu.Response.Content} class is the base response class which will work well for the two phases.However the {@link juzu.request.Phase#VIEW} can specify an optional title and the {@link juzu.request.Phase#RESOURCE}can specify an optional status code for the user agent response.
Responses are created using the {@link Response} factory methods such as
- {@link Response#ok} creates an ok response
- {@link Response#notFound} creates a not found response
Response can also created from {@link juzu.template.Template} directly:
public class MyController { @Inject @Path("index.gtmpl") {@link juzu.template.Template} index;@View public {@link juzu.Response.Content} myView() {return index.ok(); } @Inject @Path("error.gtmpl") {@link juzu.template.Template} error;@Resource public {@link juzu.Response.Content} myView() {return error.notFound(); } }
The {@link juzu.template.Template.Builder} can also create responses:
public class MyController { @Inject @Path("index.gtmpl") index index; @View public {@link juzu.Response.Content} myView() {return index.with().label("hello").ok(); } }
@author
Julien Viet