Class CtxMenuUtil

java.lang.Object
com.jalios.jcms.ajax.CtxMenuUtil
All Implemented Interfaces:
CtxMenuConstants

public class CtxMenuUtil extends Object implements CtxMenuConstants
Utility class providing convenient methods for producing contextual menus.
Since:
jcms-6.1.0
Author:
dissert
  • Constructor Details

    • CtxMenuUtil

      public CtxMenuUtil()
  • Method Details

    • getRedirectJSNoCaddy

      public static 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(StringBuffer sb)
      Adds a menu item separator.
      Parameters:
      sb - the StringBuffer
    • addItem

      public static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url)
      Adds a menu item
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
    • addItem

      public static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect)
      Adds a menu item
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      redirect - if not empty, add a redirect attribute in the url.
    • addItem

      public static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect, String css)
      Adds a menu item
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      redirect - if not empty, add a redirect attribute in the url.
      css - the link css
    • addItem

      public static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect, String css, Map<String,String> dataAttributes)
      Adds a menu item
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      redirect - if not empty, add a redirect attribute in the url.
      css - the link css
      dataAttributes - the data attributes to add on link element
    • addItem

      public static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect, String css, Map<String,String> dataAttributes, String wrapperCss)
      Adds a menu item
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      redirect - if not empty, add a redirect attribute in the url.
      css - the link css
      dataAttributes - the data attributes to add on the link element
      wrapperCss - the css to add on the link wrapper
      Since:
      jcms-9.0.3
    • addItemWithOnclick

      @Deprecated(forRemoval=true) public static void addItemWithOnclick(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String onclick, String redirect)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since JCMS-3712, inline onclick event are not compliance with strict Content-Security-Policy.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      onclick - the javascript function to call
      redirect - if not empty, add a redirect attribute in the url.
    • addItemWithOnclick

      @Deprecated(forRemoval=true) public static void addItemWithOnclick(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String onclick, String title, String redirect)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since JCMS-3712, inline onclick event are not compliance with strict Content-Security-Policy.
      Adds a menu item with onclick value. The given url may be null and will be replaced by '#'
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user selects this item
      onclick - the javascript function to call
      title - the title to set
      redirect - parameter in the url
    • addItemWithConfirm

      public static void addItemWithConfirm(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String confirmMsg, String redirect, String contextPath)
      Adds a menu item with a confirm message dialog box.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      url - the URL to access if the user confirms the dialog box
      confirmMsg - the confirm message
      redirect - to force the value of the redirect
      contextPath - the context path of the current J2EE request
    • addItemWithJSConfirm

      @Deprecated(forRemoval=true) public static void addItemWithJSConfirm(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String func, String confirmMsg)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since JCMS-3712, inline onclick event are not compliance with strict Content-Security-Policy.
      Adds a menu item with a confirm message dialog box.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon of this item
      label - the property of the label
      func - 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

      @Deprecated(forRemoval=true) public static void addItemWithPrompt(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String promptMsg, String redirectJSNoCaddy, String param, String defaultValue)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since JCMS-3712, inline onclick event are not compliance with strict Content-Security-Policy.
      Adds a menu item with an input dialog box. Then redirect prompt value to given url.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon
      label - the property of the label
      url - the URL to access if the user confirm the dialog box
      promptMsg - the prompt message
      redirectJSNoCaddy - the redirect of the current J2EE request with action param for the caddy
      param - the name of the parameter for the input text
      defaultValue - the default value of the input
    • addItemWithPrompt

      @Deprecated(forRemoval=true) public static void addItemWithPrompt(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String func, String promptMsg, String defaultValue)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since JCMS-3712, inline onclick event are not compliance with strict Content-Security-Policy.
      Adds a menu item with an input dialog box. Then call javascript with prompt value.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      isEnabled - true if this item is enabled
      icon - the icon
      label - the property of the label
      func - the JavaScript function to call with prompt value
      promptMsg - the prompt message
      defaultValue - the default value of the input
    • startSubSection

      public static void startSubSection(StringBuffer sb, String userLang, String label, String icon)
      Starts an sub-section
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      label - the label of the section
      icon - the icon
    • startSubSection

      public static void startSubSection(StringBuffer sb, String userLang, String label, String icon, String ul)
      Starts an sub-section
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      label - the label of the section
      icon - the icon
      ul - the class on the ul subsection or null
    • endSubSection

      public static void endSubSection(StringBuffer sb)
      Ends an sub-section
      Parameters:
      sb - the StringBuffer
    • startInfoSection

      public static void startInfoSection(StringBuffer sb, String userLang, String label, String icon)
      Starts an info section
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      label - the label of the section
      icon - the icon
    • endInfoSection

      public static void endInfoSection(StringBuffer sb)
      Ends an info section
      Parameters:
      sb - the StringBuffer
    • addInfo

      public static void addInfo(StringBuffer sb, String userLang, String label, String value)
      Adds an info in an info section
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      label - the label of the info
      value - the value
    • addInfoText

      public static void addInfoText(StringBuffer sb, String text)
      Adds an info in an info section
      Parameters:
      sb - the StringBuffer
      text - the text to display
    • addInfo

      public static void addInfo(StringBuffer sb, String userLang, String label, String value, String url, String titleConfirm, String icon, boolean isDisabled)
      Adds an info with a icon and a text.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      label - the I18N property to display
      value - if the info is with a computed value to display (may be null : won't be displayed)
      url - the possible link
      titleConfirm - an message for a confirm if there is an action link
      icon - the path to the icon to display
      isDisabled - if the line is disabled
    • addInfoImage

      public static void addInfoImage(StringBuffer sb, String path)
      Adds an info in an info section
      Parameters:
      sb - the StringBuffer
      path - the path of the image to display
    • openItem

      public static void openItem(StringBuffer sb, boolean isEnabled)
      Open a menu item which has got an icon.
      Parameters:
      sb - the StringBuffer
      isEnabled - true if this item is enabled.
    • openItem

      public static void openItem(StringBuffer sb, boolean isEnabled, String css)
      Open a menu item which has got an icon.
      Parameters:
      sb - the StringBuffer
      isEnabled - 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(StringBuffer sb, String userLang, String icon, String label)
      Close a menu item which has got an icon.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      icon - the item icon
      label - the label of the item
    • closeItem

      public static void closeItem(StringBuffer sb, String userLang, String icon, String label, String value)
      Close a menu item which has got an icon.
      Parameters:
      sb - the StringBuffer
      userLang - the current user lang
      icon - the item icon
      label - the label of the item
      value - display a String value after the localized label
    • addIcon

      public static void addIcon(StringBuffer sb, 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 tag
      icon - the icon to display