|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.context.AbstractJcmsAjaxContext
public abstract class AbstractJcmsAjaxContext
Convenient abstract class to easily develops AJAX handlers in JCMS.
This class tracks variables and various request information available
during the initial request of user (as opposed to other AJAX request in which the
information is either not available or not the same).
To develop your AJAX handler :
1. Create your own AJAX java class by extending this class.
package custom; public class MyAjaxClass extends com.jalios.jcms.AbstractJcmsAjaxContext { public String saySomething(String str) { if (isLogged) { return str + " " + loggedMember.getFriendlyName() + "!"; } return str + "!"; } }2. Instanciate your class using the jcmsContext variable available in the any jsp and register this new instance using JSON.
json_bridge.registerObject("MyAjaxClass", new MyAjaxClass(jcmsContext));3. Call your methods from javascript using JSON.
<script type="text/javascript"> function saySomething(str) { var msg; try { msg = JcmsJsContext.getJsonRPC().MyAjaxClass.saySomething(str); } catch(ex) { alert(I18N.glp('warn.json.sessiontimeout')); return; } alert(msg); } </script> <a href="#" onclick="saySomething('Hello'); return false;">Say Hello</a>
Field Summary | |
---|---|
protected String |
baseUrl
|
protected Caddy |
caddy
|
protected Channel |
channel
|
protected String |
contextPath
|
protected Category[] |
ctxCategories
|
protected Category |
currentCategory
|
protected boolean |
debug
|
protected boolean |
isAdmin
|
protected boolean |
isIE
|
protected boolean |
isInFrontOffice
|
protected boolean |
isLogged
|
protected boolean |
isWindows
|
protected Member |
loggedMember
|
protected String |
method
|
protected Map<String,String[]> |
parameterMap
|
protected PortalInterface |
portal
|
protected Category |
portalCategory
|
protected Publication |
pub
|
protected String |
resourcePath
|
protected String |
url
|
protected String |
userLang
|
protected Locale |
userLocale
|
protected Workspace |
workspace
|
protected String |
zone
|
Constructor Summary | |
---|---|
protected |
AbstractJcmsAjaxContext()
Use this constructor when you need to override some values available in JcmsJspContext by calling setters of this object but still want to benefit from other values already available in the JcmsContext. But Make sure you call the setter setJcmsContext(JcmsJspContext)
after. |
protected |
AbstractJcmsAjaxContext(JcmsJspContext ctxt)
Build a new JcmsAjaxContext based on information available in the JcmsJspContext. |
Method Summary | |
---|---|
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 |
debug(String key)
|
String |
deflate()
|
String |
getBaseUrl()
Retrieve the base URL of the initial request or any base URL that might have specified using setBaseUrl(String) . |
Caddy |
getCaddy()
Returns the caddy stored in current session. |
String |
getContextPath()
Retrieve the context path of the initial request or any context path that might have specified using setContextPath(String) . |
Category[] |
getCtxCategories()
Retrieve the contextual categories to used for refinement |
Category |
getCurrentCategory()
Retrieve the current category, either the category available at the time of the initial request or the one overrided by setCurrentCategory(Category) |
Member |
getLoggedMember()
Retrieve the logged Member at the time of the initial request. |
String |
getMethod()
Retrieve the method of the initial request or any base URL that might have specified using setMethod(String) . |
Map<String,String[]> |
getParameterMap()
Retrieve the map of paramaters available for the original request or map path that might have specified using setParameterMap(Map) . |
PortalInterface |
getPortal()
Returns the stored portal interface for the given request |
Category |
getPortalCategory()
Retrieve the portal category, either the category available at the time of the initial request or the one overrided by setPortalCategory(Category) |
Publication |
getPublication()
Returns the stored Publication for the given request |
String |
getResourcePath()
Retrieve the original request resource path or any resource path that might have specified using setResourcePath(String) . |
String |
getUrl()
Retrieve the URL of the initial request or any URL that might have specified using setUrl(String) . |
String |
getUserLang()
Retrieve the language to use for localized message and localized features. |
Locale |
getUserLocale()
Retrieve the Locale to use for localized message and localized features. |
Workspace |
getWorkspace()
Retrieve the workspace, either the workspace available at the time of the initial request or the one overrided by setWorkspace(Workspace) |
String |
getZone()
Return the zone status |
String |
glp(String key,
Object... params)
Resolve a language property in the current user language. |
void |
inflate(String data,
javax.servlet.http.HttpServletRequest request)
|
boolean |
isAdmin()
Return the admin status of the logged user. |
boolean |
isInFrontOffice()
Return the isInFrontOffice status |
boolean |
isLogged()
Return the user logging status for the initial request. |
protected void |
readObject(Map<String,Object> map,
javax.servlet.http.HttpServletRequest request)
|
void |
setBaseUrl(String baseUrl)
Sets the base URL. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setContextPath(String contextPath)
Sets the context path. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setCtxCategories(Category[] ctxCategories)
Sets the contextual categories used for refinement. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setCurrentCategory(Category currentCategory)
Set the current category. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setJcmsContext(JcmsJspContext jcmsContext)
Sets the following values from values found in the specified JcmsJspContext. Values are not retrieved from context if they have already been set through their setter. |
void |
setLoggedMember(Member loggedMember)
Sets the logged member. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setMethod(String method)
Sets the method. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setParameterMap(Map<String,String[]> parameterMap)
Sets the request parameter Map. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setPortal(PortalInterface portal)
Set the portal interface for the given request |
void |
setPortalCategory(Category portalCategory)
Set the portal category. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setPublication(Publication pub)
Set the Publication for the given request |
void |
setResourcePath(String resourcePath)
Sets the resource path. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setUrl(String url)
Sets the URL. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setUserLang(String userLang)
Sets the user lang. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setUserLocale(Locale userLocale)
Sets the user Locale. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
void |
setWorkspace(Workspace workspace)
Sets the workspace. If this method is called before setJcmsContext(JcmsJspContext) , its
value won't be overiden by values retrieved from the JcmsJspContext. |
protected void |
writeObject(Map<String,Object> map)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient Channel channel
protected transient boolean debug
protected transient Member loggedMember
protected transient String userLang
protected transient Locale userLocale
protected transient boolean isLogged
protected transient boolean isAdmin
protected transient Workspace workspace
protected transient Category currentCategory
protected transient Category portalCategory
protected transient Category[] ctxCategories
protected transient String zone
protected transient boolean isInFrontOffice
protected transient Caddy caddy
protected transient PortalInterface portal
protected transient Publication pub
protected transient String url
protected transient String baseUrl
protected transient String contextPath
protected transient String resourcePath
protected transient Map<String,String[]> parameterMap
protected transient String method
protected transient boolean isWindows
protected transient boolean isIE
Constructor Detail |
---|
protected AbstractJcmsAjaxContext()
setJcmsContext(JcmsJspContext)
after.
protected AbstractJcmsAjaxContext(JcmsJspContext ctxt)
ctxt
- the JcmsJspContext available in the first "standard" request
prior to calling AJAX methods.Method Detail |
---|
public final void setLoggedMember(Member loggedMember)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
loggedMember
- the Logged MembersetJcmsContext(JcmsJspContext)
public final Member getLoggedMember()
public final void setUserLang(String userLang)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
userLang
- the user langsetJcmsContext(JcmsJspContext)
public final String getUserLang()
public final void setUserLocale(Locale userLocale)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
userLocale
- the user LocalesetJcmsContext(JcmsJspContext)
public final Locale getUserLocale()
public boolean isLogged()
public boolean isAdmin()
public boolean isInFrontOffice()
public String getZone()
public final void setWorkspace(Workspace workspace)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
workspace
- the workspacesetJcmsContext(JcmsJspContext)
public final Workspace getWorkspace()
setWorkspace(Workspace)
public void setCurrentCategory(Category currentCategory)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
currentCategory
- Categorypublic Category getCurrentCategory()
setCurrentCategory(Category)
public void setPortalCategory(Category portalCategory)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
portalCategory
- Categorypublic Category getPortalCategory()
setPortalCategory(Category)
public final void setCtxCategories(Category[] ctxCategories)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
ctxCategories
- Category[] of contextual categoriessetJcmsContext(JcmsJspContext)
public final Category[] getCtxCategories()
public Caddy getCaddy()
public PortalInterface getPortal()
public void setPortal(PortalInterface portal)
portal
- public Publication getPublication()
public void setPublication(Publication pub)
pub
- public final void setUrl(String url)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
url
- the full URL of the page accessed initiallysetJcmsContext(JcmsJspContext)
public final String getUrl()
setUrl(String)
.
public final void setBaseUrl(String baseUrl)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
baseUrl
- the base URL of the page accessed initiallysetJcmsContext(JcmsJspContext)
public final String getBaseUrl()
setBaseUrl(String)
.
public final void setMethod(String method)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
method
- the method of the page accessed initiallysetJcmsContext(JcmsJspContext)
public final String getMethod()
setMethod(String)
.
public final void setContextPath(String contextPath)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
contextPath
- the base URL of the page accessed initiallysetJcmsContext(JcmsJspContext)
public final String getContextPath()
setContextPath(String)
.
public final void setResourcePath(String resourcePath)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
resourcePath
- the resource pathsetJcmsContext(JcmsJspContext)
public final String getResourcePath()
setResourcePath(String)
.
ServletUtil.getResourcePath(HttpServletRequest)
public final void setParameterMap(Map<String,String[]> parameterMap)
setJcmsContext(JcmsJspContext)
, its
value won't be overiden by values retrieved from the JcmsJspContext.
parameterMap
- a Map containing parameter names as keys and parameter values as map values.
This map will be cloned to make sure any modification does not impact your original map and vice versa.setJcmsContext(JcmsJspContext)
public final Map<String,String[]> getParameterMap()
setParameterMap(Map)
.
public void setJcmsContext(JcmsJspContext jcmsContext)
jcmsContext
- the JcmsJspContextpublic String deflate()
public void inflate(String data, javax.servlet.http.HttpServletRequest request)
protected void writeObject(Map<String,Object> map)
protected void readObject(Map<String,Object> map, javax.servlet.http.HttpServletRequest request)
public String glp(String key, Object... params)
key
- the language property to resolve, for example "ui.com.lbl.contents"params
- the parameters to use when resolving the format of the given property
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 debug(String key)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |