|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.jsp.CmsJspBean
public class CmsJspBean
Superclass for OpenCms JSP beans that provides convient access to OpenCms core and VFS functionality.
If you have large chunks of code on your JSP that you want to move to a Class file, consider creating a subclass of this bean. Initialize this bean at the beginning of your JSP like this:
<jsp:useBean id="cmsbean" class="org.opencms.jsp.CmsJspBean"> <% cmsbean.init(pageContext, request, response); %> </jsp:useBean>
Constructor Summary | |
---|---|
CmsJspBean()
Empty constructor, required for every JavaBean. |
Method Summary | |
---|---|
CmsObject |
getCmsObject()
Returns the CmsObject from the wrapped request. |
protected CmsFlexController |
getController()
Returns the Flex controller derived from the request this bean was initialized with. |
javax.servlet.jsp.PageContext |
getJspContext()
Returns the JSP page context this bean was initialized with. |
protected java.lang.String |
getMessage(CmsMessageContainer container)
Internally localizes the given CmsMessageContainer to a String. |
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the request this bean was initialized with. |
CmsRequestContext |
getRequestContext()
Returns the current users OpenCms request context. |
javax.servlet.http.HttpServletResponse |
getResponse()
Returns the response wrapped by this element. |
protected void |
handleException(java.lang.Throwable t)
Handles any exception that might occur in the context of this element to ensure that templates are not disturbed. |
void |
init(javax.servlet.jsp.PageContext context,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Initialize this bean with the current page context, request and response. |
protected boolean |
isNotInitialized()
Returns true if this bean has not been initialized (i.e. init() has not been called so far), false otherwise. |
boolean |
isSupressingExceptions()
Returns true if Exceptions are handled by the class instance and suppressed on the
output page, or false if they will be thrown and have to be handled by the calling class. |
void |
setContentType(java.lang.String type)
Sets the content type for the HTTP response. |
void |
setStatus(int status)
Sets the status code for the HTTP response. |
void |
setSupressingExceptions(boolean value)
Controls if Exceptions that occur in methods of this class are suppressed (true) or not (false). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CmsJspBean()
Method Detail |
---|
public CmsObject getCmsObject()
This is a convenience method in case you need access to the CmsObject in your JSP scriplets.
public javax.servlet.jsp.PageContext getJspContext()
public javax.servlet.http.HttpServletRequest getRequest()
public CmsRequestContext getRequestContext()
public javax.servlet.http.HttpServletResponse getResponse()
public void init(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
It is required to call one of the init() methods before you can use the instance of this bean.
context
- the JSP page context objectreq
- the JSP requestres
- the JSP responsepublic boolean isSupressingExceptions()
true
if Exceptions are handled by the class instance and suppressed on the
output page, or false
if they will be thrown and have to be handled by the calling class.
The default is true
.
If set to false
Exceptions that occur internally will be wrapped into
a RuntimeException and thrown to the calling class instance.
true
if Exceptions are suppressed, or
false
if they will be thrown and have to be handled by the calling classpublic void setContentType(java.lang.String type)
This method is required since JSP's are handled in a special way for included template elements,
so ServletResponse.setContentType(java.lang.String)
won't work.
Please note that the content type set this way is never cached in the Flex cache, so you must make sure to not cache the element when you use this method.
type
- the type to setServletResponse.setContentType(java.lang.String)
public void setStatus(int status)
This method is required since JSP's are handled in a special way for included template elements,
so HttpServletResponseWrapper.setStatus(int)
won't work.
Please note that the status code set this way is never cached in the Flex cache, so you must make sure to not cache the element when you use this method.
status
- the status code to setHttpServletResponseWrapper.setStatus(int)
public void setSupressingExceptions(boolean value)
The default is true
. If set to false
all Exceptions that
occur internally will be wrapped into a RuntimeException and thrown to the calling
class instance.
value
- the value to set the Exception handing toprotected CmsFlexController getController()
This is protected since the CmsFlexController this is really an internal OpenCms helper function, not part of the public OpenCms API. It must not be used on JSP pages, only from subclasses of this bean.
protected java.lang.String getMessage(CmsMessageContainer container)
CmsMessageContainer
to a String. If the user request context is at hand, the user's locale will be chosen. If no user request context is available, the default locale is used.
container
- the message container that allows localization of the represented message.
protected void handleException(java.lang.Throwable t)
t
- the Throwable that was caughtprotected boolean isNotInitialized()
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |