Class CmsXmlContentEditor

    • Method Detail

      • actionClear

        public void actionClear​(boolean forceUnlock)
        Deletes the temporary file and unlocks the edited resource when in direct edit mode.

        Specified by:
        actionClear in class CmsEditor
        Parameters:
        forceUnlock - if true, the resource will be unlocked anyway
      • actionCopyElementLocale

        public void actionCopyElementLocale()
                                     throws javax.servlet.jsp.JspException
        Performs the copy locale action.

        Throws:
        javax.servlet.jsp.JspException - if something goes wrong
      • actionDeleteElementLocale

        public void actionDeleteElementLocale()
                                       throws javax.servlet.jsp.JspException
        Performs the delete locale action.

        Throws:
        javax.servlet.jsp.JspException - if something goes wrong
      • actionDirectEdit

        public void actionDirectEdit()
                              throws java.io.IOException,
                                     javax.servlet.jsp.JspException,
                                     javax.servlet.ServletException
        Performs a configurable action performed by the editor.

        The default action is: save resource, clear temporary files and publish the resource directly.

        Throws:
        java.io.IOException - if a forward fails
        javax.servlet.ServletException - of a forward fails
        javax.servlet.jsp.JspException - if including a JSP fails
      • actionExit

        public void actionExit()
                        throws java.io.IOException,
                               javax.servlet.jsp.JspException,
                               javax.servlet.ServletException
        Performs the exit editor action.

        Specified by:
        actionExit in class CmsEditor
        Throws:
        java.io.IOException - if a forward fails
        javax.servlet.jsp.JspException - if including an element fails
        javax.servlet.ServletException - if a forward fails
        See Also:
        CmsEditor.actionExit()
      • actionMoveElement

        public void actionMoveElement()
                               throws javax.servlet.jsp.JspException
        Moves an element in the xml content either up or down.

        Depends on the given action value.

        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • actionNew

        public void actionNew()
                       throws javax.servlet.jsp.JspException
        Creates a new XML content item for editing.

        Throws:
        javax.servlet.jsp.JspException - in case something goes wrong
      • actionPreview

        public void actionPreview()
                           throws java.io.IOException,
                                  javax.servlet.jsp.JspException
        Performs the preview XML content action in a new browser window.

        Throws:
        java.io.IOException - if redirect fails
        javax.servlet.jsp.JspException - if inclusion of error page fails
      • actionSave

        public void actionSave()
                        throws javax.servlet.jsp.JspException
        Performs the save content action.

        Specified by:
        actionSave in class CmsEditor
        Throws:
        javax.servlet.jsp.JspException - if including an element fails
        See Also:
        CmsEditor.actionSave()
      • actionSave

        public void actionSave​(java.util.Locale locale)
                        throws javax.servlet.jsp.JspException
        Performs the save content action.

        This is also used when changing the element language.

        Parameters:
        locale - the locale to save the content
        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • actionToggleElement

        public void actionToggleElement()
                                 throws javax.servlet.jsp.JspException
        Adds an optional element to the XML content or removes an optional element from the XML content.

        Depends on the given action value.

        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • buildElementChoices

        public JSONArray buildElementChoices​(java.lang.String elementName,
                                             boolean choiceType,
                                             boolean checkChoice)
        Returns the JSON array with information about the choices of a given element.

        The returned array is only filled if the given element has choice options, otherwise an empty array is returned.
        Note: the first array element is an object containing information if the element itself is a choice type, the following elements are the choice option items.

        Parameters:
        elementName - the element name to check (complete xpath)
        choiceType - flag indicating if the given element name represents a choice type or not
        checkChoice - flag indicating if the element name should be checked if it is a choice option and choice type
        Returns:
        the JSON array with information about the choices of a given element
      • buildSelectElementLanguage

        public java.lang.String buildSelectElementLanguage​(java.lang.String attributes)
        Builds the HTML String for the element language selector.

        This method has to use the resource request parameter because the temporary file is not available in the upper button frame.

        Parameters:
        attributes - optional attributes for the <select> tag
        Returns:
        the HTML for the element language select box
      • buildSubChoices

        public java.lang.String buildSubChoices()
        Returns the available sub choices for a nested choice element.

        Returns:
        the available sub choices for a nested choice element as JSON array string
      • getElementLocale

        public java.util.Locale getElementLocale()
        Returns the current element locale.

        Returns:
        the current element locale
      • getHelpMessageIds

        public java.util.Set<java.lang.String> getHelpMessageIds()
        Description copied from interface: I_CmsWidgetDialog
        Returns a set of help messages ids that are already included on the widget dialog.

        This is used to prevent the occurence of multiple html div id's with the same value when generating the help texts. For valid html, each id can be used only once.

        Specified by:
        getHelpMessageIds in interface I_CmsWidgetDialog
        Returns:
        a set of help messages ids that are already included on the widget dialog
        See Also:
        I_CmsWidgetDialog.getHelpMessageIds()
      • getParamChoiceElement

        public java.lang.String getParamChoiceElement()
        Returns the name of the choice element to add.

        Returns:
        the name of the choice element to add
      • getParamChoiceType

        public java.lang.String getParamChoiceType()
        Returns the flag if the element to add is a choice type.

        Returns:
        the flag if the element to add is a choice type
      • getParamEditContext

        public java.lang.String getParamEditContext()
        Gets the editor context path (usually either a container page path or null).

        Returns:
        the editor context path
      • getParamElementIndex

        public java.lang.String getParamElementIndex()
        Returns the index of the element to add or remove.

        Returns:
        the index of the element to add or remove
      • getParamElementName

        public java.lang.String getParamElementName()
        Returns the name of the element to add or remove.

        Returns:
        the name of the element to add or remove
      • getParamMode

        public java.lang.String getParamMode()
        Returns the mode.

        Returns:
        the mode
      • getParamModelFile

        public java.lang.String getParamModelFile()
        Returns the parameter that specifies the model file name.

        Returns:
        the parameter that specifies the model file name
      • getParamNewLink

        public java.lang.String getParamNewLink()
        Returns the "new link" parameter.

        Returns:
        the "new link" parameter
      • getParamPostCreateHandler

        public java.lang.String getParamPostCreateHandler()
        Returns the postCreateHandler.

        Returns:
        the postCreateHandler
      • getXmlEditorForm

        public java.lang.String getXmlEditorForm()
        Generates the HTML form for the XML content editor.

        Returns:
        the HTML that generates the form for the XML editor
      • getXmlEditorHtmlEnd

        public java.lang.String getXmlEditorHtmlEnd()
                                             throws javax.servlet.jsp.JspException
        Generates the HTML for the end of the HTML editor form page.

        Returns:
        the HTML for the end of the HTML editor form page
        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • getXmlEditorIncludes

        public java.lang.String getXmlEditorIncludes()
                                              throws javax.servlet.jsp.JspException
        Generates the JavaScript includes for the used widgets in the editor form.

        Returns:
        the JavaScript includes for the used widgets
        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • getXmlEditorInitCalls

        public java.lang.String getXmlEditorInitCalls()
                                               throws javax.servlet.jsp.JspException
        Generates the JavaScript initialization calls for the used widgets in the editor form.

        Returns:
        the JavaScript initialization calls for the used widgets
        Throws:
        javax.servlet.jsp.JspException - if including the error page fails
      • getXmlEditorInitMethods

        public java.lang.String getXmlEditorInitMethods()
                                                 throws javax.servlet.jsp.JspException
        Generates the JavaScript initialization methods for the used widgets.

        Returns:
        the JavaScript initialization methods for the used widgets
        Throws:
        javax.servlet.jsp.JspException - if an error occurs during JavaScript generation
      • hasValidationErrors

        public boolean hasValidationErrors()
        Returns true if the edited content contains validation errors, otherwise false.

        Returns:
        true if the edited content contains validation errors, otherwise false
      • isPreviewEnabled

        public boolean isPreviewEnabled()
        Returns true if the preview is available for the edited xml content.

        This method has to use the resource request parameter and read the file from vfs because the temporary file is not available in the upper button frame.

        Returns:
        true if the preview is enabled, otherwise false
      • setEditorValues

        public void setEditorValues​(java.util.Locale locale)
                             throws CmsXmlException
        Sets the editor values for the locale with the parameters from the request.

        Called before saving the xml content, redisplaying the input form, changing the language and adding or removing elements.

        Parameters:
        locale - the locale of the content to save
        Throws:
        CmsXmlException - if something goes wrong
      • setParamChoiceElement

        public void setParamChoiceElement​(java.lang.String choiceElement)
        Sets the name of the choice element to add.

        Parameters:
        choiceElement - the name of the choice element to add
      • setParamChoiceType

        public void setParamChoiceType​(java.lang.String paramChoiceType)
        Sets the flag if the element to add is a choice type.

        Parameters:
        paramChoiceType - the flag if the element to add is a choice type
      • setParamEditContext

        public void setParamEditContext​(java.lang.String editContext)
        Sets the edit context URI.

        Parameters:
        editContext - the edit context URI.
      • setParamElementIndex

        public void setParamElementIndex​(java.lang.String elementIndex)
        Sets the index of the element to add or remove.

        Parameters:
        elementIndex - the index of the element to add or remove
      • setParamElementName

        public void setParamElementName​(java.lang.String elementName)
        Sets the name of the element to add or remove.

        Parameters:
        elementName - the name of the element to add or remove
      • setParamMode

        public void setParamMode​(java.lang.String mode)
        Sets the content creation mode.

        Parameters:
        mode - the content creation mode
      • setParamModelFile

        public void setParamModelFile​(java.lang.String paramMasterFile)
        Sets the parameter that specifies the model file name.

        Parameters:
        paramMasterFile - the parameter that specifies the model file name
      • setParamNewLink

        public void setParamNewLink​(java.lang.String paramNewLink)
        Sets the "new link" parameter.

        Parameters:
        paramNewLink - the "new link" parameter to set
      • setParamPostCreateHandler

        public void setParamPostCreateHandler​(java.lang.String handler)
        Sets the post-create handler class name.

        Parameters:
        handler - the post-create handler class name
      • showElementLanguageSelector

        public boolean showElementLanguageSelector()
        Determines if the element language selector is shown dependent on the available Locales.

        Returns:
        true, if more than one Locale is available, otherwise false
      • ensureLocale

        protected java.util.Locale ensureLocale​(java.util.Locale locale)
        Makes sure the requested locale node is present in the content document by either copying an existing locale node or creating an empty one.

        Parameters:
        locale - the requested locale
        Returns:
        the locale
      • initContent

        protected void initContent()
        Initializes the editor content when opening the editor for the first time.

        Not necessary for the xmlcontent editor.

        Specified by:
        initContent in class CmsEditor
      • initElementLanguage

        protected void initElementLanguage()
        Initializes the element language for the first call of the editor.