Class CmsJspTagEditable

java.lang.Object
javax.servlet.jsp.tagext.TagSupport
javax.servlet.jsp.tagext.BodyTagSupport
org.opencms.jsp.CmsJspTagEditable
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class CmsJspTagEditable extends javax.servlet.jsp.tagext.BodyTagSupport
Implementation of the <cms:editable/> tag.

This class is also used to generate the direct edit buttons for the <cms:include editable="..." /> and <cms:contentload editable="..." /> tags.

Since OpenCms version 6.2.3, the direct edit button HTML generated is controlled by an instance of I_CmsDirectEditProvider. The default direct edit provider used can be configured in opencms-workplace.xml in the <directeditprovider class="..." /> node. The standard provider is CmsDirectEditDefaultProvider. It's possible to override the default provider onm a page-by-page basis by initializing direct edit with <cms:editable provider="...." /> on top of the page.

Since OpenCms version 6.2.3, it is also possible to place the HTML of the direct edit buttons manually. This is intended for pages where the template HTML is not compatible with the direct edit HTML, which usually results in a funny placement of the direct edit buttons in a totally wrong position. To do manual placement of the direct edit buttons, you need to place <cms:editable mode="manual"> and </cms:editable> around your HTML. Both tags (start and end) will insert HTML according to the used I_CmsDirectEditProvider. The direct edit provider used must also support manual placing, or the manual tags will be ignored and the HTML will be inserted at the automatic position. A provider which support manual placing is the CmsDirectEditTextButtonProvider.

