Class JspContext
ActionFactory.prepareContext(InvokationContext)
and ActionFactory.getActions(InvokationContext)
methods
and other methods that has a context parameter.
@Override public boolean prepareContext(InvokationContext context) { JspContext jspContext = (JspContext)context.getClientContext(); jspContext.addStylesheet("/base/include/styles/mystylesheet.css"); // Do other things return true; }
This context exposes the underlying JSP PageContext
,
which can be used to get information about the current request
among other things. Render factories usually needs access to
the response output stream, getOut()
, so that renderers
can write the generated HTML to the response.
- Version:
- 2.7
- Author:
- nicklas
- Last modified
- $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The key that is used when storing a JspContext object in a request/page/session/etc. attribute.static final String
The key that is used when storing an Extension object in a request/page/session/etc. attribute.private final GuiContext
private final ItemContext
private boolean
private final PageContext
-
Constructor Summary
ConstructorDescriptionJspContext
(SessionControl sc, DbControl dc, ItemContext itemContext, PageContext pageContext, GuiContext guiContext, Object item) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an absolute reference to a script that should be included on the generated page with a<script>
tag.void
addScripts
(Collection<String> scriptsToAdd) Add several scripts in one go.void
addStylesheet
(String absolutePath) Add an absolute reference to a CSS stylesheet that should be included on the generated page with a<link>
tag.void
addStylesheets
(Collection<String> stylesheetsToAdd) Add several stylesheets in one go.Get the current item context.Get the currentGuiContext
.Get the URL to the home directory for a given extension.getOut()
Get a writer object that can be used to return generated text to the response that is sent back to the browser.Get the JSP Page context object for the current request.getRoot()
Get the URL to the web application root as a string.Get all scripts that has been added to this context.getScripts
(String xtId) Get all scripts that has been added to this context by the given extensionGet the Set that is stored under the given key.Get all stylesheets that has been added to this context.getStylesheets
(String xtId) Get all stylesheets that has been added to this context by the given extension.void
setNeedResourcesPerExtension
(boolean nrpe) Set a flag indicating that resources (eg. scripts and stylesheets) should be tracked per extension.Methods inherited from class net.sf.basedb.util.extensions.ClientContext
getAttribute, getCurrentExtension, getCurrentExtensionPoint, getCurrentItem, getDbControl, getSessionControl, linkAttributes, loadAttributes, setAttribute, setCurrentExtension, setCurrentExtensionPoint, setCurrentItem, storeAttributes
-
Field Details
-
ATTRIBUTE_KEY
The key that is used when storing a JspContext object in a request/page/session/etc. attribute.- Since:
- 2.17
- See Also:
-
EXTENSION_KEY
The key that is used when storing an Extension object in a request/page/session/etc. attribute.- Since:
- 3.3
- See Also:
-
pageContext
-
guiContext
-
itemContext
-
needResourcesPerExtension
private boolean needResourcesPerExtension -
scripts
-
stylesheets
-
-
Constructor Details
-
JspContext
JspContext(SessionControl sc, DbControl dc, ItemContext itemContext, PageContext pageContext, GuiContext guiContext, Object item)
-
-
Method Details
-
setNeedResourcesPerExtension
public void setNeedResourcesPerExtension(boolean nrpe) Set a flag indicating that resources (eg. scripts and stylesheets) should be tracked per extension. If this is set, it is possible to usegetScripts(String)
andgetStylesheets(String)
to get the resources that was added by the given extension.- Since:
- 3.19.3
-
getPageContext
Get the JSP Page context object for the current request. -
getOut
Get a writer object that can be used to return generated text to the response that is sent back to the browser.Note! The writer is only intended to be used by render objects when rendering the extensions. Using the writer from the
ActionFactory.prepareContext(InvokationContext)
orRendererFactory.prepareContext(InvokationContext)
method may produce unpredictable results.- Returns:
- A
JspWriter
object
-
getGuiContext
Get the currentGuiContext
.- Returns:
- A GuiContext object or null if it is not applicable to the extension point
- Since:
- 2.12
-
getCurrentContext
Get the current item context. -
getRoot
Get the URL to the web application root as a string. The URL only includes the path information, not the server name or protocol. -
getHome
Get the URL to the home directory for a given extension. The URL only includes the path information, not the server name or protocol.- Parameters:
extension
- The extension
-
addScript
Add an absolute reference to a script that should be included on the generated page with a<script>
tag. The path must be an absolute path.Note 1! This method must be called from the
ActionFactory.prepareContext(InvokationContext)
orRendererFactory.prepareContext(InvokationContext)
methods. Changes to the context after that will not be reflected in the output.Note 2! Not all extension points supports custom scripts. Check the documentation for the extension point you are extending.
- Parameters:
absolutePath
- The absolute path
-
addScripts
Add several scripts in one go. If the collection is null or empty nothing is done.- Since:
- 3.19.4
-
getSet
Get the Set that is stored under the given key. If no Set exists it is created and stored in the map. -
addStylesheet
Add an absolute reference to a CSS stylesheet that should be included on the generated page with a<link>
tag. The path must be the absolute path.Note 1! This method must be called from the
ActionFactory.prepareContext(InvokationContext)
orRendererFactory.prepareContext(InvokationContext)
methods. Changes to the context after that will not be reflected in the output.Note 2! Not all extension points supports custom stylesheets. Check the documentation for the extension point you are extending.
- Parameters:
absolutePath
- The absolute path
-
addStylesheets
Add several stylesheets in one go. If the collection is null or empty nothing is done.- Since:
- 3.19.4
-
getScripts
Get all scripts that has been added to this context.- Returns:
- A collection of scripts
-
getScripts
Get all scripts that has been added to this context by the given extension- Returns:
- A collection of scripts
- Since:
- 3.19.3
-
getStylesheets
Get all stylesheets that has been added to this context.- Returns:
- A collection of stylesheets
-
getStylesheets
Get all stylesheets that has been added to this context by the given extension.- Returns:
- A collection of stylesheets
- Since:
- 3.19.3
-