|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.infohazard.maverick.ctl.Throwaway2
org.infohazard.maverick.ctl.ThrowawayBean2
org.activemath.webapp.base.ControllerBase
public class ControllerBase
Base class for all ActiveMath controllers. This class provides:
action())
getCurrentUser())
log)
addError(java.lang.String, java.lang.String))
| Field Summary | |
|---|---|
protected static AppContext |
appContext
Applicaton context |
protected static String |
defaultContentType
Default content type of the HttpServletResponse |
static String |
JSON
Common name for the JSON view. |
protected static Logger |
log
The logger for this class |
static String |
REDIRECT
Common name for the typical "redirect" view. |
static String |
REDIRECT_LOGIN
|
protected HttpServletRequest |
request
|
protected HttpServletResponse |
response
|
protected StopWatch |
stopwatch
|
| Fields inherited from class org.infohazard.maverick.ctl.Throwaway2 |
|---|
ERROR, SUCCESS |
| Constructor Summary | |
|---|---|
ControllerBase()
|
|
| Method Summary | |
|---|---|
protected String |
action()
This is the method you should override to implement application logic. |
protected void |
addError(String message)
Add a simple error message. |
protected void |
addError(String field,
String message)
Add an error to this request. |
protected void |
enableNoCache()
Tell browser not to cache the response. |
protected String |
escapeForHtmlSafety(String value)
Make a string safe for HTML markup. |
protected AccountManager |
getAccountManager()
Return the user account management object |
protected AppSession |
getAppSession()
Return the AppSession of the current user, of AnonUser, or null. |
protected String |
getCmdName()
Returns the name of the command ("/dict/show"), with ".cmd" stripped of. |
protected User |
getCurrentUser()
Get the current User object. |
Map |
getErrors()
Return a map of error messages added by addError(String, String). |
protected HttpSession |
getHttpSession()
Return the HttpSession of this controller context |
protected String |
getLanguage()
The language to use for this request, as determined by ServletUtils#getLanguage(). |
protected AppModel |
getModel()
Give access to the basic model object, which is to be filled by action() |
protected String |
getOutputFormat()
|
protected HttpServletRequest |
getRequest()
Return the HttpServletRequest of this controller context |
protected HttpServletResponse |
getResponse()
Return the HttpServletResponse of this controller context |
protected Skin |
getSkin()
|
boolean |
hasErrors()
|
String |
perform()
Basic request handling method. |
protected void |
publishControllerEvent(ActivemathEvent event)
Publish an event for a controller. |
protected String |
sendError(String message)
|
protected String |
sendError(String message,
Throwable e)
Return an error view (with HTTP code 500). |
protected String |
sendJson(String jsonCode)
Return a JSON value. |
protected String |
sendLoginRequired()
Forward to the login controller. |
protected String |
sendRedirect(String url)
Redirect to a redirect view without params. |
protected String |
sendRedirect(String url,
Map params)
Redirect to a redirect view. |
void |
setPasswd(String string)
|
void |
setUser(String string)
|
| Methods inherited from class org.infohazard.maverick.ctl.ThrowawayBean2 |
|---|
go |
| Methods inherited from class org.infohazard.maverick.ctl.Throwaway2 |
|---|
getCtx, go |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static Logger log
public static final String REDIRECT
public static final String REDIRECT_LOGIN
public static final String JSON
protected static String defaultContentType
HttpServletResponse
protected HttpServletRequest request
protected HttpServletResponse response
protected static AppContext appContext
protected StopWatch stopwatch
| Constructor Detail |
|---|
public ControllerBase()
| Method Detail |
|---|
public void setUser(String string)
public void setPasswd(String string)
protected String escapeForHtmlSafety(String value)
protected final AccountManager getAccountManager()
protected HttpSession getHttpSession()
HttpSession of this controller context
protected HttpServletRequest getRequest()
HttpServletRequest of this controller context
protected HttpServletResponse getResponse()
HttpServletResponse of this controller context
protected String getCmdName()
protected AppModel getModel()
action()
Map)protected void publishControllerEvent(ActivemathEvent event)
User events will not be published if user is not logged in.
Before publishing, this will fill in the following data for the event:
protected AppSession getAppSession()
AppSession of the current user, of AnonUser, or null.
public boolean hasErrors()
public Map getErrors()
addError(String, String).
The interpretation of the map is left to the view.
Empty map if no errors have been reported.
protected void addError(String field,
String message)
field - - error id, use to group messages.message - - interpreted by the view as text or as phrase keyprotected void addError(String message)
protected String sendError(String message)
protected String sendError(String message,
Throwable e)
exception)
and a stack traces ($Stacktrace and $StacktraceStripped).
protected User getCurrentUser()
null if no user can be determined.protected String getLanguage()
ServletUtils#getLanguage().
Note: ONLY CALL THIS METHOD FROM INSIDE action()!
protected Skin getSkin()
protected String getOutputFormat()
protected String sendRedirect(String url)
protected String sendRedirect(String url,
Map params)
<view name="redirect" type="redirect"/>
If you want to redirect to yourself, just do
return sendRedirect(request.getRequestURI(), params);
url -
protected String sendJson(String jsonCode)
protected String sendLoginRequired()
protected void enableNoCache()
public final String perform()
throws Exception
enableNoCache().
text/html; charset=UTF-8)
AppSession if needed and link it to the HTTPSession.
AuthenticationManager#tryAutoLogin().
AppModel for this request
AnonUser for this request if necessary.
action() of the subclass,
and catch all exceptions arising from it
perform in class ThrowawayBean2Exception
protected String action()
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||