Class CmsDefaultPageEditor

  • Direct Known Subclasses:
    CmsSimplePageEditor

    public abstract class CmsDefaultPageEditor
    extends CmsEditor
    Provides methods for building editors for the CmsDefaultPage page type.

    Extend this class for all editors that work with the CmsDefaultPage.

    Since:
    6.0.0
    • Field Detail

      • SELECTBOX_FONTS

        public static final java.lang.String[] SELECTBOX_FONTS
        option values for font select boxes.
      • m_file

        protected CmsFile m_file
        File object used to read and write contents.
      • m_page

        protected CmsXmlPage m_page
        Page object used from the action and init methods, be sure to initialize this e.g. in the initWorkplaceRequestValues method.
    • Method Detail

      • actionClear

        public void actionClear​(boolean forceUnlock)
        Description copied from class: CmsEditor
        Unlocks the edited resource when in direct edit mode or when the resource was not modified.

        Specified by:
        actionClear in class CmsEditor
        Parameters:
        forceUnlock - if true, the resource will be unlocked anyway
        See Also:
        CmsEditor.actionClear(boolean)
      • 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.jsp.JspException - if including a JSP fails
        javax.servlet.ServletException - if a forward fails
      • actionExit

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

        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()
      • actionPreview

        public void actionPreview()
                           throws java.io.IOException,
                                  javax.servlet.jsp.JspException
        Performs the preview page 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
        Description copied from class: CmsEditor
        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()
      • buildSelectElementLanguage

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

        Parameters:
        attributes - optional attributes for the <select> tag
        Returns:
        the html for the element language selectbox
      • buildSelectElementName

        public java.lang.String buildSelectElementName​(java.lang.String attributes)
        Builds the html String for the element name selector.

        Parameters:
        attributes - optional attributes for the <select> tag
        Returns:
        the html for the element name selectbox
      • buildSelectFonts

        public java.lang.String buildSelectFonts​(java.lang.String attributes)
        Builds the html for the font face select box of a WYSIWYG editor.

        Parameters:
        attributes - optional attributes for the <select> tag
        Returns:
        the html for the font face select box
      • escapeParams

        public void escapeParams()
        Escapes the content and title parameters to display them in the editor form.

        This method has to be called on the JSP right before the form display html is created.

        *

      • getElementLocale

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

        Returns:
        the current element locale
      • getParamElementname

        public java.lang.String getParamElementname()
        Returns the current element name.

        Returns:
        the current element name
      • getParamOldelementname

        public java.lang.String getParamOldelementname()
        Returns the old element name.

        Returns:
        the old element name
      • getUriStyleSheet

        public java.lang.String getUriStyleSheet()
        Returns the OpenCms VFS uri of the style sheet of the current page.

        Returns:
        the OpenCms VFS uri of the style sheet of the current page
      • getUriTemplate

        public java.lang.String getUriTemplate()
        Returns the OpenCms VFS uri of the template of the current page.

        Returns:
        the OpenCms VFS uri of the template of the current page
      • setParamElementname

        public void setParamElementname​(java.lang.String elementName)
        Sets the current element name.

        Parameters:
        elementName - the current element name
      • setParamOldelementname

        public void setParamOldelementname​(java.lang.String oldElementName)
        Sets the old element name.

        Parameters:
        oldElementName - the old element name
      • getElementList

        protected java.util.List<CmsDialogElementgetElementList()
        Returns the list of active elements of the page.

        Returns:
        the list of active elements of the page
      • initBodyElementLanguage

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

      • initBodyElementName

        protected void initBodyElementName​(java.lang.String elementName)
        Initializes the body element name of the editor.

        This has to be called after the element language has been set with setParamBodylanguage().

        Parameters:
        elementName - the name of the element to initialize or null, if default element should be used
      • performSaveContent

        protected void performSaveContent​(java.lang.String body,
                                          java.util.Locale locale)
                                   throws CmsException
        Saves the editor content to the temporary file.

        Parameters:
        body - the body name to write
        locale - the body locale to write
        Throws:
        CmsException - if writing the file fails
      • prepareContent

        protected abstract java.lang.String prepareContent​(boolean save)
        Manipulates the content String for different editor views and the save operation.

        Parameters:
        save - if set to true, the result String is not escaped and the content parameter is not updated
        Returns:
        the prepared content String