com.jalios.jcms.ajax
Class CtxMenuUtil

java.lang.Object
  extended by 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

Field Summary
 
Fields inherited from interface com.jalios.jcms.ajax.CtxMenuConstants
DISABLED, FLAG_CADDY, FLAG_DELETE, FLAG_EDIT, FLAG_EXPORT, FLAG_SEPARATOR, INFO_ICON, MENU_DISABLED, MENU_ENABLED, MENU_SKIPPED, NO_ICON
 
Constructor Summary
CtxMenuUtil()
           
 
Method Summary
static void addIcon(StringBuffer sb, String icon)
          Print to StringBuffer Image tag that can be an icon or a sprite
static void addInfo(StringBuffer sb, String userLang, String label, String value)
          Adds an info in an info section
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.
static void addInfoImage(StringBuffer sb, String path)
          Adds an info in an info section
static void addInfoText(StringBuffer sb, String text)
          Adds an info in an info section
static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url)
          Adds a menu item
static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect)
          Adds a menu item
static void addItem(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String redirect, String css)
          Adds a menu item
static void addItemSeparator(StringBuffer sb)
          Adds a menu item separator.
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.
static void addItemWithJSConfirm(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String func, String confirmMsg)
          Adds a menu item with a confirm message dialog box.
static void addItemWithOnclick(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String onclick, String redirect)
          Convenient method that delegater to addItemWithOnclick(StringBuffer, String, boolean, String, String, String, String, String, String)
static void addItemWithOnclick(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String onclick, String title, String redirect)
          Adds a menu item with onclick value.
static void addItemWithPrompt(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String func, String promptMsg, String defaultValue)
          Adds a menu item with an input dialog box.
static void addItemWithPrompt(StringBuffer sb, String userLang, boolean isEnabled, String icon, String label, String url, String promptMsg, String redirectJSNoCaddy, String param, String defaultValue)
          Adds a menu item with an input dialog box.
static void closeItem(StringBuffer sb, String userLang, String icon, String label)
          Close a menu item which has got an icon.
static void closeItem(StringBuffer sb, String userLang, String icon, String label, String value)
          Close a menu item which has got an icon.
static void endInfoSection(StringBuffer sb)
          Ends an info section
static void endSubSection(StringBuffer sb)
          Ends an sub-section
static String getRedirectJSNoCaddy(javax.servlet.http.HttpServletRequest request)
          Gives the redirect for the given request, without parameter to update the caddy.
static void openItem(StringBuffer sb, boolean isEnabled)
          Open a menu item which has got an icon.
static void startInfoSection(StringBuffer sb, String userLang, String label, String icon)
          Starts an info section
static void startSubSection(StringBuffer sb, String userLang, String label, String icon)
          Starts an sub-section
static void startSubSection(StringBuffer sb, String userLang, String label, String icon, 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 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

addItemWithOnclick

public static void addItemWithOnclick(StringBuffer sb,
                                      String userLang,
                                      boolean isEnabled,
                                      String icon,
                                      String label,
                                      String url,
                                      String onclick,
                                      String redirect)
Convenient method that delegater to addItemWithOnclick(StringBuffer, String, boolean, String, String, String, String, String, String)

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(StringBuffer sb,
                                      String userLang,
                                      boolean isEnabled,
                                      String icon,
                                      String label,
                                      String url,
                                      String onclick,
                                      String title,
                                      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(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

public static void addItemWithJSConfirm(StringBuffer sb,
                                        String userLang,
                                        boolean isEnabled,
                                        String icon,
                                        String label,
                                        String func,
                                        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(StringBuffer sb,
                                     String userLang,
                                     boolean isEnabled,
                                     String icon,
                                     String label,
                                     String url,
                                     String promptMsg,
                                     String redirectJSNoCaddy,
                                     String param,
                                     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(StringBuffer sb,
                                     String userLang,
                                     boolean isEnabled,
                                     String icon,
                                     String label,
                                     String func,
                                     String promptMsg,
                                     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(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.

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, can be either an icon sprite class name matching ss_* (in which case it is used as a sprite class) or else a full or relative path (in which case it is use in src attribute)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.