Since:
6.0.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    File with editable elements.
    Indicates which direct edit mode is active.
    protected String
    Class name of the direct edit provider.

    Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport

    bodyContent

    Fields inherited from class javax.servlet.jsp.tagext.TagSupport

    id, pageContext

    Fields inherited from interface javax.servlet.jsp.tagext.BodyTag

    EVAL_BODY_BUFFERED, EVAL_BODY_TAG

    Fields inherited from interface javax.servlet.jsp.tagext.IterationTag

    EVAL_BODY_AGAIN

    Fields inherited from interface javax.servlet.jsp.tagext.Tag

    EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Close the direct edit tag, also prints the direct edit HTML to the current page.
    int
    Opens the direct edit tag, if manual mode is set then the next start HTML for the direct edit buttons is printed to the page.
    static void
    editableTagAction(javax.servlet.jsp.PageContext context, String provider, CmsDirectEditMode mode, String fileName)
    Editable action method.
    static void
    endDirectEdit(javax.servlet.jsp.PageContext context)
    Closes the current direct edit element.
    getDirectEditProvider(javax.servlet.jsp.PageContext context)
    Returns the current initialized instance of the direct edit provider.
    protected static CmsDirectEditParams
    getDirectEditProviderParams(javax.servlet.jsp.PageContext context)
    Returns the current initialized instance of the direct edit provider parameters from the given page context.
    Gets the file with elements for direct editing.
    Returns the direct edit mode.
    Returns the class name of the direct edit provider.
    static void
    insertEditEmpty(javax.servlet.jsp.PageContext context, I_CmsXmlContentContainer container, CmsDirectEditMode mode, String id)
    Inserts direct edit for empty collector lists.
    static boolean
    isEditableRequest(javax.servlet.ServletRequest req)
    Checks if the current request should be direct edit enabled.
    boolean
    Returns the edit empty attribute.
    void
    Releases any resources we may have (or inherit).
    protected static void
    setDirectEditProvider(javax.servlet.jsp.PageContext context, I_CmsDirectEditProvider provider)
    Sets the current initialized instance of the direct edit provider.
    protected static void
    setDirectEditProviderParams(javax.servlet.jsp.PageContext context, CmsDirectEditParams params)
    Sets the current initialized instance of the direct edit provider parameters to the page context.
    void
    setEditEmpty(boolean editEmpty)
    Sets the edit empty attribute.
    void
    Sets the file with elements for direct editing.
    void
    Sets the direct edit mode.
    void
    setProvider(String provider)
    Sets the class name of the direct edit provider.
    static boolean
    startDirectEdit(javax.servlet.jsp.PageContext context, CmsDirectEditParams params)
    Includes the "direct edit" start element that adds HTML for the editable area to the output page.

    Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport

    doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent

    Methods inherited from class javax.servlet.jsp.tagext.TagSupport

    findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface javax.servlet.jsp.tagext.Tag

    getParent, setPageContext, setParent
  • Field Details

  • Constructor Details

  • Method Details

    • editableTagAction

      public static void editableTagAction(javax.servlet.jsp.PageContext context, String provider, CmsDirectEditMode mode, String fileName) throws javax.servlet.jsp.JspException
      Editable action method.

      Parameters:
      context - the current JSP page context
      provider - the class name of the direct edit privider to use (may be null, which means use the default)
      mode - the direct edit mode to use (may be null, which means current use mode on page)
      fileName - optional filename parameter for the direct edit provider (may be null, which means use the default)
      Throws:
      javax.servlet.jsp.JspException - in case something goes wrong
    • endDirectEdit

      public static void endDirectEdit(javax.servlet.jsp.PageContext context) throws javax.servlet.jsp.JspException
      Closes the current direct edit element.

      Parameters:
      context - the current JSP page context
      Throws:
      javax.servlet.jsp.JspException - in case something goes wrong
    • getDirectEditProvider

      public static I_CmsDirectEditProvider getDirectEditProvider(javax.servlet.jsp.PageContext context)
      Returns the current initialized instance of the direct edit provider.

      Parameters:
      context - the current JSP page context
      Returns:
      the current initialized instance of the direct edit provider
    • insertEditEmpty

      public static void insertEditEmpty(javax.servlet.jsp.PageContext context, I_CmsXmlContentContainer container, CmsDirectEditMode mode, String id) throws CmsException, javax.servlet.jsp.JspException
      Inserts direct edit for empty collector lists.

      Parameters:
      context - the current JSP page context
      container - the parent content load container
      mode - the direct edit mode to use (may be null, which means current use mode on page)
      id - an id for the content info bean, if available
      Throws:
      CmsException - in case of invalid collector settings
      javax.servlet.jsp.JspException - in case writing to page context fails
    • isEditableRequest

      public static boolean isEditableRequest(javax.servlet.ServletRequest req)
      Checks if the current request should be direct edit enabled.

      Parameters:
      req - the servlet request
      Returns:
      true if the current request should be direct edit enabled
    • startDirectEdit

      public static boolean startDirectEdit(javax.servlet.jsp.PageContext context, CmsDirectEditParams params) throws javax.servlet.jsp.JspException
      Includes the "direct edit" start element that adds HTML for the editable area to the output page.

      Parameters:
      context - the current JSP page context
      params - the direct edit parameters
      Returns:
      true in case a direct edit element has been opened
      Throws:
      javax.servlet.jsp.JspException - in case something goes wrong
    • getDirectEditProviderParams

      protected static CmsDirectEditParams getDirectEditProviderParams(javax.servlet.jsp.PageContext context)
      Returns the current initialized instance of the direct edit provider parameters from the given page context.

      Also removes the parameters from the given page context.

      Parameters:
      context - the current JSP page context
      Returns:
      the current initialized instance of the direct edit provider parameters
    • setDirectEditProvider

      protected static void setDirectEditProvider(javax.servlet.jsp.PageContext context, I_CmsDirectEditProvider provider)
      Sets the current initialized instance of the direct edit provider.

      Parameters:
      context - the current JSP page context
      provider - the current initialized instance of the direct edit provider to set
    • setDirectEditProviderParams

      protected static void setDirectEditProviderParams(javax.servlet.jsp.PageContext context, CmsDirectEditParams params)
      Sets the current initialized instance of the direct edit provider parameters to the page context.

      Parameters:
      context - the current JSP page context
      params - the current initialized instance of the direct edit provider parameters to set
    • doEndTag

      public int doEndTag() throws javax.servlet.jsp.JspException
      Close the direct edit tag, also prints the direct edit HTML to the current page.

      Specified by:
      doEndTag in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
      Returns:
      Tag.EVAL_PAGE
      Throws:
      javax.servlet.jsp.JspException - in case something goes wrong
    • doStartTag

      public int doStartTag() throws javax.servlet.jsp.JspException
      Opens the direct edit tag, if manual mode is set then the next start HTML for the direct edit buttons is printed to the page.

      Specified by:
      doStartTag in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
      Returns:
      Tag.EVAL_BODY_INCLUDE
      Throws:
      javax.servlet.jsp.JspException - in case something goes wrong
    • getFile

      public String getFile()
      Gets the file with elements for direct editing.

      Returns:
      the file
    • getMode

      public String getMode()
      Returns the direct edit mode.

      Returns:
      the direct edit mode
    • getProvider

      public String getProvider()
      Returns the class name of the direct edit provider.

      Returns:
      the class name of the direct edit provider
    • isEditEmpty

      public boolean isEditEmpty()
      Returns the edit empty attribute.

      Returns:
      the edit empty attribute
    • release

      public void release()
      Releases any resources we may have (or inherit).

      Specified by:
      release in interface javax.servlet.jsp.tagext.Tag
      Overrides:
      release in class javax.servlet.jsp.tagext.BodyTagSupport
    • setEditEmpty

      public void setEditEmpty(boolean editEmpty)
      Sets the edit empty attribute.

      Parameters:
      editEmpty - the edit empty attribute to set
    • setFile

      public void setFile(String file)
      Sets the file with elements for direct editing.

      Parameters:
      file - the file to set
    • setMode

      public void setMode(String mode)
      Sets the direct edit mode.

      Parameters:
      mode - the direct edit mode to set
    • setProvider

      public void setProvider(String provider)
      Sets the class name of the direct edit provider.

      Parameters:
      provider - the class name of the direct edit provider to set