|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.context.JcmsContext com.jalios.jcms.context.JcmsJspContext
public class JcmsJspContext
This class allows you to keep track of variables declare and initialiazed by JCMS.
You can either :
1. Use the one declared in request attributes with :
JcmsJspContext jspCtx = request.getAttribute("jcmsContext")
2. Instanciante a new one with :
JcmsJspContext jspCtx = new JcmsJspContext(pageContext)
3. create your own bean/handler classes by extending this class.
In your class:
package custom; public class HelloUser extends com.jalios.jcms.JcmsPageContext { private static final Logger logger = Logger.getLogger(HelloUser.class); public doHelloUser() throws java.io.IOException { logger.debug("doHelloUser()"); if (isLogged) { out.println(glp("myhello.welcome-msg", loggedMember.getFriendlyName())); } else { out.println(glp("myhello.welcome-guest-msg")); } } }
<%@ include file="/doInitPage.jsp" %> <jsp:useBean id="welcomeUserBean" scope="page" class="custom.WelcomeUser"> <jsp:setProperty name="welcomeUserBean" property="pageContext" value="<%= pageContext %>"/> </jsp:useBean> <% welcomeUserBean.doHelloUser(); %>
Field Summary | |
---|---|
static String |
AJAX_REQUEST_ATTRIBUTES
|
static String |
BODY_HEADER
|
static String |
CSS_HEADER
|
static LinkedHashMap<String,String> |
cssboMap
|
static LinkedHashMap<String,String> |
cssfoMap
|
static String |
CUSTOM_HEADER
|
protected boolean |
editIcon
|
static String |
HTTPEQUIV_HEADER
|
static LinkedHashMap<String,String> |
httpequivMap
|
static String |
HTTPNAME_HEADER
|
static LinkedHashMap<String,String> |
httpnameMap
|
protected boolean |
initEditIcon
|
static String |
JAVASCRIPT_CODE_SET_ATTRIBUTE
Request attribute name for the Set of JavaScript code used in current page. |
static String |
JAVASCRIPT_SET_ATTRIBUTE
Request attribute name for the Set of JavaScript path used in current page. |
static LinkedHashSet<String> |
jsboSet
|
static LinkedHashSet<String> |
jsfoSet
|
protected javax.servlet.jsp.JspWriter |
out
|
protected javax.servlet.jsp.PageContext |
pageContext
|
static String |
REVISION
|
protected static String |
SHOW_EDIT_ICON
|
static String |
STYLE_HEADER
|
Fields inherited from class com.jalios.jcms.context.JcmsContext |
---|
browser, caddy, channel, inFO, initDone, initWorkspace, isAdmin, isAjaxRequest, isDBMember, isDebug, isLogged, loggedMember, request, response, userCountry, userLang, userLocale, workspace |
Fields inherited from interface com.jalios.util.JaliosConstants |
---|
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR |
Constructor Summary | |
---|---|
JcmsJspContext()
If you use this constructor, pageContext or request must be initialized at a later time |
|
JcmsJspContext(javax.servlet.jsp.PageContext pageContext)
|
Method Summary | |
---|---|
void |
addBodyAttributes(String name,
String value)
Adds body attributes. |
void |
addCSSHeader(Map<String,String> paths)
Adds css headers. |
void |
addCSSHeader(String path)
Adds a css header. |
void |
addCSSHeader(String[] paths)
Adds css headers. |
void |
addCSSHeader(String path,
String media)
Adds a css header. |
void |
addCustomHeader(String content)
Adds inline content header. |
void |
addHttpEquivHeader(String httpequiv,
String content)
Adds http-equiv header. |
void |
addHttpNameHeader(String name,
String content)
Adds http-name header. |
void |
addJavaScript(Collection<String> pathsColl)
Adds several javascript files to the current page. |
void |
addJavaScript(String path)
Adds a javascript file to the current page. |
void |
addJavaScript(String[] paths)
Adds several javascript files to the current page. |
void |
addJavaScriptCode(String code)
Adds some javascript CODE to be executed on page load (or an after an ajax update). |
void |
addStyleHeader(String cssquery)
Adds inline style header. |
void |
addStyleHeader(String cssquery,
String media)
Adds inline style header. |
boolean |
checkAccess(String resource)
Check if the current member is authorized to access the specified resource. |
boolean |
checkAccess(String resource,
Map<String,Object> ctxt)
Check if the current member is authorized to access the specified resource. |
boolean |
checkCSRF()
Check that the current request validates CSRF prevention requirements. |
void |
debugDisplayContext()
|
void |
disablePacker()
Force disable CSS & JS packer for all CSS & JS of the current request only. |
void |
forceEditIcon(boolean editIcon)
Force the editIcon stat to the given value for the current request. |
void |
forceUpdate()
Will force an update of all JcmsContext variables (retrieve it from the request) Update the protected variable initDone (to false at begining of method, and true on end). |
Object |
getAjaxRequestAttribute(String key)
Returns the attribute value associated to given key if the attribute has been stored for the ajax scope |
String |
getAjaxRequestId()
Retrieve the Ajax Request Id for the current request |
Map |
getAllHeadersDiffMap(Map oldMap)
Returns a Map of "Header Name" / "Header Map" that contains added items since given map |
Map |
getAllHeadersMap()
Returns a Map of "Header Name" / "Header Map" that contains all current headers. |
static Map<String,String> |
getBackOfficeCSSHeader()
Returns BackOffice CSS header. |
static Set<String> |
getBackOfficeJavaScriptSet()
Returns BackOffice JavaScript files. |
Map<String,String> |
getBodyAttributes()
Returns a map of body attributes |
Publication |
getContentForm()
|
Map<String,String> |
getCSSHeaders()
Returns a map of CSS headers. |
Category[] |
getCtxCategories()
|
Category |
getCurrentCategory()
|
Collection |
getCustomHeaders()
Returns a Map of Custom headers. |
String |
getDocType(String defaultValue)
This method return the doc type set in request attribute "docType" Otherwise use the default value. |
LinkedHashMap<String,String> |
getFinalCSSMap()
Retrieve the final (ultimate) map of CSS files (and media to be used in the page. |
LinkedHashSet<String> |
getFinalJavaScriptSet()
Retrieve the final (ultimate) set of JavaScript file to be used in the page. |
int |
getFormElementCount()
|
static Map<String,String> |
getFrontOfficeCSSHeader()
Returns FronOffice CSS header. |
static Set<String> |
getFrontOfficeJavaScriptSet()
Returns FronOffice JavaScript files. |
Map<String,String> |
getHttpEquivHeaders()
Returns a map of Meta httpequiv headers. |
Map<String,String> |
getHttpNameHeaders()
Returns a map of Meta name headers. |
LinkedHashSet<String> |
getJavaScriptCodeSet()
Retrieves the javascript CODE that have been setup to be called on current page load. |
LinkedHashSet<String> |
getJavaScriptSet()
Retrieves the javascript files that have been setup for current page. |
org.jabsorb.JSONRPCBridge |
getJSONBridge()
Returns the JSON-RPC Bridge declared by the InitFilter |
static String |
getPackVersion()
Retrieve JS and CSS pack version used in packer URL for improved caching management. |
javax.servlet.jsp.PageContext |
getPageContext()
|
String |
getPageTitle(String defaultValue)
This method return the title of the page |
String |
getPageZone(String defaultValue)
This method return the zone of the page. |
PortalInterface |
getPortal()
|
Category |
getPortalCategory()
|
PortalElement |
getPortlet()
|
Publication |
getPublication()
|
Map<String,String> |
getStyleHeaders()
Returns a Map of Style headers. |
String |
getTemplateUsage()
|
void |
internalSetupEmptyHeader()
Convenient method to setup all headers and delegate to policy filters This method must be called before printing headers |
boolean |
isEditIcon()
Deprecated. Use new method isEditIcon with workspace and data as parameters |
boolean |
isEditIcon(Workspace ws,
Publication pub)
|
boolean |
isPrintView()
|
void |
registerDisplayContext(DisplayContext ctxt)
Register the given DisplayContext into the JcmsContext |
Object |
removeAjaxRequestAttribute(String key)
Remove a request attribute persistent in the AJAX request Scope. |
void |
setAjaxRequestAttribute(String key,
Object value)
Set a request attribute persistent in the AJAX request Scope |
void |
setAjaxRequestId(String ajaxReqId)
Set the Ajax Request Id for the current JcmsContext |
void |
setAllHeadersDiffMap(Map oldMap)
Adds header diff map to current context |
void |
setDocType(String docType)
This method set the doctype of the page. |
void |
setEditIcon(boolean editIcon,
boolean request,
boolean session)
Force the editIcon stat to the given value for the current request or session. |
void |
setFormElementCount(int count)
|
void |
setPageContext(javax.servlet.jsp.PageContext pageContext)
Page context setter, will initialize the following members : - page context - out - request - response then force an update of all variables |
void |
setPageTitle(String title)
This method set custom page title to append to header tag. |
void |
setPageZone(String zone)
This method set page zone then store it in the request attribute "zone" The zone is used to define groups of pages. |
void |
setShowEditIcon(boolean show)
Set the editIcon state to define if the EditArea must be hidden |
void |
setTemplateUsage(String usage)
Set the current template usage. |
boolean |
showEditIcon()
Returns editIcon state. |
boolean |
showEditIcon(Workspace ws,
Data pub)
|
String |
workaroundBrowserBaseHrefBug(String path)
If needed, apply workaround for specified path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
protected javax.servlet.jsp.PageContext pageContext
protected javax.servlet.jsp.JspWriter out
protected boolean initEditIcon
protected boolean editIcon
protected static final String SHOW_EDIT_ICON
public static final String AJAX_REQUEST_ATTRIBUTES
public static final String JAVASCRIPT_SET_ATTRIBUTE
Set
of JavaScript path used in current page.
addJavaScript(String)
,
addJavaScript(String[])
,
getJavaScriptSet()
,
Constant Field Valuespublic static final String JAVASCRIPT_CODE_SET_ATTRIBUTE
Set
of JavaScript code used in current page.
addJavaScriptCode(String)
,
getJavaScriptCodeSet()
,
Constant Field Valuespublic static final String CSS_HEADER
public static final String STYLE_HEADER
public static final String CUSTOM_HEADER
public static final String BODY_HEADER
public static final String HTTPEQUIV_HEADER
public static final String HTTPNAME_HEADER
public static final LinkedHashMap<String,String> httpequivMap
public static final LinkedHashMap<String,String> httpnameMap
public static final LinkedHashMap<String,String> cssfoMap
public static final LinkedHashMap<String,String> cssboMap
public static final LinkedHashSet<String> jsfoSet
public static final LinkedHashSet<String> jsboSet
Constructor Detail |
---|
public JcmsJspContext()
public JcmsJspContext(javax.servlet.jsp.PageContext pageContext)
Method Detail |
---|
public void forceUpdate()
forceUpdate
in class JcmsContext
public void setPageContext(javax.servlet.jsp.PageContext pageContext)
pageContext
- the jsp PageContext to be used for initialization of this JcmsJspContextpublic javax.servlet.jsp.PageContext getPageContext()
public Publication getPublication()
public Publication getContentForm()
public PortalElement getPortlet()
public PortalInterface getPortal()
public Category getCurrentCategory()
public Category getPortalCategory()
public Category[] getCtxCategories()
public String getTemplateUsage()
public boolean isPrintView()
public void setTemplateUsage(String usage)
usage
- the current template usagepublic void registerDisplayContext(DisplayContext ctxt)
ctxt
- the DisplayContextpublic void debugDisplayContext()
public boolean isEditIcon()
public boolean isEditIcon(Workspace ws, Publication pub)
ws
- the Workspace
used to check rightspub
- the Publication
to edit used to check rights
Returns true if edit area must be displayed.
public boolean showEditIcon(Workspace ws, Data pub)
ws
- the Workspace
used to check rightspub
- the Data
to edit used to check rights
Returns true if edit area must be displayed.
public boolean showEditIcon()
public void setShowEditIcon(boolean show)
show
- boolean true to display EditAreapublic void setEditIcon(boolean editIcon, boolean request, boolean session)
editIcon
- the new edit Icon staterequest
- store in requestsession
- store in sessionpublic void forceEditIcon(boolean editIcon)
editIcon
- the new edit Icon statepublic void setAjaxRequestId(String ajaxReqId)
ajaxReqId
- the Ajax Request Idpublic String getAjaxRequestId()
public void setAjaxRequestAttribute(String key, Object value)
key
- the keyvalue
- the valuepublic Object getAjaxRequestAttribute(String key)
key
- the key
public Object removeAjaxRequestAttribute(String key)
key
- the key
public org.jabsorb.JSONRPCBridge getJSONBridge()
public int getFormElementCount()
public void setFormElementCount(int count)
public void setPageTitle(String title)
title
- the custom title headerpublic String getPageTitle(String defaultValue)
defaultValue
- the default value to return
public void setPageZone(String zone)
zone
- the custom zonepublic String getPageZone(String defaultValue)
defaultValue
- the default zone
public void setDocType(String docType)
docType
- the doc typepublic String getDocType(String defaultValue)
defaultValue
- the default value if there is no doctype
public void addHttpEquivHeader(String httpequiv, String content)
httpequiv
- the header keycontent
- the header valuepublic Map<String,String> getHttpEquivHeaders()
public void addHttpNameHeader(String name, String content)
name
- the header keycontent
- the header valuepublic Map<String,String> getHttpNameHeaders()
public void addBodyAttributes(String name, String value)
name
- the attribute namevalue
- the attribute valuepublic Map<String,String> getBodyAttributes()
public void addCustomHeader(String content)
content
- the inline content to addpublic Collection getCustomHeaders()
public void addStyleHeader(String cssquery)
cssquery
- the inline style to addpublic void addStyleHeader(String cssquery, String media)
cssquery
- the inline style to addmedia
- the css mediapublic Map<String,String> getStyleHeaders()
public void addCSSHeader(String path)
path
- the CSS pathpublic void addCSSHeader(String path, String media)
path
- the CSS pathmedia
- the Media pathpublic void addCSSHeader(String[] paths)
paths
- the CSS pathpublic void addCSSHeader(Map<String,String> paths)
paths
- the CSS pathpublic Map<String,String> getCSSHeaders()
public static Map<String,String> getFrontOfficeCSSHeader()
public static Map<String,String> getBackOfficeCSSHeader()
public static Set<String> getFrontOfficeJavaScriptSet()
public static Set<String> getBackOfficeJavaScriptSet()
public void internalSetupEmptyHeader()
public LinkedHashMap<String,String> getFinalCSSMap()
If csspacker is enabled (property "channel.css-packer.enabled"
), the existing css map is
converted into a new map of packed resources.
public void disablePacker()
This method must be invoked prior to inclusion of doEmptyHeader.jsp (for CSS) and doEmptyFooter (for JS).
public Map getAllHeadersMap()
public Map getAllHeadersDiffMap(Map oldMap)
oldMap
- the map to diff with
public void setAllHeadersDiffMap(Map oldMap)
oldMap
- the Map to work withpublic void addJavaScript(String path)
path
- a relative JavaScript path (e.g "plugins/MyPlugin/js/plugin.js"
)public void addJavaScript(String[] paths)
paths
- an array of relative JavaScript path (e.g { "plugins/MyPlugin/js/myscript1.js", "plugins/MyPlugin/js/myscript2.js" }
)public void addJavaScript(Collection<String> pathsColl)
pathsColl
- a collection of relative JavaScript path (e.g { "plugins/MyPlugin/js/myscript1.js", "plugins/MyPlugin/js/myscript2.js" }
)public LinkedHashSet<String> getJavaScriptSet()
The returned set will only contains file that have been added prior to invocation of this method. Some files may be added after.
public LinkedHashSet<String> getFinalJavaScriptSet()
If jspacker is enabled, the existing javascript set is converted into a new set of packed resources (unless resource contain a 'nopack' querystring argument).
public static String getPackVersion()
public String workaroundBrowserBaseHrefBug(String path)
path
- the path to convert to absolute URL, if needed
public void addJavaScriptCode(String code)
jcmsContext.addJavaScriptCodeOnLoad("someMethod(); alert('Page has been loaded by browser'); ");
code
- some javascript codepublic LinkedHashSet<String> getJavaScriptCodeSet()
The returned set will only contains code that have been added prior to invocation of this method. Some code may be added after.
public boolean checkAccess(String resource)
boolean isAuthorized = checkAccess(loggedMember, "admin/dev/store-cleaner");
resource
- a resource URI using a path representation, eg "admin/dev/store-cleaner"
public boolean checkAccess(String resource, Map<String,Object> ctxt)
boolean isAuthorized = checkAccess(loggedMember, "admin-ws/types/content", ctxtMap);
resource
- a resource URI using a path representation, eg "admin/dev/store-cleaner"ctxt
- an optionnal context map
public boolean checkCSRF()
This method does not check that CSRF is enabled, see HttpUtil.isCSRFEnabled()
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |