Class 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
    • 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 sprite
      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
      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.
      static void addInfoImage​(java.lang.StringBuffer sb, java.lang.String path)
      Adds an info in an info section
      static void addInfoText​(java.lang.StringBuffer sb, java.lang.String text)
      Adds an info in an info section
      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
      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
      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
      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
      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
      static 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)
      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 section
      static void endSubSection​(java.lang.StringBuffer sb)
      Ends an sub-section
      static 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 section
      static void startSubSection​(java.lang.StringBuffer sb, java.lang.String userLang, java.lang.String label, java.lang.String icon)
      Starts an sub-section
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CtxMenuUtil

        public CtxMenuUtil()
    • 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 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​(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 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​(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 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​(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 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​(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 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

        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)
        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 (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 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 (Note: current implementation use double quote onclick="")
        title - the title to set (should not contains double quote
        redirect - 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 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

        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 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

        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 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

        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 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​(java.lang.StringBuffer sb,
                                           java.lang.String userLang,
                                           java.lang.String label,
                                           java.lang.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​(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 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​(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 StringBuffer
        userLang - the current user lang
        label - the label of the section
        icon - 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 StringBuffer
        userLang - the current user lang
        label - the label of the info
        value - 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 StringBuffer
        text - 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 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​(java.lang.StringBuffer sb,
                                        java.lang.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​(java.lang.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​(java.lang.StringBuffer sb,
                                    boolean isEnabled,
                                    java.lang.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​(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 StringBuffer
        userLang - the current user lang
        icon - the item icon
        label - 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 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​(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 tag
        icon - the icon to display