Class WidgetUtil

    • Constructor Detail

      • WidgetUtil

        public WidgetUtil()
    • Method Detail

      • getHtmlIcon

        public static java.lang.String getHtmlIcon​(java.lang.String src,
                                                   java.lang.String title)
        Build an icon
        Parameters:
        src - the image source
        title - the image title
        Returns:
        the image tag representation
      • getHtmlIcon

        public static java.lang.String getHtmlIcon​(java.lang.String src,
                                                   java.lang.String title,
                                                   java.lang.String alt)
        Build an icon
        Parameters:
        src - the image source
        title - the image title
        alt - the image alt
        Returns:
        the image tag representation
      • getHtmlIcon

        public static java.lang.String getHtmlIcon​(java.lang.String src,
                                                   java.lang.String title,
                                                   java.lang.String id,
                                                   java.lang.String style,
                                                   java.lang.String onclick)
        Build an icon
        Parameters:
        src - the image URL
        title - the image title
        id - the id
        style - the style
        onclick - the onclick value
        Returns:
        the image tag representation
      • getHtmlIcon

        public static java.lang.String getHtmlIcon​(java.lang.String src,
                                                   java.lang.String title,
                                                   java.lang.String alt,
                                                   java.lang.String id,
                                                   java.lang.String style,
                                                   java.lang.String onclick)
        Build an icon
        Parameters:
        src - the image URL
        title - the image title
        alt - the image alt
        id - the id
        style - the style
        onclick - the onclick value
        Returns:
        the image tag representation
      • getHtmlHidden

        public static java.lang.String getHtmlHidden​(java.lang.String widgetName,
                                                     java.lang.String value)
        Convenient method that build an input hidden field calling printHiddenField
        Parameters:
        widgetName - the name of the hidden field
        value - the value of the hidden field
        Returns:
        the hidden tag
      • getLangTab

        public static java.lang.String getLangTab​(java.lang.String widget,
                                                  java.lang.String lang)
        Return ONE Lang Tab for a given lang with a given widget has content.
        Parameters:
        widget - the widget to put
        lang - the lang of the tab
        Returns:
        String for the given lang tab TODO: I18N Lang Alt
      • getControlSettings

        public static ControlSettings<?> getControlSettings​(java.lang.String editorName)
        Returns an instance of ControlSettings corresponding to the given editor name.
        Parameters:
        editorName - editor name
        Returns:
        ControlSettings implementation
        Since:
        10.0.1
        See Also:
        getPropertyEditor(String)
      • getPropertyEditor

        public static java.lang.String getPropertyEditor​(java.lang.String propertyKey)
        Returns the editor associated to the given property key.
        Parameters:
        propertyKey - the property key
        Returns:
        String the property editor
      • getShortProperty

        public static java.lang.String getShortProperty​(java.lang.String key)
        Return the value of the property without the editor value
        Parameters:
        key - the full extra key
        Returns:
        String the short key
      • getShortProperty

        public static java.lang.String getShortProperty​(java.lang.String key,
                                                        java.lang.String editor)
        Return the value of the property without the editor value
        Parameters:
        key - the full extra key
        editor - the editor
        Returns:
        String the short key
      • printHtmlButton

        public static java.lang.String printHtmlButton​(java.lang.String widgetName,
                                                       java.lang.String value,
                                                       boolean submit,
                                                       java.lang.String onClick,
                                                       boolean isMainAction)
        Print an HTML Button
        Parameters:
        widgetName - the name of the button
        value - the value of the button
        submit - is a submit button
        onClick - is onClick action
        isMainAction - if true use
        Returns:
        the String representation of the button
      • printHtmlButton

        public static java.lang.String printHtmlButton​(java.lang.String widgetName,
                                                       java.lang.String value,
                                                       boolean submit,
                                                       java.lang.String onClick,
                                                       boolean isMainAction,
                                                       int tabindex)
      • printPopupButton

        public static java.lang.String printPopupButton​(java.lang.String label,
                                                        java.lang.String url)
      • printSubmitButton

        public static java.lang.String printSubmitButton​(java.lang.String label,
                                                         java.lang.String action)
        Return a Submit HTML Button with a given label/action
        Parameters:
        label - the label of the button
        action - the name of the action while submitting
        Returns:
        a String representation
      • printSubmitButton

        public static java.lang.String printSubmitButton​(java.lang.String label,
                                                         java.lang.String action,
                                                         int tabindex)
      • printSubmitFormButton

        public static java.lang.String printSubmitFormButton​(java.lang.String label,
                                                             java.lang.String action,
                                                             java.lang.String formName,
                                                             java.lang.String userLang)
        Display a Button that will submit form for a given action
        Parameters:
        label - the label of the button
        action - the name of the action while submitting
        formName - the name of the form
        userLang - the current userLang
        Returns:
        the String representation of the button
      • printSubmitFormButton

        public static java.lang.String printSubmitFormButton​(java.lang.String label,
                                                             java.lang.String action,
                                                             java.lang.String formName,
                                                             java.lang.String userLang,
                                                             int tabindex)
      • printConfirmSubmitFormButton

        public static java.lang.String printConfirmSubmitFormButton​(java.lang.String label,
                                                                    java.lang.String action,
                                                                    java.lang.String formName,
                                                                    java.lang.String msg,
                                                                    java.lang.String userLang)
        Display a Button that will ask to confirm the action
        Parameters:
        label - the label of the button
        action - the name of the action while submitting
        formName - the name of the form
        msg - an I18N confirm message
        userLang - the current userLang
        Returns:
        the String representation of the button
      • printConfirmSubmitFormButton

        public static java.lang.String printConfirmSubmitFormButton​(java.lang.String label,
                                                                    java.lang.String action,
                                                                    java.lang.String formName,
                                                                    java.lang.String msg,
                                                                    java.lang.String userLang,
                                                                    int tabindex)
      • printHiddenField

        public static void printHiddenField​(java.lang.StringBuffer sb,
                                            java.lang.String widgetName,
                                            java.lang.String value,
                                            java.lang.String style,
                                            java.lang.String id)
        Print Hidden Input
        Parameters:
        sb - the Buffer
        widgetName - the widget name
        value - the value
        style - the CSS style
        id - the id
      • printHiddenField

        public static void printHiddenField​(java.lang.StringBuffer sb,
                                            java.lang.String widgetName,
                                            java.lang.String value)
        Print Hidden Input
        Parameters:
        sb - the Buffer
        widgetName - the widget name
        value - the value
      • printInputBox

        public static void printInputBox​(java.lang.StringBuffer sb,
                                         java.lang.String inputId,
                                         java.lang.String fieldName,
                                         java.lang.String fieldValue,
                                         java.lang.String fieldLabel,
                                         boolean check,
                                         boolean selected,
                                         boolean disabled,
                                         int tabindex,
                                         java.lang.String customAttributes,
                                         java.lang.String lang)
        Print an input Checkbox or Radio button
        Parameters:
        sb - the buffer
        inputId - the id of the input
        fieldName - the name of the widget
        fieldValue - the value of the widget
        fieldLabel - the label of the widget
        check - checkbox or radio button ?
        selected - selected or not ?
        disabled - true to disabled the input box
        tabindex - the tabinex
        customAttributes - the custom attributes to add to each input
        lang - the language (ISO-639) of this text area or null for default site language.
        Since:
        6.0
      • printInputBox

        public static java.lang.String printInputBox​(java.lang.String fieldId,
                                                     java.lang.String fieldName,
                                                     java.lang.String fieldValue,
                                                     java.lang.String fieldLabel,
                                                     boolean check,
                                                     boolean selected,
                                                     boolean disabled,
                                                     int tabindex,
                                                     java.lang.String lang)
      • printInputBox

        public static java.lang.String printInputBox​(java.lang.String fieldId,
                                                     java.lang.String fieldName,
                                                     java.lang.String fieldValue,
                                                     java.lang.String fieldLabel,
                                                     boolean check,
                                                     boolean selected,
                                                     boolean disabled,
                                                     int tabindex,
                                                     java.lang.String customAttributes,
                                                     java.lang.String lang)
      • printInputBoxList

        public static void printInputBoxList​(java.lang.StringBuffer sb,
                                             java.util.Collection<?> fieldIds,
                                             java.lang.String fieldName,
                                             java.util.Collection<?> fieldValue,
                                             java.util.Collection<?> fieldLabel,
                                             boolean check,
                                             java.util.Collection<?> selected,
                                             boolean br,
                                             boolean disabled,
                                             int tabindex,
                                             java.lang.String customAttributes,
                                             java.lang.String lang)
        Print an html list of check/radio box
        Parameters:
        sb - the buffer
        fieldIds - the DOM ids item : must be null or contains as many elements as fieldValue and fieldLabel
        fieldName - the name of the widget
        fieldValue - the values of the widget
        fieldLabel - the labels of the widget
        check - checkbox or radio button ?
        selected - a Set of selected values
        br - should append br
        disabled - true to disabled the inputs
        tabindex - the tabindex
        customAttributes - the custom attributes to add to each input
        lang - the language (ISO-639) of this text area or null for default site language.
        Since:
        6.0
      • printInputComboBox

        public static void printInputComboBox​(java.lang.StringBuffer sb,
                                              java.lang.String fieldId,
                                              java.lang.String fieldName,
                                              java.util.Collection<?> fieldValue,
                                              java.util.Collection<?> fieldLabel,
                                              java.lang.String selected,
                                              boolean blank,
                                              int tabindex,
                                              boolean disabled,
                                              java.lang.String custom,
                                              java.lang.String lang)
        Print a ComboBox
        Parameters:
        sb - the buffer
        fieldId - the id of the field
        fieldName - the name of the widget
        fieldValue - the values of the widget
        fieldLabel - the labels of the widget
        selected - the selected String
        blank - if true produce an empty option
        disabled - true to disable the combo box
        tabindex - the tabindex
        custom - custom html attribute to be added inside the select tag
        lang - the language (ISO-639) of this text area or null for default site language.
        Since:
        jcms-6.0
      • printInputListBox

        public static void printInputListBox​(java.lang.StringBuffer sb,
                                             java.lang.String fieldId,
                                             java.lang.String fieldName,
                                             int size,
                                             java.util.Collection<?> fieldValue,
                                             java.util.Collection<?> fieldLabel,
                                             java.util.Collection<?> selected,
                                             boolean disabled,
                                             int tabindex,
                                             java.lang.String customs,
                                             java.lang.String lang)
        Print a ListBox
        Parameters:
        sb - the buffer
        fieldId - the id of the field
        fieldName - the name of the widget
        size - size of the select
        fieldValue - the values of the widget
        fieldLabel - the labels of the widget
        selected - the selected String
        disabled - true to disabled the input listbox
        tabindex - the tabindex
        customs - custom html attribute to be added inside the select tag
        lang - the language (ISO-639) of this text area or null for default site language.
        Since:
        jcms-6.0
      • printDataSourceSelect

        public static void printDataSourceSelect​(java.lang.StringBuffer sb,
                                                 java.lang.String widgetName,
                                                 java.lang.String dataSource,
                                                 java.lang.String userLang)
        This method write to the buffer a select box of sql datasource. With the correct selected datasource.
        Parameters:
        sb - the Buffer
        widgetName - the widget name
        dataSource - the selected datasource
        userLang - the userlang
        Since:
        jcms-5.5.0
      • printLangAttributes

        public static void printLangAttributes​(java.lang.StringBuffer sb,
                                               java.lang.String lang)
        Appends the html language attributes to use for the given language. For example "lang='fr' xml:lang='fr' dir='ltr' " (note the spaces and without the double quotes). Nothing is appended if advanced I18N is not enabled in JCMS.
        Parameters:
        sb - the StringBuffer in which to append the class name
        lang - the language of the class to generated or null to use default jcms language
        See Also:
        Channel.isUsingAdvancedI18N()
      • printUnits

        public static void printUnits​(java.lang.StringBuffer sb,
                                      java.lang.String unit)
        Print the units for field
        Parameters:
        sb - the Buffer
        unit - the unit
      • printMandatory

        public static void printMandatory​(java.lang.StringBuffer sb)
        Print the Mandatory for a given field
        Parameters:
        sb - the Buffer
      • printLabel

        public static void printLabel​(java.lang.StringBuffer sb,
                                      java.lang.String formLabel,
                                      java.lang.String inputId)
        Print the field Label
        Parameters:
        sb - the Buffer
        formLabel - the label
        inputId - if not null, the given label is linked to the input with DOM id
      • printLabel

        public static void printLabel​(java.lang.StringBuffer sb,
                                      java.lang.String formLabel,
                                      java.lang.String[] inputId)
        Print the field label.
        Parameters:
        sb - the Buffer
        formLabel - the label
        inputId - array of ids of the input. Used in a "for" attribute.
      • printDescription

        public static void printDescription​(java.lang.StringBuffer sb,
                                            java.lang.String formDescription)
        Print the field Description
        Parameters:
        sb - the Buffer
        formDescription - the description
      • printInfo

        public static void printInfo​(java.lang.StringBuffer sb,
                                     java.lang.String formInfo)
        Print the field Info
        Parameters:
        sb - the Buffer
        formInfo - the info
      • printSeparator

        public static void printSeparator​(java.lang.StringBuffer sb,
                                          java.lang.String formField)
        Print a HR separator and an Anchor for the field
        Parameters:
        sb - the Buffer
        formField - name
      • printMoveFormElement

        protected static void printMoveFormElement​(java.lang.StringBuffer sb,
                                                   java.lang.String jsfunc,
                                                   java.lang.String formField,
                                                   java.lang.String formName,
                                                   java.lang.String action,
                                                   java.lang.String icon,
                                                   java.lang.String alt,
                                                   int pos,
                                                   int relFirst,
                                                   java.lang.String formFieldId)
      • getRadioInsert

        public static java.lang.String getRadioInsert​(Data data,
                                                      java.util.Locale locale)
        Retrieve a radio button suitable for insertion in chooser.
        Parameters:
        data - the data for which the insert radio button is added.
        locale - the Locale in which I18Ned element should be presented
        Returns:
        an HTML radio button