|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectplay.mvc.Controller
public abstract class Controller
Application controller support: The controller receives input and initiates a response by making calls on model objects. This is the class that your controllers should extend.
| Field Summary | |
|---|---|
static ThreadLocal<Router.ActionDefinition> |
_currentReverse
Don't use this directly if you don't know why |
protected static Scope.Flash |
flash
The current flash scope. |
protected static Scope.Params |
params
The current HTTP params. |
protected static Scope.RenderArgs |
renderArgs
The current renderArgs scope: This is a hash map that is accessible during the rendering phase. |
protected static Http.Request |
request
The current HTTP request: the message sent by the client to the server. |
protected static Http.Response |
response
The current HTTP response: The message sent back from the server after a request. |
protected static Scope.Session |
session
The current HTTP session. |
protected static Validation |
validation
The current Validation object. |
| Constructor Summary | |
|---|---|
Controller()
|
|
| Method Summary | ||
|---|---|---|
protected static void |
badRequest()
Send a 400 Bad request |
|
protected static void |
checkAuthenticity()
|
|
protected static void |
error()
Send a 500 Error response |
|
protected static void |
error(Exception reason)
Send a 500 Error response |
|
protected static void |
error(int status,
String reason)
Send a 5xx Error response |
|
protected static void |
error(String reason)
Send a 500 Error response |
|
protected static void |
flash(String key,
Object value)
Add a value to the flash scope |
|
protected static void |
forbidden()
Send a 403 Forbidden response |
|
protected static void |
forbidden(String reason)
Send a 403 Forbidden response |
|
protected static
|
getActionAnnotation(Class<T> clazz)
Retrieve annotation for the action method |
|
protected static
|
getControllerAnnotation(Class<T> clazz)
Retrieve annotation for the controller class |
|
protected static Class<?> |
getControllerClass()
Retrieve annotation for the action method |
|
protected static
|
getControllerInheritedAnnotation(Class<T> clazz)
Retrieve annotation for the controller class |
|
protected static void |
notFound()
Send a 404 Not Found reponse |
|
protected static void |
notFound(String what)
Send a 404 Not Found response |
|
protected static void |
notFoundIfNull(Object o)
Send a 404 Not Found response if object is null |
|
protected static void |
notModified()
Send a 304 Not Modified response |
|
protected static void |
ok()
Send a 200 OK response |
|
protected static void |
parent()
Call the parent method |
|
protected static void |
parent(Map<String,Object> map)
Call the parent action adding this objects to the params scope |
|
protected static void |
parent(Object... args)
Call the parent action adding this objects to the params scope |
|
protected static void |
redirect(String url)
Send a 302 redirect response. |
|
protected static void |
redirect(String url,
boolean permanent)
Send a Redirect response. |
|
protected static void |
redirect(String action,
boolean permanent,
Object... args)
Redirect to another action |
|
protected static void |
redirect(String action,
Object... args)
302 Redirect to another action |
|
protected static void |
redirectToStatic(String file)
Send a 302 redirect response. |
|
protected static void |
render(Object... args)
Render the corresponding template |
|
protected static void |
renderBinary(File file)
Return a 200 OK application/binary response |
|
protected static void |
renderBinary(File file,
String name)
Return a 200 OK application/binary response with content-disposition attachment |
|
protected static void |
renderBinary(InputStream is)
Return a 200 OK application/binary response |
|
protected static void |
renderBinary(InputStream is,
long length)
Return a 200 OK application/binary response. |
|
protected static void |
renderBinary(InputStream is,
String name)
Return a 200 OK application/binary response with content-disposition attachment |
|
protected static void |
renderBinary(InputStream is,
String name,
long length)
Return a 200 OK application/binary response with content-disposition attachment |
|
protected static void |
renderJSON(Object o)
Render a 200 OK application/json response |
|
protected static void |
renderJSON(Object o,
com.google.gson.JsonSerializer<?>... adapters)
Render a 200 OK application/json response |
|
protected static void |
renderJSON(String jsonString)
Render a 200 OK application/json response |
|
protected static void |
renderTemplate(String templateName,
Object... args)
Render a specific template |
|
protected static void |
renderText(CharSequence pattern,
Object... args)
Return a 200 OK text/plain response |
|
protected static void |
renderText(Object text)
Return a 200 OK text/plain response |
|
protected static void |
renderXml(Document xml)
Return a 200 OK text/xml response |
|
protected static void |
renderXml(String xml)
Return a 200 OK text/xml response |
|
protected static Router.ActionDefinition |
reverse()
|
|
protected static void |
suspend(int timeout)
|
|
protected static void |
suspend(String timeout)
Suspend the current request for a specified amount of time |
|
protected static void |
todo()
Send a TODO response |
|
protected static void |
unauthorized(String realm)
Send a 401 Unauthorized response |
|
protected static void |
waitFor(Future<?> task)
Suspend this request and wait for the task completion |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Http.Request request
protected static Http.Response response
protected static Scope.Session session
protected static Scope.Flash flash
protected static Scope.Params params
protected static Scope.RenderArgs renderArgs
protected static Validation validation
public static ThreadLocal<Router.ActionDefinition> _currentReverse
| Constructor Detail |
|---|
public Controller()
| Method Detail |
|---|
protected static void renderText(Object text)
text - The response content
protected static void renderText(CharSequence pattern,
Object... args)
pattern - The response content to be formatted (with String.format)args - Args for String.formatprotected static void renderXml(String xml)
xml - The XML stringprotected static void renderXml(Document xml)
xml - The DOM document objectprotected static void renderBinary(InputStream is)
is - The stream to copy
protected static void renderBinary(InputStream is,
long length)
is - The stream to copy
protected static void renderBinary(InputStream is,
String name)
is - The stream to copyname - The attachment name
protected static void renderBinary(InputStream is,
String name,
long length)
is - The stream to copy. COntent is streamedname - The attachment nameprotected static void renderBinary(File file)
file - The file to copy
protected static void renderBinary(File file,
String name)
file - The file to copyname - The attachment nameprotected static void renderJSON(String jsonString)
jsonString - The JSON stringprotected static void renderJSON(Object o)
o - The Java object to serialize
protected static void renderJSON(Object o,
com.google.gson.JsonSerializer<?>... adapters)
o - The Java object to serializeadapters - A set of GSON serializers/deserializers/instance creator to useprotected static void notModified()
protected static void badRequest()
protected static void unauthorized(String realm)
realm - The realm nameprotected static void notFound(String what)
what - The Not Found resource nameprotected static void ok()
protected static void todo()
protected static void notFoundIfNull(Object o)
o - The object to checkprotected static void notFound()
protected static void checkAuthenticity()
protected static void forbidden(String reason)
reason - The reasonprotected static void forbidden()
protected static void error(int status,
String reason)
status - The exact status codereason - The reasonprotected static void error(String reason)
reason - The reasonprotected static void error(Exception reason)
reason - The reasonprotected static void error()
protected static void flash(String key,
Object value)
key - The keyvalue - The valueprotected static void redirect(String url)
url - The Location to redirectprotected static void redirectToStatic(String file)
file - The Location to redirect
protected static void redirect(String url,
boolean permanent)
url - The Location to redirectpermanent - true -> 301, false -> 302
protected static void redirect(String action,
Object... args)
action - The fully qualified action name (ex: Application.index)args - Method arguments
protected static void redirect(String action,
boolean permanent,
Object... args)
action - The fully qualified action name (ex: Application.index)permanent - true -> 301, false -> 302args - Method arguments
protected static void renderTemplate(String templateName,
Object... args)
templateName - The template nameargs - The template dataprotected static void render(Object... args)
args - The template dataprotected static <T extends Annotation> T getActionAnnotation(Class<T> clazz)
clazz - The annotation class
protected static <T extends Annotation> T getControllerAnnotation(Class<T> clazz)
clazz - The annotation class
protected static <T extends Annotation> T getControllerInheritedAnnotation(Class<T> clazz)
clazz - The annotation class
protected static Class<?> getControllerClass()
protected static void parent(Object... args)
protected static void parent()
protected static void parent(Map<String,Object> map)
protected static void suspend(String timeout)
protected static void suspend(int timeout)
protected static void waitFor(Future<?> task)
protected static Router.ActionDefinition reverse()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||