|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xpn.xwiki.api.Api
com.xpn.xwiki.api.Context
public class Context
The Context class represents a secure proxy for the XWiki context, which in turn represents the
execution environment for all the wiki pages. An instance of the Context class is available as a
predefined variable for scripting inside any wiki page. You can access it using $context in Velocity
scripts or simply context in Groovy ones. The Context class provides a means of getting
contextual information about the current request or configuring XWiki on the fly.
| Field Summary |
|---|
| Fields inherited from class com.xpn.xwiki.api.Api |
|---|
context |
| Constructor Summary | |
|---|---|
Context(XWikiContext context)
|
|
| Method Summary | |
|---|---|
java.lang.Object |
get(java.lang.String key)
Returns the value associated with the given key in the XWiki context. |
java.lang.String |
getAction()
Returns the current action. |
int |
getCacheDuration()
Returns the amount of time this document should be cached. |
XWikiContext |
getContext()
Returns the XWiki context. |
java.lang.String |
getDatabase()
Returns the current database name. |
java.util.List |
getDisplayedFields()
Returns the list with the currently displayed fields. |
XWikiDocument |
getDoc()
Returns the current requested document. |
java.lang.String |
getEditorWysiwyg()
Returns the list of textarea fields that use the WYSIWYG editor. |
java.lang.String |
getInterfaceLanguage()
Returns the interface language preference of the current user. |
java.lang.String |
getLanguage()
Returns the language of the current request. |
java.lang.String |
getLinksAction()
Returns the action used by XWiki URL factories to replace the view action when creating URLs. |
java.lang.String |
getLinksQueryString()
Returns the extra query string that is added to all the URLs created by XWiki URL factories. |
java.lang.String |
getLocalUser()
Returns the current user which made the request. |
java.lang.String |
getMainWikiName()
Returns the name of the main wiki. |
int |
getMode()
Specifies the container or environment in which XWiki is currently running. |
java.lang.String |
getOriginalDatabase()
Returns the name of the original database. |
XWikiRequest |
getRequest()
Returns the current request object. |
XWikiResponse |
getResponse()
Returns the current response object. |
XWikiURLFactory |
getURLFactory()
Returns the URL factory matching both the protocol used to make the current request and the container or environment in which XWiki is running. |
java.lang.String |
getUser()
Returns the current user which made the request. |
Util |
getUtil()
Returns an instance of the Util class. |
XWikiValidationStatus |
getValidationStatus()
Returns the form field validation status, which contains the exceptions or errors that may have occured during the validation process performed during a save. |
XWiki |
getXWiki()
Returns the XWiki object. |
boolean |
isMainWiki()
Specifies if the current request was made to a virtual (non-main) wiki, or to the main wiki. |
void |
put(java.lang.String key,
java.lang.Object value)
Puts an object on the context using the given key. |
void |
setCacheDuration(int duration)
Sets the cache duration in seconds. |
void |
setDatabase(java.lang.String database)
Sets the current database. |
void |
setDisplayMode(java.lang.String mode)
Sets the default field display mode, when using Document.display(String) or
Document.display(String, Object). |
void |
setDoc(XWikiDocument doc)
Sets the current document. |
void |
setFinished(boolean finished)
Specifies if the current page should be sent to the client or not. |
void |
setLinksAction(java.lang.String action)
Sets the action to be used instead of the view action inside URLs. |
void |
setLinksQueryString(java.lang.String value)
Sets an extra query string to be added to all the URLs created by XWiki URL factories. |
void |
unsetLinksAction()
Stops the view action from being replaced with another action inside URLs. |
void |
unsetLinksQueryString()
Specifies that no additional query string should be added to XWiki URLs. |
| Methods inherited from class com.xpn.xwiki.api.Api |
|---|
convert, convert, getXWikiContext, hasAccessLevel, hasAdminRights, hasProgrammingRights |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Context(XWikiContext context)
| Method Detail |
|---|
public XWikiRequest getRequest()
HttpServletRequest instance.
public XWikiResponse getResponse()
HttpServletResponse instance.
public int getMode()
| Return | Meaning |
|---|---|
| 0 | Servlet Container |
| 1 | Portlet Container |
| 2 | XML RPC |
| 3 | Atom |
| 4 | |
| 5 | GWT |
| 6 | GWT Debugging |
public java.lang.String getDatabase()
isMainWiki() returns true then the current database
name is the same as getMainWikiName(). Otherwise, in virtual mode, each virtual wiki has it's own
database. In this case the returned string identifies the current virtual wiki we operate on and prefixes
document names like in databaseName:spaceName.pageName.
isMainWiki(),
getMainWikiName()public java.lang.String getMainWikiName()
public java.lang.String getOriginalDatabase()
#includeTopic("virtualwiki:Some.Document").
@Programming public void setDatabase(java.lang.String database)
database - a database namegetDatabase()public XWikiURLFactory getURLFactory()
XWikiURLFactory
are XWikiServletURLFactory and XWikiPortletURLFactory. XWikiURLFactory
offers a generic way of creating XWiki specific URLs that should be chosen instead of the basic string
concatenation. Hard-coding the protocol used, like HTTP, inside wiki pages should be avoided.
public boolean isMainWiki()
Specifies if the current request was made to a virtual (non-main) wiki, or to the main wiki.
In virtual mode the server can host more than one wiki, each having it's own database and its own URL. We refer
to them as virtual wikis. One of them stores information about the others and it is called the main
wiki. You can switch to virtual mode by changing the xwiki.virtual parameter from 0
to 1 in the configuration file.
true if XWiki is in the main wiki, or if virtual mode is disabled.getDatabase(),
getMainWikiName()public java.lang.String getAction()
public java.lang.String getLanguage()
multilingual is turned off then the language used is
given by the default_language preference. Otherwise, the language is take from either the request
object, the cookie, user preferences or from the navigator language settings, the last having the lower priority.
getInterfaceLanguage()public java.lang.String getInterfaceLanguage()
multilingual is turned off then
the language used is given by the default_language preference. Otherwise, the language is take from
either the request object, the context, the cookie, user preferences or from the navigator language settings, the
last having the lower priority.
getLanguage()@Programming public XWiki getXWiki()
$xwiki in Velocity.
null otherwise.@Programming public XWikiDocument getDoc()
$doc in
Velocity.
null otherwise.public java.lang.String getUser()
$xwiki.getDocument($context.user) to find out more about the current user, like his/hers real name
or e-mail address.
getLocalUser(),
getDatabase()public java.lang.String getLocalUser()
getUser() is that the returned
string is never prefixed with the database name, not even in virtual mode.
getUser(),
getDatabase()@Programming public void setDoc(XWikiDocument doc)
doc - XWiki document to set as the context document.@Programming public XWikiContext getContext()
null otherwise.@Programming public java.lang.Object get(java.lang.String key)
key - The key to look for in the context.
null otherwise.put(String, Object)public java.lang.String getEditorWysiwyg()
@Programming
public void put(java.lang.String key,
java.lang.Object value)
key - The parameter name.value - The parameter value.get(String)public void setFinished(boolean finished)
.xar archive.
finished - true to avoid rendering of the current pagepublic int getCacheDuration()
setCacheDuration(int)public void setCacheDuration(int duration)
duration - The cache duration specified in seconds.getCacheDuration()public void setLinksAction(java.lang.String action)
action - view action replacementunsetLinksAction(),
getLinksAction(),
getURLFactory()public void unsetLinksAction()
setLinksAction(String),
getLinksAction()public java.lang.String getLinksAction()
null.
null.setLinksAction(String),
unsetLinksAction(),
getURLFactory()public void setLinksQueryString(java.lang.String value)
value - The additional query string to be added to all the URLs created by XWiki URL factories.unsetLinksQueryString(),
getLinksQueryString(),
getURLFactory()public void unsetLinksQueryString()
setLinksQueryString(String),
getLinksQueryString()public java.lang.String getLinksQueryString()
null.
null.setLinksQueryString(String),
unsetLinksQueryString(),
getURLFactory()public XWikiValidationStatus getValidationStatus()
public java.util.List getDisplayedFields()
display on a document for a
specific field that field is added to the list returned by this method.
Document.display(String)public Util getUtil()
Util class.
Util classUtilpublic void setDisplayMode(java.lang.String mode)
Document.display(String) or
Document.display(String, Object). It is automatically set to "edit" when the action is "inline", and to
"view" in all other cases.
mode - the display mode, one of "view", "edit", "hidden", "search", "rendered".
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||