public class JspContext extends ClientContext
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ATTRIBUTE_KEY
The key that is used when storing a JspContext object in
a request/page/session/etc. attribute.
|
static java.lang.String |
EXTENSION_KEY
The key that is used when storing an Extension object in
a request/page/session/etc. attribute.
|
private GuiContext |
guiContext |
private PageContext |
pageContext |
private java.util.Set<java.lang.String> |
scripts |
private java.util.Set<java.lang.String> |
stylesheets |
Constructor and Description |
---|
JspContext(SessionControl sc,
DbControl dc,
PageContext pageContext,
GuiContext guiContext,
java.lang.Object item) |
Modifier and Type | Method and Description |
---|---|
void |
addScript(java.lang.String absolutePath)
Add an absolute reference to a script that should be included on the
generated page with a
<script> tag. |
void |
addStylesheet(java.lang.String absolutePath)
Add an absolute reference to a CSS stylesheet that should be included on the
generated page with a
<link> tag. |
GuiContext |
getGuiContext()
Get the current
GuiContext . |
java.lang.String |
getHome(Extension extension)
Get the URL to the home directory for a given extension.
|
JspWriter |
getOut()
Get a writer object that can be used to return generated text
to the response that is sent back to the browser.
|
PageContext |
getPageContext()
Get the JSP Page context object for the current request.
|
java.lang.String |
getRoot()
Get the URL to the web application root as a string.
|
java.util.Collection<java.lang.String> |
getScripts()
Get all scripts that has been added to this context.
|
java.util.Collection<java.lang.String> |
getStylesheets()
Get all stylesheets that has been added to this context.
|
getAttribute, getCurrentItem, getDbControl, getSessionControl, setAttribute, setCurrentItem
public static final java.lang.String ATTRIBUTE_KEY
public static final java.lang.String EXTENSION_KEY
private final PageContext pageContext
private final GuiContext guiContext
private java.util.Set<java.lang.String> scripts
private java.util.Set<java.lang.String> stylesheets
JspContext(SessionControl sc, DbControl dc, PageContext pageContext, GuiContext guiContext, java.lang.Object item)
public PageContext getPageContext()
public JspWriter getOut()
Note! The writer is only intended to be used by render
objects when rendering the extensions. Using the writer
from the ActionFactory.prepareContext(InvokationContext)
or
RendererFactory.prepareContext(InvokationContext)
method may produce unpredictable results.
JspWriter
objectpublic GuiContext getGuiContext()
GuiContext
.public java.lang.String getRoot()
public java.lang.String getHome(Extension extension)
extension
- The extensionpublic void addScript(java.lang.String absolutePath)
<script>
tag. The
path must be an absolute path.
Note 1! This method must be called from the ActionFactory.prepareContext(InvokationContext)
or
RendererFactory.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.
absolutePath
- The absolute pathpublic void addStylesheet(java.lang.String absolutePath)
<link>
tag. The
path must be the absolute path.
Note 1! This method must be called from the ActionFactory.prepareContext(InvokationContext)
or
RendererFactory.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.
absolutePath
- The absolute pathpublic java.util.Collection<java.lang.String> getScripts()
public java.util.Collection<java.lang.String> getStylesheets()