Class CmsDialog

Direct Known Subclasses:
A_CmsAjaxGallery, CmsDialogCopyLanguage, CmsDialogElements, CmsEditorBase, CmsExplorerDialog, CmsLoginUserAgreement, CmsOpenGallery, CmsOpenGallery, CmsPreEditorAction

public class CmsDialog extends CmsToolDialog
Provides methods for building the dialog windows of OpenCms.

Since:
6.0.0
  • Field Details

  • Constructor Details

    • CmsDialog

      Public constructor with JSP action element.

      Parameters:
      jsp - an initialized JSP action element
    • CmsDialog

      public CmsDialog(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      Public constructor with JSP variables.

      Parameters:
      context - the JSP page context
      req - the JSP request
      res - the JSP response
  • Method Details

    • initCmsDialog

      public static CmsDialog initCmsDialog(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
      Returns an initialized CmsDialog instance that is read from the request attributes.

      This method is used by dialog elements. The dialog elements do not initialize their own workplace class, but use the initialized instance of the "master" class. This is required to ensure that parameters of the "master" class can properly be kept on the dialog elements.

      To prevent null pointer exceptions, an empty dialog is returned if nothing is found in the request attributes.

      Parameters:
      context - the JSP page context
      req - the JSP request
      res - the JSP response
      Returns:
      an initialized CmsDialog instance that is read from the request attributes
    • actionCloseDialog

      public void actionCloseDialog() throws javax.servlet.jsp.JspException
      Used to close the current JSP dialog.

      This method tries to include the URI stored in the workplace settings. This URI is determined by the frame name, which has to be set in the frame name parameter.

      Throws:
      javax.servlet.jsp.JspException - if including an element fails
    • buildAjaxResultContainer

      Returns the html code to build the ajax report container.

      Parameters:
      title - the title of the report box
      Returns:
      html code
    • buildLockAdditionalOptions

      Override to display additional options in the lock dialog.

      Returns:
      html code to display additional options
    • buildLockConfirmationMessageJS

      Returns the html code to build the confirmation messages.

      Returns:
      html code
    • buildLockHeaderBox

      Returns the html code to build the header box.

      Returns:
      html code
      Throws:
      CmsException - if something goes wrong
    • dialog

      public String dialog(int segment, String attributes)
      Builds the outer dialog window border.

      Parameters:
      segment - the HTML segment (START / END)
      attributes - optional additional attributes for the opening dialog table
      Returns:
      a dialog window start / end segment
    • dialogBlock

      public String dialogBlock(int segment, String headline, boolean error)
      Builds a block with 3D border and optional subheadline in the dialog content area.

      Parameters:
      segment - the HTML segment (START / END)
      headline - the headline String for the block
      error - if true, an error block will be created
      Returns:
      3D block start / end segment
    • dialogBlockEnd

      Builds the end HTML for a block with 3D border in the dialog content area.

      Returns:
      3D block start / end segment
    • dialogBlockStart

      public String dialogBlockStart(String headline)
      Builds the start HTML for a block with 3D border and optional subheadline in the dialog content area.

      Parameters:
      headline - the headline String for the block
      Returns:
      3D block start / end segment
    • dialogButtonRow

      public String dialogButtonRow(int segment)
      Builds the button row under the dialog content area without the buttons.

      Parameters:
      segment - the HTML segment (START / END)
      Returns:
      the button row start / end segment
    • dialogButtonRowEnd

      Builds the end of the button row under the dialog content area without the buttons.

      Returns:
      the button row end segment
    • dialogButtonRowStart

      Builds the start of the button row under the dialog content area without the buttons.

      Returns:
      the button row start segment
    • dialogButtons

      public String dialogButtons(int[] buttons, String[] attributes)
      Builds the html for the button row under the dialog content area, including buttons.

      Parameters:
      buttons - array of constants of which buttons to include in the row
      attributes - array of Strings for additional button attributes
      Returns:
      the html for the button row under the dialog content area, including buttons
    • dialogButtonsClose

      Builds a button row with a single "close" button.

      Returns:
      the button row
    • dialogButtonsClose

      public String dialogButtonsClose(String closeAttribute)
      Builds a button row with a single "close" button.

      Parameters:
      closeAttribute - additional attributes for the "close" button
      Returns:
      the button row
    • dialogButtonsCloseDetails

      public String dialogButtonsCloseDetails(String closeAttribute, String detailsAttribute)
      Builds a button row with a "close" and a "details" button.

      Parameters:
      closeAttribute - additional attributes for the "close" button
      detailsAttribute - additional attributes for the "details" button
      Returns:
      the button row
    • dialogButtonsOk

      Builds a button row with a single "ok" button.

      Returns:
      the button row
    • dialogButtonsOk

      public String dialogButtonsOk(String okAttribute)
      Builds a button row with a single "ok" button.

      Parameters:
      okAttribute - additional attributes for the "ok" button
      Returns:
      the button row
    • dialogButtonsOkCancel

      Builds a button row with an "ok" and a "cancel" button.

      Returns:
      the button row
    • dialogButtonsOkCancel

      public String dialogButtonsOkCancel(String okAttributes, String cancelAttributes)
      Builds a button row with an "ok" and a "cancel" button.

      Parameters:
      okAttributes - additional attributes for the "ok" button
      cancelAttributes - additional attributes for the "cancel" button
      Returns:
      the button row
    • dialogButtonsOkCancelAdvanced

      public String dialogButtonsOkCancelAdvanced(String okAttributes, String cancelAttributes, String advancedAttributes)
      Builds a button row with an "ok", a "cancel" and an "advanced" button.

      Parameters:
      okAttributes - additional attributes for the "ok" button
      cancelAttributes - additional attributes for the "cancel" button
      advancedAttributes - additional attributes for the "advanced" button
      Returns:
      the button row
    • dialogButtonsSetOkCancel

      public String dialogButtonsSetOkCancel(String setAttributes, String okAttributes, String cancelAttributes)
      Builds a button row with a "set", an "ok", and a "cancel" button.

      Parameters:
      setAttributes - additional attributes for the "set" button
      okAttributes - additional attributes for the "ok" button
      cancelAttributes - additional attributes for the "cancel" button
      Returns:
      the button row
    • dialogContent

      public String dialogContent(int segment, String title)
      Builds the content area of the dialog window.

      Parameters:
      segment - the HTML segment (START / END)
      title - the title String for the dialog window
      Returns:
      a content area start / end segment
    • dialogContentEnd

      Returns the end html for the content area of the dialog window.

      Returns:
      the end html for the content area of the dialog window
    • dialogContentStart

      Returns the start html for the content area of the dialog window.

      Parameters:
      title - the title for the dialog
      Returns:
      the start html for the content area of the dialog window
    • dialogEnd

      public String dialogEnd()
      Returns the end html for the outer dialog window border.

      Returns:
      the end html for the outer dialog window border
    • dialogHead

      public String dialogHead(String title)
      Builds the title of the dialog window.

      Parameters:
      title - the title String for the dialog window
      Returns:
      the HTML title String for the dialog window
    • dialogHorizontalSpacer

      public String dialogHorizontalSpacer(int width)
      Builds an invisible horizontal spacer with the specified width.

      Parameters:
      width - the width of the spacer in pixels
      Returns:
      an invisible horizontal spacer with the specified width
    • dialogLockButtons

      Builds the necessary button row.

      Returns:
      the button row
    • dialogRow

      public String dialogRow(int segment)
      Builds a dialog line without break (display: block).

      Parameters:
      segment - the HTML segment (START / END)
      Returns:
      a row start / end segment
    • dialogRowEnd

      public String dialogRowEnd()
      Builds the end of a dialog line without break (display: block).

      Returns:
      the row end segment
    • dialogRowStart

      Builds the start of a dialog line without break (display: block).

      Returns:
      the row start segment
    • dialogScriptSubmit

      Builds the standard javascript for submitting the dialog.

      Overrides:
      dialogScriptSubmit in class CmsToolDialog
      Returns:
      the standard javascript for submitting the dialog
    • dialogSeparator

      Builds a horizontal separator line in the dialog content area.

      Returns:
      a separator element
    • dialogSpacer

      public String dialogSpacer()
      Builds a space between two elements in the dialog content area.

      Returns:
      a space element
    • dialogStart

      public String dialogStart()
      Returns the start html for the outer dialog window border.

      Returns:
      the start html for the outer dialog window border
    • dialogStart

      public String dialogStart(String attributes)
      Returns the start html for the outer dialog window border.

      Parameters:
      attributes - optional html attributes to insert
      Returns:
      the start html for the outer dialog window border
    • dialogSubheadline

      public String dialogSubheadline(String headline)
      Builds a subheadline in the dialog content area.

      Parameters:
      headline - the desired headline string
      Returns:
      a subheadline element
    • dialogToggleStart

      public String dialogToggleStart(String headline, String id, boolean show)
      Builds the HTML code to fold and unfold a white-box.

      Parameters:
      headline - the heading to display
      id - the id of the toggle
      show - true if the white box is open at the beginning
      Returns:
      HTML code to fold and unfold a white-box
    • dialogWhiteBox

      public String dialogWhiteBox(int segment)
      Builds a white box in the dialog content area.

      Parameters:
      segment - the HTML segment (START / END)
      Returns:
      the white box start / end segment
    • dialogWhiteBoxEnd

      Builds the end of a white box in the dialog content area.

      Returns:
      the white box end segment
    • dialogWhiteBoxStart

      Builds the start of a white box in the dialog content area.

      Returns:
      the white box start segment
    • getAction

      public int getAction()
      Returns the action value.

      The action value is used on JSP pages to select the proper action in a large "switch" statement.

      Returns:
      the action value
    • getCancelAction

      Returns the action to be carried out after a click on the cancel button..

      Returns:
      the action to be carried out after a click on the cancel button.
    • getDialogRealUri

      Returns the http URI of the current dialog, to be used as value for the "action" attribute of a html form.

      This URI is the real one.

      Returns:
      the http URI of the current dialog
    • getDialogUri

      public String getDialogUri()
      Returns the http URI of the current dialog, to be used as value for the "action" attribute of a html form.

      This URI could not be really the real one...

      Returns:
      the http URI of the current dialog
    • getOnlineHelpUriCustom

      Returns the custom mapping for the online help.

      Returns:
      the custom mapping for the online help
    • getParamAction

      Returns the value of the action parameter, or null if this parameter was not provided.

      The action parameter is very important, it will select the dialog action to perform. The value of the getAction() method will be initialized from the action parameter.

      Returns:
      the value of the action parameter
    • getParamCloseLink

      Returns the value of the close link parameter, or null if this parameter was not provided.

      Returns:
      the value of the close link parameter
    • getParamDialogtype

      Returns the value of the dialog type parameter, or null if this parameter was not provided.

      This parameter is very important. It must match to the localization keys, e.g. "copy" for the copy dialog.

      This parameter must be set manually by the subclass during first initialization.

      Returns:
      the value of the dialog type parameter
    • getParamFramename

      Returns the value of the frame name parameter.

      Returns:
      the value of the frame name parameter
    • getParamIsPopup

      Returns the is popup parameter.

      Use this parameter to indicate that the dialog is shown in a popup window.

      Returns:
      the is popup parameter
    • getParamMessage

      Returns the value of the message parameter, or null if this parameter was not provided.

      The message parameter is used on dialogs to show any text message.

      Returns:
      the value of the message parameter
    • getParamOriginalParams

      Returns the value of the original parameters parameter.

      This stores the request parameter values from a previous dialog, if necessary.

      Returns:
      the value of the original parameters parameter
    • getParamPreActionDone

      Returns the value of the preaction done parameter.

      Returns:
      the value of the preaction done parameter
    • getParamRedirect

      Returns the value of the redirect flag parameter.

      Returns:
      the value of the redirect flag parameter
    • getParamResource

      Returns the value of the file parameter, or null if this parameter was not provided.

      The file parameter selects the file on which the dialog action is to be performed.

      Returns:
      the value of the file parameter
    • getParamTitle

      Returns the value of the title parameter, or null if this parameter was not provided.

      This parameter is used to build the title of the dialog. It is a parameter so that the title can be passed to included elements.

      Returns:
      the value of the title parameter
    • getState

      public String getState() throws CmsException
      Gets a formatted file state string.

      Returns:
      formatted state string
      Throws:
      CmsException - if something goes wrong
    • hasCorrectLockstate

      public boolean hasCorrectLockstate()
      Checks if the current resource has lock state exclusive or inherited.

      This is used to determine whether the dialog shows the option to delete all siblings of the resource or not.

      Returns:
      true if lock state is exclusive or inherited, otherwise false
    • hasSiblings

      public boolean hasSiblings()
      Checks if this resource has siblings.

      Returns:
      true if this resource has siblings
    • htmlStart

      public String htmlStart()
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      Returns:
      the start html of the page
    • htmlStart

      public String htmlStart(String helpUrl)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Overrides:
      htmlStart in class CmsWorkplace
      Parameters:
      helpUrl - the key for the online help to include on the page
      Returns:
      the start html of the page
    • htmlStart

      public String htmlStart(String helpUrl, String title)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      Parameters:
      helpUrl - the key for the online help to include on the page
      title - the title for the page
      Returns:
      the start html of the page
    • htmlStartStyle

      public String htmlStartStyle(String title, String stylesheet)
      Builds the start html of the page, including setting of DOCTYPE, inserting a header with the content-type and choosing an individual style sheet.

      Parameters:
      title - the title for the page
      stylesheet - the style sheet to include
      Returns:
      the start html of the page
    • includeErrorpage

      public void includeErrorpage(CmsWorkplace wp, Throwable t) throws javax.servlet.jsp.JspException
      Displays the throwable on the error page and logs the error.

      Parameters:
      wp - the workplace class
      t - the throwable to be displayed on the error page
      Throws:
      javax.servlet.jsp.JspException - if the include of the error page jsp fails
    • isPopup

      public boolean isPopup()
      Returns the "isPopup" flag.

      Returns:
      the "isPopup" flag
    • isPreEditor

      public boolean isPreEditor()
      Returns if the dialog is called in direct edit mode before the editor is opened.

      Returns:
      true if the dialog is called in direct edit mode before the editor is opened
    • pageHtml

      public String pageHtml(int segment, String helpUrl)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Overrides:
      pageHtml in class CmsWorkplace
      Parameters:
      segment - the HTML segment (START / END)
      helpUrl - the url for the online help to include on the page
      Returns:
      the start html of the page
    • pageHtml

      public String pageHtml(int segment, String helpUrl, String title)
      Builds the start html of the page, including setting of DOCTYPE and inserting a header with the content-type.

      This overloads the default method of the parent class.

      Parameters:
      segment - the HTML segment (START / END)
      helpUrl - the url for the online help to include on the page
      title - the title for the page
      Returns:
      the start html of the page
    • setOnlineHelpUriCustom

      public void setOnlineHelpUriCustom(String uri)
      Set the custom mapping for the online help.

      This value will be set to a javascript variable called onlineHelpUriCustom. If it is set, the top.head javascript for the online help will use this value.

      This method should be called from initWorkplaceRequestValues(CmsWorkplaceSettings, HttpServletRequest), CmsWorkplace.initWorkplaceMembers(CmsJspActionElement) or from the jsp if the dialog class is used for several actions. It should be used whenever the online help mapping does not work (due to jsp - forwards).

      Parameters:
      uri - the left hand value in mapping.properties for the online help pages
    • setParamAction

      public void setParamAction(String value)
      Sets the value of the action parameter.

      Parameters:
      value - the value to set
    • setParamCloseLink

      public void setParamCloseLink(String value)
      Sets the value of the close link parameter.

      Parameters:
      value - the value to set
    • setParamDialogtype

      public void setParamDialogtype(String value)
      Sets the value of the dialog type parameter.

      Parameters:
      value - the value to set
    • setParamFramename

      public void setParamFramename(String value)
      Sets the value of the frame name parameter.

      Parameters:
      value - the value to set
    • setParamIsPopup

      public void setParamIsPopup(String value)
      Sets the is popup parameter.

      Parameters:
      value - the is popup parameter value
    • setParamMessage

      public void setParamMessage(String value)
      Sets the value of the message parameter.

      Parameters:
      value - the value to set
    • setParamOriginalParams

      public void setParamOriginalParams(String paramOriginalParams)
      Sets the value of the original parameters parameter.

      Parameters:
      paramOriginalParams - the value of the original parameters parameter
    • setParamPreActionDone

      public void setParamPreActionDone(String paramPreActionDone)
      Sets the value of the preaction done parameter.

      Parameters:
      paramPreActionDone - the value of the preaction done parameter
    • setParamRedirect

      public void setParamRedirect(String redirect)
      Sets the value of the redirect flag parameter.

      Parameters:
      redirect - the value of the redirect flag parameter
    • setParamResource

      public void setParamResource(String value)
      Sets the value of the file parameter.

      Parameters:
      value - the value to set
    • setParamTitle

      public void setParamTitle(String value)
      Sets the value of the title parameter.

      Parameters:
      value - the value to set
    • appendDelimiter

      protected String appendDelimiter(String attribute)
      Appends a space char. between tag attributes.

      Parameters:
      attribute - a tag attribute
      Returns:
      the tag attribute with a leading space char
    • buildAjaxWaitMessage

      Returns ajax wait message.

      Returns:
      html code
    • checkResourcePermissions

      protected boolean checkResourcePermissions(CmsPermissionSet required, boolean neededForFolder)
      Checks if the permissions of the current user on the resource to use in the dialog are sufficient.

      Automatically generates a CmsMessageContainer object with an error message and stores it in the users session.

      Parameters:
      required - the required permissions for the dialog
      neededForFolder - if true, the permissions are required for the parent folder of the resource (e.g. for editors)
      Returns:
      true if the permissions are sufficient, otherwise false
    • checkResourcePermissions

      protected boolean checkResourcePermissions(CmsPermissionSet required, boolean neededForFolder, CmsMessageContainer errorMessage)
      Checks if the permissions of the current user on the resource to use in the dialog are sufficient.

      Automatically generates a CmsMessageContainer object with an error message and stores it in the users session.

      Parameters:
      required - the required permissions for the dialog
      neededForFolder - if true, the permissions are required for the parent folder of the resource (e.g. for editors)
      errorMessage - the message container that is stored in the session in case the permissions are not sufficient
      Returns:
      true if the permissions are sufficient, otherwise false
    • computeCurrentFolder

      Returns the full path of the current workplace folder.

      Returns:
      the full path of the current workplace folder
    • dialogButtonsHtml

      protected void dialogButtonsHtml(StringBuffer result, int button, String attribute)
      Renders the HTML for a single input button of a specified type.

      Parameters:
      result - a string buffer where the rendered HTML gets appended to
      button - a integer key to identify the button
      attribute - an optional string with possible tag attributes, or null
    • getAdministrationBackLink

      Returns the link URL to get back one folder in the administration view.

      Returns:
      the link URL to get back one folder in the administration view
    • 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 CmsToolDialog
      Parameters:
      settings - the workplace settings
      request - the current request
      See Also:
    • openLaunchpad

      protected void openLaunchpad() throws javax.servlet.jsp.JspException
      Opens the launch pad view.

      Throws:
      javax.servlet.jsp.JspException - in case writing to the JSP output stream fails
    • openWorkplaceLink

      protected void openWorkplaceLink(String workplaceLink) throws IOException
      Opens a workplace UI link in the top frame.

      Parameters:
      workplaceLink - the workplace link to open
      Throws:
      IOException - in case writing to the JSP output stream fails
    • setAction

      protected void setAction(int value)
      Sets the action value.

      Parameters:
      value - the action value