Package org.javalite.activeweb
Class AppController
java.lang.Object
org.javalite.activeweb.HttpSupport
org.javalite.activeweb.AppController
- All Implemented Interfaces:
RequestAccess
- Direct Known Subclasses:
AbstractLesscController
,AbstractSASSController
,SimpleController
Subclass this class to create application controllers. A controller is a main component of a web
application. Its main purpose in life is to process web requests.
- Author:
- Igor Polevoy
-
Nested Class Summary
Nested classes/interfaces inherited from class org.javalite.activeweb.HttpSupport
HttpSupport.HttpBuilder, HttpSupport.RenderBuilder
-
Field Summary
Fields inherited from interface org.javalite.activeweb.RequestAccess
LOGGER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
Returns hardcoded value "text/html".protected String
Returns a name for a default layout as provided inactiveweb_defaults.properties
file.protected HttpSupport.RenderBuilder
render()
Use this method in order to override a layout, status code, and content type.protected HttpSupport.RenderBuilder
Renders results with a template.boolean
restful()
Returns true if this controller is configured to beRESTful
.static <T extends AppController>
booleanMethods inherited from class org.javalite.activeweb.HttpSupport
applicationJSON, assign, blank, encoding, flash, flash, flash, flash, getEncoding, getFile, getHttpServletRequest, getHttpServletResponse, getMap, getMap, getRealPath, getRequestBytes, getRequestInputStream, getRequestStream, getRequestString, getResponseHeaders, header, header, jsonList, jsonMap, jsonMaps, locale, logDebug, logError, logError, logError, logInfo, logWarning, logWarning, merge, multipartForm, multipartForm, multipartFormItems, multipartFormItems, multipartFormItems, outputStream, outputStream, outputStream, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirect, redirectToReferrer, redirectToReferrer, render, respond, sanitize, sendCookie, sendCookie, sendFile, sendFile, sendPermanentCookie, session, session, sessionBoolean, sessionDouble, sessionFloat, sessionHas, sessionInteger, sessionLong, sessionObject, sessionString, setContentLength, setEncoding, setLocale, setRequestEncoding, setResponseEncoding, status, streamOut, uploadedFiles, uploadedFiles, uploadedFiles, values, view, view, view, writer, writer
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.javalite.activeweb.RequestAccess
appContext, context, cookie, cookies, cookieValue, exists, format, getId, getLocale, getRequestHost, getRequestPort, getRequestProperties, getRequestProtocol, getRoute, header, headers, host, ipAddress, ipForwardedFor, isDelete, isGet, isHead, isMethod, isMultipartContent, isPost, isPut, isXhr, locale, method, param, param, params, params, params, params1st, params1st, path, port, protocol, queryString, remoteAddress, remoteHost, requestHas, servletPath, session, session, uri, url, userAgent, xhr
-
Constructor Details
-
AppController
public AppController()
-
-
Method Details
-
render
Renders results with a template. This method is called from within an action execution. This call must be the last call in the action. All subsequent calls to assign values, render or respond will generateIllegalStateException
.- Parameters:
template
- - template name, can be "list" - for a view whose name is different than the name of this action, or "/another_controller/any_view" - this is a reference to a view from another controller. The format of this parameter should be either a single word or two words separated by slash: '/'. If this is a single word, than it is assumed that template belongs to current controller, if there is a slash used as a separator, then the first word is assumed to be a name of another controller.- Returns:
- instance of
HttpSupport.RenderBuilder
, which is used to provide additional parameters.
-
render
Use this method in order to override a layout, status code, and content type.- Returns:
- instance of
HttpSupport.RenderBuilder
, which is used to provide additional parameters.
-
getLayout
Returns a name for a default layout as provided inactiveweb_defaults.properties
file. Override this method in a sub-class. Value expected is a fully qualified name of a layout template. Example:"/custom/custom_layout"
- Returns:
- name of a layout for this controller and descendants if they do not override this method.
-
getContentType
Returns hardcoded value "text/html". Override this method to set default content type to a different value across all actions in controller and its subclasses. This is a convenient method for building REST webservices. You can set this value once to "text/json", "text/xml" or whatever else you need.- Returns:
- hardcoded value "text/html"
-
restful
public boolean restful()Returns true if this controller is configured to beRESTful
.- Returns:
- true if this controller is restful, false if not.
-
restful
-