Class CmsXmlContentEditor

All Implemented Interfaces:
I_CmsWidgetDialog

public class CmsXmlContentEditor extends CmsEditor implements I_CmsWidgetDialog
Creates the editor for XML content definitions.

Since:
6.0.0
  • Field Details

  • Constructor Details

  • Method Details

    • actionChangeElementLanguage

      Performs the change element language action of the editor.

    • 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 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:
      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 IOException, javax.servlet.jsp.JspException, javax.servlet.ServletException
      Performs the exit editor action.

      Specified by:
      actionExit in class CmsEditor
      Throws:
      IOException - if a forward fails
      javax.servlet.jsp.JspException - if including an element fails
      javax.servlet.ServletException - if a forward fails
      See Also:
    • 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 IOException, javax.servlet.jsp.JspException
      Performs the preview XML content action in a new browser window.

      Throws:
      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:
    • actionSave

      public void actionSave(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(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

      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

      Returns the available sub choices for a nested choice element.

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

      public int getButtonStyle()
      Description copied from interface: I_CmsWidgetDialog
      Returns the style setting to use when generating buttons for this widget dialog.

      Specified by:
      getButtonStyle in interface I_CmsWidgetDialog
      Returns:
      the style setting to use when generating buttons for this widget dialog
      See Also:
    • getEditorResourceUri

      Description copied from class: CmsEditor
      Returns the URI to the editor resource folder where button images and javascripts are located.

      Specified by:
      getEditorResourceUri in class CmsEditor
      Returns:
      the URI to the editor resource folder
      See Also:
    • getElementLocale

      Returns the current element locale.

      Returns:
      the current element locale
    • 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:
    • getParamChoiceElement

      Returns the name of the choice element to add.

      Returns:
      the name of the choice element to add
    • 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

      Gets the editor context path (usually either a container page path or null).

      Returns:
      the editor context path
    • getParamElementIndex

      Returns the index of the element to add or remove.

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

      Returns the name of the element to add or remove.

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

      public String getParamMode()
      Returns the mode.

      Returns:
      the mode
    • getParamModelFile

      Returns the parameter that specifies the model file name.

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

      Returns the "new link" parameter.

      Returns:
      the "new link" parameter
    • getParamPostCreateHandler

      Returns the postCreateHandler.

      Returns:
      the postCreateHandler
    • getUserAgent

      public String getUserAgent()
      Description copied from interface: I_CmsWidgetDialog
      Returns the "user-agent" of the current request, or null in case no request is available.

      Specified by:
      getUserAgent in interface I_CmsWidgetDialog
      Returns:
      the "user-agent" of the current request
      See Also:
    • getWidgetCollector

      Returns the different xml editor widgets used in the form to display.

      Returns:
      the different xml editor widgets used in the form to display
    • getXmlEditorForm

      Generates the HTML form for the XML content editor.

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

      public 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 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 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 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(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(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(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(String editContext)
      Sets the edit context URI.

      Parameters:
      editContext - the edit context URI.
    • setParamElementIndex

      public void setParamElementIndex(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(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(String mode)
      Sets the content creation mode.

      Parameters:
      mode - the content creation mode
    • setParamModelFile

      public void setParamModelFile(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(String paramNewLink)
      Sets the "new link" parameter.

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

      public void setParamPostCreateHandler(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
    • useNewStyle

      public boolean useNewStyle()
      Description copied from class: CmsToolDialog
      Tests if we are working with the new administration dialog style.

      The default is the new style, this parameter is not intended for external use.

      Specified by:
      useNewStyle in interface I_CmsWidgetDialog
      Overrides:
      useNewStyle in class CmsToolDialog
      Returns:
      true if using the new style
      See Also:
    • commitTempFile

      protected void commitTempFile() throws CmsException
      Description copied from class: CmsEditor
      Writes the content of a temporary file back to the original file.

      Overrides:
      commitTempFile in class CmsEditor
      Throws:
      CmsException - if something goes wrong
      See Also:
    • ensureLocale

      protected Locale ensureLocale(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.

    • initWorkplaceRequestValues

      protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
      Description copied from class: CmsWorkplace
      Analyzes the request for workplace parameters and adjusts the workplace settings accordingly.

      Overrides:
      initWorkplaceRequestValues in class CmsDialog
      Parameters:
      settings - the workplace settings
      request - the current request
      See Also: