|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.extensions.ClientContext net.sf.basedb.clients.web.extensions.JspContext
public class JspContext
Context object for the web application. Instances of this class
are always used for passing client context information to web extensions.
This means that it is always safe to cast the client context to this
class in the 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.
Field Summary | |
---|---|
static String |
ATTRIBUTE_KEY
The key that is used when storing a JspContext object in a request/page/session/etc. attribute. |
private ExtensionsDirectory |
directory
|
private GuiContext |
guiContext
|
private PageContext |
pageContext
|
private Set<String> |
scripts
|
private Set<String> |
stylesheets
|
Constructor Summary | |
---|---|
JspContext(ExtensionsDirectory directory,
SessionControl sc,
DbControl dc,
PageContext pageContext,
GuiContext guiContext,
Object item)
|
Method Summary | |
---|---|
void |
addScript(String absolutePath)
Add an absolute reference to a script that should be included on the generated page with a <script> tag. |
void |
addStylesheet(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 . |
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. |
String |
getRoot()
Get the URL to the web application root as a string. |
Collection<String> |
getScripts()
Get all scripts that has been added to this context. |
Collection<String> |
getStylesheets()
Get all stylesheets that has been added to this context. |
Methods inherited from class net.sf.basedb.util.extensions.ClientContext |
---|
getAttribute, getCurrentItem, getDbControl, getSessionControl, setAttribute, setCurrentItem |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ATTRIBUTE_KEY
private final ExtensionsDirectory directory
private final PageContext pageContext
private final GuiContext guiContext
private Set<String> scripts
private Set<String> stylesheets
Constructor Detail |
---|
JspContext(ExtensionsDirectory directory, SessionControl sc, DbControl dc, PageContext pageContext, GuiContext guiContext, Object item)
Method Detail |
---|
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 String getRoot()
public String getHome(Extension extension)
extension
- The extensionpublic void addScript(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(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 Collection<String> getScripts()
public Collection<String> getStylesheets()
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |