public abstract class XWikiAction
extends org.apache.struts.action.Action
Root class for most XWiki actions. It provides a common framework that allows actions to execute just the specific action code, handling the extra activities, such as preparing the context and retrieving the document corresponding to the URL.
It defines two methods, action(XWikiContext)
and render(XWikiContext)
, that should be overridden by
specific actions. action(XWikiContext)
should contain the processing part of the action.
render(XWikiContext)
should return the name of a template that should be rendered, or manually write to the
response
stream.
Serving a request goes through the following phases:
XWiki-specific context
action(XWikiContext)
action(XWikiContext)
returns true, run the overridden render(XWikiContext)
render(XWikiContext)
returned a string (template name), render the template with that nameDuring this process, also handle specific errors, like when a document does not exist, or the user does not have the right to perform the current action.
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_PROGRESS |
protected boolean |
handleRedirectObject
Indicate if the XWiki.RedirectClass is handled by the action (see handleRedirectObject()).
|
protected boolean |
waitForXWikiInitialization
Indicate if the action is blocked until XWiki is initialized.
|
Constructor and Description |
---|
XWikiAction() |
Modifier and Type | Method and Description |
---|---|
boolean |
action(XWikiContext context) |
protected void |
cleanupComponents() |
protected boolean |
csrfTokenCheck(XWikiContext context)
Perform CSRF check and redirect to the resubmission page if needed.
|
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Handle server requests.
|
org.apache.struts.action.ActionForward |
execute(XWikiContext context) |
protected ScriptContext |
getCurrentScriptContext() |
protected ContextualLocalizationManager |
getLocalization() |
protected org.xwiki.job.event.status.JobProgressManager |
getProgress() |
String |
getRealPath(String path) |
protected XWikiDocument |
getTranslatedDocument(XWikiDocument doc,
String language,
XWikiContext context)
Gets the translated version of a document, in the specified language.
|
protected boolean |
handleRedirectObject(XWikiContext context)
Redirect the user to an other location if the document holds an XWiki.RedirectClass instance (used when a
document is moved).
|
protected void |
handleRevision(XWikiContext context) |
protected void |
initializeContainerComponent(XWikiContext context) |
protected XWikiContext |
initializeXWikiContext(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) |
protected String |
localizePlainOrKey(String key,
Object... parameters) |
String |
render(XWikiContext context) |
protected boolean |
sendGlobalRedirect(XWikiResponse response,
String url,
XWikiContext context)
Send redirection based on a regexp pattern (if any) set at the main wiki level.
|
protected void |
sendRedirect(XWikiResponse response,
String url) |
addErrors, addMessages, execute, generateToken, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
public static final String ACTION_PROGRESS
protected boolean waitForXWikiInitialization
protected boolean handleRedirectObject
protected ContextualLocalizationManager getLocalization()
protected org.xwiki.job.event.status.JobProgressManager getProgress()
protected ScriptContext getCurrentScriptContext()
ScriptContext
instancepublic org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws Exception
execute
in class org.apache.struts.action.Action
mapping
- The ActionMapping used to select this instanceform
- The optional ActionForm bean for this request (if any)req
- The HTTP request we are processingresp
- The HTTP response we are creatingIOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet exception occursException
public org.apache.struts.action.ActionForward execute(XWikiContext context) throws Exception
Exception
protected XWikiContext initializeXWikiContext(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws XWikiException, javax.servlet.ServletException
XWikiException
javax.servlet.ServletException
protected void initializeContainerComponent(XWikiContext context) throws javax.servlet.ServletException
javax.servlet.ServletException
protected void cleanupComponents()
public boolean action(XWikiContext context) throws XWikiException
XWikiException
public String render(XWikiContext context) throws XWikiException
XWikiException
protected boolean handleRedirectObject(XWikiContext context) throws XWikiException
context
- the XWiki contextXWikiException
- if error occursprotected void handleRevision(XWikiContext context) throws XWikiException
XWikiException
protected boolean sendGlobalRedirect(XWikiResponse response, String url, XWikiContext context) throws Exception
response
- the servlet responseurl
- url of the requestcontext
- the XWiki contextException
protected void sendRedirect(XWikiResponse response, String url) throws XWikiException
XWikiException
protected XWikiDocument getTranslatedDocument(XWikiDocument doc, String language, XWikiContext context) throws XWikiException
doc
- the main (default, untranslated) document to translatelanguage
- the requested document languagecontext
- the current request contextXWikiException
- if the translation cannot be retrieved from the databaseprotected boolean csrfTokenCheck(XWikiContext context) throws XWikiException
context
- current xwiki context containing the requestXWikiException
- if the check failsCopyright © 2004–2017 XWiki. All rights reserved.