Package com.jalios.jcms.ajax
Class CtxMenuUtil
- java.lang.Object
-
- com.jalios.jcms.ajax.CtxMenuUtil
-
- All Implemented Interfaces:
CtxMenuConstants
public class CtxMenuUtil extends java.lang.Object implements CtxMenuConstants
Utility class providing convenient methods for producing contextual menus.- Since:
- jcms-6.1.0
- Author:
- dissert
-
-
Field Summary
-
Fields inherited from interface com.jalios.jcms.ajax.CtxMenuConstants
DISABLED, FLAG_CADDY, FLAG_DELETE, FLAG_EDIT, FLAG_EXPORT, FLAG_INSPECT, FLAG_SEPARATOR, INFO_ICON, MENU_DISABLED, MENU_ENABLED, MENU_SKIPPED, NO_ICON
-
-
Constructor Summary
Constructors Constructor Description CtxMenuUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addIcon(java.lang.StringBuffer sb, java.lang.String icon)
Print to StringBuffer Image tag that can be an icon or a spritestatic void
addInfo(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String value)
Adds an info in an info sectionstatic void
addInfo(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String value, java.lang.String url, java.lang.String titleConfirm, java.lang.String icon, boolean isDisabled)
Adds an info with a icon and a text.static void
addInfoImage(java.lang.StringBuffer sb, java.lang.String path)
Adds an info in an info sectionstatic void
addInfoText(java.lang.StringBuffer sb, java.lang.String text)
Adds an info in an info sectionstatic void
addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url)
Adds a menu itemstatic void
addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect)
Adds a menu itemstatic void
addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css)
Adds a menu itemstatic void
addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css, java.util.Map<java.lang.String,java.lang.String> dataAttributes)
Adds a menu itemstatic void
addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css, java.util.Map<java.lang.String,java.lang.String> dataAttributes, java.lang.String wrapperCss)
Adds a menu itemstatic void
addItemSeparator(java.lang.StringBuffer sb)
Adds a menu item separator.static void
addItemWithConfirm(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String confirmMsg, java.lang.String redirect, java.lang.String contextPath)
Adds a menu item with a confirm message dialog box.static void
addItemWithJSConfirm(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String func, java.lang.String confirmMsg)
Adds a menu item with a confirm message dialog box.static void
addItemWithOnclick(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String onclick, java.lang.String redirect)
Convenient method that delegater toaddItemWithOnclick(StringBuffer, String, boolean, String, String, String, String, String, String)
static void
addItemWithOnclick(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String onclick, java.lang.String title, java.lang.String redirect)
Adds a menu item with onclick value.static void
addItemWithPrompt(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String func, java.lang.String promptMsg, java.lang.String defaultValue)
Adds a menu item with an input dialog box.static void
addItemWithPrompt(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String promptMsg, java.lang.String redirectJSNoCaddy, java.lang.String param, java.lang.String defaultValue)
Adds a menu item with an input dialog box.static void
closeItem(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String icon, java.lang.String label)
Close a menu item which has got an icon.static void
closeItem(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String icon, java.lang.String label, java.lang.String value)
Close a menu item which has got an icon.static void
endInfoSection(java.lang.StringBuffer sb)
Ends an info sectionstatic void
endSubSection(java.lang.StringBuffer sb)
Ends an sub-sectionstatic java.lang.String
getRedirectJSNoCaddy(javax.servlet.http.HttpServletRequest request)
Gives the redirect for the given request, without parameter to update the caddy.static void
openItem(java.lang.StringBuffer sb, boolean isEnabled)
Open a menu item which has got an icon.static void
openItem(java.lang.StringBuffer sb, boolean isEnabled, java.lang.String css)
Open a menu item which has got an icon.static void
startInfoSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon)
Starts an info sectionstatic void
startSubSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon)
Starts an sub-sectionstatic void
startSubSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon, java.lang.String ul)
Starts an sub-section
-
-
-
Method Detail
-
getRedirectJSNoCaddy
public static java.lang.String getRedirectJSNoCaddy(javax.servlet.http.HttpServletRequest request)
Gives the redirect for the given request, without parameter to update the caddy.- Parameters:
request
- the current J2EE request- Returns:
- the redirect value
-
addItemSeparator
public static void addItemSeparator(java.lang.StringBuffer sb)
Adds a menu item separator.- Parameters:
sb
- the StringBuffer
-
addItem
public static void addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url)
Adds a menu item- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this item
-
addItem
public static void addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect)
Adds a menu item- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemredirect
- if not empty, add a redirect attribute in the url.
-
addItem
public static void addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css)
Adds a menu item- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemredirect
- if not empty, add a redirect attribute in the url.css
- the link css
-
addItem
public static void addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css, java.util.Map<java.lang.String,java.lang.String> dataAttributes)
Adds a menu item- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemredirect
- if not empty, add a redirect attribute in the url.css
- the link cssdataAttributes
- the data attributes to add on link element
-
addItem
public static void addItem(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String redirect, java.lang.String css, java.util.Map<java.lang.String,java.lang.String> dataAttributes, java.lang.String wrapperCss)
Adds a menu item- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemredirect
- if not empty, add a redirect attribute in the url.css
- the link cssdataAttributes
- the data attributes to add on the link elementwrapperCss
- the css to add on the link wrapper- Since:
- jcms-9.0.3
-
addItemWithOnclick
public static void addItemWithOnclick(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String onclick, java.lang.String redirect)
Convenient method that delegater toaddItemWithOnclick(StringBuffer, String, boolean, String, String, String, String, String, String)
- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemonclick
- the javascript function to call (Note: current implementation use double quote onclick="")redirect
- if not empty, add a redirect attribute in the url.
-
addItemWithOnclick
public static void addItemWithOnclick(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String onclick, java.lang.String title, java.lang.String redirect)
Adds a menu item with onclick value. The given url may be null and will be replaced by '#'- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user selects this itemonclick
- the javascript function to call (Note: current implementation use double quote onclick="")title
- the title to set (should not contains double quoteredirect
- parameter in the url
-
addItemWithConfirm
public static void addItemWithConfirm(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String confirmMsg, java.lang.String redirect, java.lang.String contextPath)
Adds a menu item with a confirm message dialog box.- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelurl
- the URL to access if the user confirms the dialog boxconfirmMsg
- the confirm messageredirect
- to force the value of the redirectcontextPath
- the context path of the current J2EE request
-
addItemWithJSConfirm
public static void addItemWithJSConfirm(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String func, java.lang.String confirmMsg)
Adds a menu item with a confirm message dialog box.- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the icon of this itemlabel
- the property of the labelfunc
- the JavaScript Func to call if the user confirms the dialog box If you need to use string literal in your function, use the simple quote ('), e.g :String func = "function() {Popup.popupWindow('"+url+"', 'Something');}";
confirmMsg
- the confirm message
-
addItemWithPrompt
public static void addItemWithPrompt(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String url, java.lang.String promptMsg, java.lang.String redirectJSNoCaddy, java.lang.String param, java.lang.String defaultValue)
Adds a menu item with an input dialog box. Then redirect prompt value to given url.- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the iconlabel
- the property of the labelurl
- the URL to access if the user confirm the dialog boxpromptMsg
- the prompt messageredirectJSNoCaddy
- the redirect of the current J2EE request with action param for the caddyparam
- the name of the parameter for the input textdefaultValue
- the default value of the input
-
addItemWithPrompt
public static void addItemWithPrompt(java.lang.StringBuffer sb, java.lang.String userLang, boolean isEnabled, java.lang.String icon, java.lang.String label, java.lang.String func, java.lang.String promptMsg, java.lang.String defaultValue)
Adds a menu item with an input dialog box. Then call javascript with prompt value.- Parameters:
sb
- the StringBufferuserLang
- the current user langisEnabled
- true if this item is enabledicon
- the iconlabel
- the property of the labelfunc
- the JavaScript function to call with prompt valuepromptMsg
- the prompt messagedefaultValue
- the default value of the input
-
startSubSection
public static void startSubSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon)
Starts an sub-section- Parameters:
sb
- the StringBufferuserLang
- the current user langlabel
- the label of the sectionicon
- the icon
-
startSubSection
public static void startSubSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon, java.lang.String ul)
Starts an sub-section- Parameters:
sb
- the StringBufferuserLang
- the current user langlabel
- the label of the sectionicon
- the iconul
- the class on the ul subsection or null
-
endSubSection
public static void endSubSection(java.lang.StringBuffer sb)
Ends an sub-section- Parameters:
sb
- the StringBuffer
-
startInfoSection
public static void startInfoSection(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon)
Starts an info section- Parameters:
sb
- the StringBufferuserLang
- the current user langlabel
- the label of the sectionicon
- the icon
-
endInfoSection
public static void endInfoSection(java.lang.StringBuffer sb)
Ends an info section- Parameters:
sb
- the StringBuffer
-
addInfo
public static void addInfo(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String value)
Adds an info in an info section- Parameters:
sb
- the StringBufferuserLang
- the current user langlabel
- the label of the infovalue
- the value
-
addInfoText
public static void addInfoText(java.lang.StringBuffer sb, java.lang.String text)
Adds an info in an info section- Parameters:
sb
- the StringBuffertext
- the text to display
-
addInfo
public static void addInfo(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String value, java.lang.String url, java.lang.String titleConfirm, java.lang.String icon, boolean isDisabled)
Adds an info with a icon and a text.- Parameters:
sb
- the StringBufferuserLang
- the current user langlabel
- the I18N property to displayvalue
- if the info is with a computed value to display (may be null : won't be displayed)url
- the possible linktitleConfirm
- an message for a confirm if there is an action linkicon
- the path to the icon to displayisDisabled
- if the line is disabled
-
addInfoImage
public static void addInfoImage(java.lang.StringBuffer sb, java.lang.String path)
Adds an info in an info section- Parameters:
sb
- the StringBufferpath
- the path of the image to display
-
openItem
public static void openItem(java.lang.StringBuffer sb, boolean isEnabled)
Open a menu item which has got an icon.- Parameters:
sb
- the StringBufferisEnabled
- true if this item is enabled.
-
openItem
public static void openItem(java.lang.StringBuffer sb, boolean isEnabled, java.lang.String css)
Open a menu item which has got an icon.- Parameters:
sb
- the StringBufferisEnabled
- true if this item is enabled.css
- the css to add in class attribute (Will be added on the LI element)
-
closeItem
public static void closeItem(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String icon, java.lang.String label)
Close a menu item which has got an icon.- Parameters:
sb
- the StringBufferuserLang
- the current user langicon
- the item iconlabel
- the label of the item
-
closeItem
public static void closeItem(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String icon, java.lang.String label, java.lang.String value)
Close a menu item which has got an icon.- Parameters:
sb
- the StringBufferuserLang
- the current user langicon
- the item iconlabel
- the label of the itemvalue
- display a String value after the localized label
-
addIcon
public static void addIcon(java.lang.StringBuffer sb, java.lang.String icon)
Print to StringBuffer Image tag that can be an icon or a sprite- Parameters:
sb
- the StringBuffer in which to print the img tagicon
- the icon to display
-
-