|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.workplace.CmsWorkplace
org.opencms.workplace.tools.CmsToolDialog
org.opencms.workplace.CmsDialog
org.opencms.workplace.CmsWidgetDialog
public abstract class CmsWidgetDialog
Base class for dialogs that use the OpenCms widgets without XML content.
Field Summary | |
---|---|
static int |
ACTION_ELEMENT_ADD
Action for optional element creation. |
static int |
ACTION_ELEMENT_REMOVE
Action for optional element removal. |
static int |
ACTION_ERROR
Value for the action: error in the form validation. |
static int |
ACTION_SAVE
Value for the action: save the dialog. |
static java.lang.String |
DIALOG_SAVE
Request parameter value for the action: save the dialog. |
static java.lang.String |
EDITOR_ACTION_ELEMENT_ADD
Indicates an optional element should be created. |
static java.lang.String |
EDITOR_ACTION_ELEMENT_REMOVE
Indicates an optional element should be removed. |
static java.lang.String |
HIDDEN_PARAM_PREFIX
Prefix for "hidden" parameters, required since these must be unescaped later. |
protected java.util.List |
m_commitErrors
The errors thrown by commit actions. |
protected java.lang.Object |
m_dialogObject
The object edited with this widget dialog. |
protected java.util.List |
m_pages
The allowed pages for this dialog in a List. |
protected java.lang.String |
m_paramPage
Controls which page is currently displayed in the dialog. |
protected java.util.List |
m_validationErrorList
The validation errors for the input form. |
protected java.util.Map |
m_widgetParamValues
Contains all parameter value of this dialog. |
protected java.util.List |
m_widgets
The list of widgets used on the dialog. |
Fields inherited from class org.opencms.workplace.tools.CmsToolDialog |
---|
PARAM_BASE, PARAM_FORCE, PARAM_PATH, PARAM_ROOT, PARAM_STYLE, STYLE_NEW |
Constructor Summary | |
---|---|
CmsWidgetDialog(CmsJspActionElement jsp)
Public constructor with JSP action element. |
|
CmsWidgetDialog(javax.servlet.jsp.PageContext context,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Public constructor with JSP variables. |
Method Summary | |
---|---|
void |
actionCancel()
Deletes the edited dialog object from the session. |
abstract void |
actionCommit()
Commits the edited object after pressing the "OK" button. |
void |
actionToggleElement()
Adds or removes an optional element. |
protected void |
addCommitError(java.lang.Exception error)
Adds the given error to the list of errors that are thrown by save actions or form generation. |
protected void |
addWidget(CmsWidgetDialogParameter param)
Adds a new widget parameter definition to the list of all widgets of this dialog. |
java.lang.String |
buildAddElement(java.lang.String elementName,
int insertAfter,
boolean enabled)
Returns the html for a button to add an optional element. |
java.lang.String |
buildDialogForm()
Builds the HTML for the dialog form. |
java.lang.String |
buildRemoveElement(java.lang.String elementName,
int index,
boolean enabled)
Returns the html for a button to remove an optional element. |
void |
clearDialogObject()
Clears the "dialog object" for this widget dialog by removing it from the current users session. |
protected boolean |
closeDialogOnCommit()
Returns true if the dialog should be closed after the values have been committed. |
protected java.util.List |
commitWidgetValues()
Commits all values on the dialog. |
protected java.util.List |
commitWidgetValues(java.lang.String dialogPage)
Commits all values on the given dialog page. |
protected java.lang.String |
createDialogHtml()
Creates the dialog HTML for all defined widgets of this dialog. |
protected java.lang.String |
createDialogHtml(java.lang.String dialog)
Creates the dialog HTML for all defined widgets of the named dialog (page). |
protected java.lang.String |
createDialogRowHtml(CmsWidgetDialogParameter base)
Creates the dialog HTML for all occurrences of one widget parameter. |
protected java.lang.String |
createDialogRowsHtml(int startIndex,
int endIndex)
Creates the dialog widget rows HTML for the specified widget indices. |
protected java.lang.String |
createWidgetBlockEnd()
Creates the complete widget dialog end block HTML that finishes a widget block. |
protected java.lang.String |
createWidgetBlockStart(java.lang.String headline)
Create the complete widget dialog start block HTML that begins a widget block with optional headline. |
protected java.lang.String |
createWidgetErrorHeader()
Creates the HTML for the error message if validation errors were found. |
protected java.lang.String |
createWidgetTableEnd()
Creates the HTML for the table around the dialog widgets. |
protected java.lang.String |
createWidgetTableStart()
Creates the HTML to close the table around the dialog widgets. |
protected java.lang.String |
defaultActionHtml()
Generates the dialog starting html code. |
protected java.lang.String |
defaultActionHtmlContent()
Returns the html code for the default action content. |
protected java.lang.String |
defaultActionHtmlEnd()
Generates the dialog ending html code. |
protected java.lang.String |
defaultActionHtmlStart()
Generates the dialog starting html code. |
protected abstract void |
defineWidgets()
Defines the list of parameters for this dialog. |
java.lang.String |
dialogBlockEnd()
Builds the end HTML for a block with 3D border in the dialog content area. |
java.lang.String |
dialogBlockStart(java.lang.String headline)
Builds the start HTML for a block with 3D border and optional subheadline in the dialog content area. |
java.lang.String |
dialogButtonsCustom()
Creates the HTML for the buttons on the dialog. |
void |
displayDialog()
Performs the dialog actions depending on the initialized action and displays the dialog form. |
void |
displayDialog(boolean writeLater)
Performs the dialog actions depending on the initialized action and displays the dialog form if needed. |
protected void |
fillWidgetValues(javax.servlet.http.HttpServletRequest request)
Fills all widgets of this widget dialog with the values from the request parameters. |
int |
getButtonStyle()
Returns the style setting to use when generating buttons for this widget dialog. |
java.util.List |
getCommitErrors()
Returns the errors that are thrown by save actions or form generation. |
java.lang.Object |
getDialogObject()
Returns the dialog object for this widget dialog, or null
if no dialog object has been set. |
protected java.lang.String |
getDialogTitle()
Returns the title for this Dialog. |
java.util.Set |
getHelpMessageIds()
Returns a set of help messages ids that are already included on the widget dialog. |
protected abstract java.lang.String[] |
getPageArray()
Returns the allowed pages for this dialog. |
protected java.util.List |
getPages()
Returns the allowed pages for this dialog. |
java.lang.String |
getParamElementIndex()
Returns the index of the element to add or remove. |
java.lang.String |
getParamElementName()
Returns the name of the element to add or remove. |
protected CmsWidgetDialogParameter |
getParameterDefinition(java.lang.String name)
Returns the parameter widget definition for the given parameter name. |
protected java.util.Map |
getParameters()
Returns the map with the widget parameter values. |
java.lang.String |
getParamPage()
Returns the page parameter. |
java.lang.String |
getParamValue(java.lang.String name)
Returns the value of the widget parameter with the given name, or null
if no such widget parameter is available. |
java.lang.String |
getParamValue(java.lang.String name,
int index)
Returns the value of the widget parameter with the given name and index, or null
if no such widget parameter is available. |
java.lang.String |
getUserAgent()
Returns the "user-agent" of the current request, or null in case no
request is available. |
protected java.util.List |
getValidationErrorList()
Returns the validation errors for the dialog. |
protected java.lang.String |
getWidget(CmsWidgetDialogParameter param)
Returns the widget HTML code for the given parameter. |
java.lang.String |
getWidgetHtmlEnd()
Generates the HTML for the end of the widget dialog. |
java.lang.String |
getWidgetIncludes()
Generates the HTML include tags for external JavaScripts files of the used widgets. |
java.lang.String |
getWidgetInitCalls()
Generates the JavaScript init calls for the used widgets. |
java.lang.String |
getWidgetInitMethods()
Generates the JavaScript initialization methods for the used widgets. |
protected java.util.List |
getWidgets()
Returns the list of all widgets used on this widget dialog, the List must contain Objects of type . |
protected boolean |
hasCommitErrors()
Returns true if the current dialog (page) has commit errors. |
protected boolean |
hasValidationErrors()
Returns true if the current dialog (page) has validation errors. |
protected void |
initWorkplaceRequestValues(CmsWorkplaceSettings settings,
javax.servlet.http.HttpServletRequest request)
Analyzes the request for workplace parameters and adjusts the workplace settings accordingly. |
java.lang.String |
paramsAsHidden()
Returns all initialized parameters of the current workplace class as hidden field tags that can be inserted in a form. |
protected void |
setCommitErrors(java.util.List errors)
Sets the errors that are thrown by save actions or form generation. |
void |
setDialogObject(java.lang.Object dialogObject)
Stores the given object as "dialog object" for this widget dialog in the current users session. |
protected void |
setKeyPrefix(java.lang.String prefix)
Sets an optional localized key prefix identificator for all widgets. |
protected void |
setPages(java.util.List pages)
Sets the allowed pages for this dialog. |
void |
setParamElementIndex(java.lang.String elementIndex)
Sets the index of the element to add or remove. |
void |
setParamElementName(java.lang.String elementName)
Sets the name of the element to add or remove. |
void |
setParamPage(java.lang.String paramPage)
Sets the page parameter. |
protected void |
setValidationErrorList(java.util.List errors)
Sets the validation errors for the dialog. |
protected void |
validateParamaters()
Should be overridden for parameter validation. |
java.lang.String |
widgetParamsAsHidden()
Returns the values of all widget parameters of this dialog as HTML hidden fields. |
java.lang.String |
widgetParamsAsHidden(java.lang.String excludeDialogPage)
Returns the values of all widget parameters of this dialog as HTML hidden fields, excluding the widget values that are on the given dialog page. |
void |
writeDialog()
Writes the dialog html code, only if the is set. |
Methods inherited from class org.opencms.workplace.tools.CmsToolDialog |
---|
dialogTitle, getAdminTool, getCurrentToolPath, getParamBase, getParamForce, getParamPath, getParamRoot, getParamStyle, getParentPath, getToolManager, iconsBlockArea, iconsBlockAreaEnd, iconsBlockAreaStart, initAdminTool, pageBody, pageHtmlStyle, setParamBase, setParamForce, setParamPath, setParamRoot, setParamStyle, useNewStyle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.opencms.widgets.I_CmsWidgetDialog |
---|
button, buttonBar, buttonBarHorizontalLine, buttonBarSeparator, buttonBarSpacer, buttonBarStartTab, dialogHorizontalSpacer, getLocale, getMessages, useNewStyle |
Field Detail |
---|
public static final int ACTION_ELEMENT_ADD
public static final int ACTION_ELEMENT_REMOVE
public static final int ACTION_ERROR
public static final int ACTION_SAVE
public static final java.lang.String DIALOG_SAVE
public static final java.lang.String EDITOR_ACTION_ELEMENT_ADD
public static final java.lang.String EDITOR_ACTION_ELEMENT_REMOVE
public static final java.lang.String HIDDEN_PARAM_PREFIX
protected java.util.List m_commitErrors
protected java.lang.Object m_dialogObject
protected java.util.List m_pages
protected java.lang.String m_paramPage
protected java.util.List m_validationErrorList
protected java.util.Map m_widgetParamValues
protected java.util.List m_widgets
Constructor Detail |
---|
public CmsWidgetDialog(CmsJspActionElement jsp)
jsp
- an initialized JSP action elementpublic CmsWidgetDialog(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
context
- the JSP page contextreq
- the JSP requestres
- the JSP responseMethod Detail |
---|
public void actionCancel()
public abstract void actionCommit() throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
- in case of errors forwarding to the required result page
javax.servlet.ServletException
- in case of errors forwarding to the required result pagepublic void actionToggleElement()
Depends on the value stored in the
method.CmsDialog.getAction()
public java.lang.String buildAddElement(java.lang.String elementName, int insertAfter, boolean enabled)
elementName
- name of the elementinsertAfter
- the index of the element after which the new element should be createdenabled
- if true, the button to add an element is shown, otherwise a spacer is returned
public java.lang.String buildDialogForm()
public java.lang.String buildRemoveElement(java.lang.String elementName, int index, boolean enabled)
elementName
- name of the elementindex
- the element index of the element to removeenabled
- if true, the button to remove an element is shown, otherwise a spacer is returned
public void clearDialogObject()
public java.lang.String dialogBlockEnd()
dialogBlockEnd
in class CmsDialog
public java.lang.String dialogBlockStart(java.lang.String headline)
dialogBlockStart
in class CmsDialog
headline
- the headline String for the block
public java.lang.String dialogButtonsCustom()
public void displayDialog() throws javax.servlet.jsp.JspException, java.io.IOException, javax.servlet.ServletException
javax.servlet.jsp.JspException
- if dialog actions fail
java.io.IOException
- if writing to the JSP out fails, or in case of errors forwarding to the required result page
javax.servlet.ServletException
- in case of errors forwarding to the required result pagepublic void displayDialog(boolean writeLater) throws javax.servlet.jsp.JspException, java.io.IOException, javax.servlet.ServletException
writeLater
- if true
no output is written,
you have to call manually the defaultActionHtml()
method.
javax.servlet.jsp.JspException
- if dialog actions fail
java.io.IOException
- if writing to the JSP out fails, or in case of errors forwarding to the required result page
javax.servlet.ServletException
- in case of errors forwarding to the required result pagepublic int getButtonStyle()
I_CmsWidgetDialog
getButtonStyle
in interface I_CmsWidgetDialog
I_CmsWidgetDialog.getButtonStyle()
public java.util.List getCommitErrors()
public java.lang.Object getDialogObject()
null
if no dialog object has been set.
null
public java.util.Set getHelpMessageIds()
I_CmsWidgetDialog
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.
getHelpMessageIds
in interface I_CmsWidgetDialog
I_CmsWidgetDialog.getHelpMessageIds()
public java.lang.String getParamElementIndex()
public java.lang.String getParamElementName()
public java.lang.String getParamPage()
public java.lang.String getParamValue(java.lang.String name)
null
if no such widget parameter is available.
name
- the widget parameter name to get the value for
public java.lang.String getParamValue(java.lang.String name, int index)
null
if no such widget parameter is available.
name
- the widget parameter name to get the value forindex
- the widget parameter index
public java.lang.String getUserAgent()
I_CmsWidgetDialog
null
in case no
request is available.
getUserAgent
in interface I_CmsWidgetDialog
I_CmsWidgetDialog.getUserAgent()
public java.lang.String getWidgetHtmlEnd()
This HTML includes additional components, for example the <div> tags containing the help texts.
public java.lang.String getWidgetIncludes() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- if an error occurs during JavaScript generationpublic java.lang.String getWidgetInitCalls() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- the JavaScript init calls for the used widgetspublic java.lang.String getWidgetInitMethods() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- if an error occurs during JavaScript generationpublic java.lang.String paramsAsHidden()
CmsWorkplace
paramsAsHidden
in class CmsWorkplace
CmsWorkplace.paramsAsHidden()
public void setDialogObject(java.lang.Object dialogObject)
dialogObject
- the object to storepublic void setParamElementIndex(java.lang.String elementIndex)
elementIndex
- the index of the element to add or removepublic void setParamElementName(java.lang.String elementName)
elementName
- the name of the element to add or removepublic void setParamPage(java.lang.String paramPage)
paramPage
- the page parameter to setpublic java.lang.String widgetParamsAsHidden()
CmsWorkplace.paramsAsHidden()
public java.lang.String widgetParamsAsHidden(java.lang.String excludeDialogPage)
This can be used to create multi-page dialogs where the values are passed from one page to another before everything is submitted. If a widget A is used on page X, there should be no "hidden" HTML field for A since otherwise A would have 2 values when submitting the dialog page: The one from the widget itself and the one from the hidden field. This may lead to undefined results when processing the submitted values.
excludeDialogPage
- the dialog page to exclude the values for
CmsWorkplace.paramsAsHidden()
public void writeDialog() throws java.io.IOException, javax.servlet.jsp.JspException
CmsDialog.ACTION_DEFAULT
is set.
javax.servlet.jsp.JspException
- if dialog actions fail
java.io.IOException
- if writing to the JSP out fails, or in case of errors forwarding to the required result pageprotected void addCommitError(java.lang.Exception error)
If the error list has not been initialized yet, this is done automatically.
error
- the errors to addprotected void addWidget(CmsWidgetDialogParameter param)
param
- the widget parameter definition to addprotected boolean closeDialogOnCommit()
true
if the dialog should be closed after the values have been committed.
The default implementation returns true
in case there are no
commit errors.
true
if the dialog should be closed after the values have been committedprotected java.util.List commitWidgetValues()
protected java.util.List commitWidgetValues(java.lang.String dialogPage)
dialogPage
- the dialog (page) to commit
protected java.lang.String createDialogHtml()
protected java.lang.String createDialogHtml(java.lang.String dialog)
To get a more complex layout variation, you have to overwrite this method in your dialog class.
dialog
- the dialog (page) to get the HTML for
protected java.lang.String createDialogRowHtml(CmsWidgetDialogParameter base)
base
- the widget parameter base
protected java.lang.String createDialogRowsHtml(int startIndex, int endIndex)
startIndex
- the widget index to start withendIndex
- the widget index to stop at
protected java.lang.String createWidgetBlockEnd()
protected java.lang.String createWidgetBlockStart(java.lang.String headline)
headline
- the headline String for the block
protected java.lang.String createWidgetErrorHeader()
protected java.lang.String createWidgetTableEnd()
protected java.lang.String createWidgetTableStart()
protected java.lang.String defaultActionHtml() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- if something goes wrongprotected java.lang.String defaultActionHtmlContent()
protected java.lang.String defaultActionHtmlEnd()
protected java.lang.String defaultActionHtmlStart() throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- if something goes wrongprotected abstract void defineWidgets()
protected void fillWidgetValues(javax.servlet.http.HttpServletRequest request)
request
- the current HTTP servlet requestprotected java.lang.String getDialogTitle()
In the default implementation this method returns null
.
Override this if needed.
null
if this dialog has no titleprotected abstract java.lang.String[] getPageArray()
protected java.util.List getPages()
protected CmsWidgetDialogParameter getParameterDefinition(java.lang.String name)
name
- the parameter name to get the definition for
protected java.util.Map getParameters()
protected java.util.List getValidationErrorList()
The method (@link CmsWidgetDialog#commitWidgetValues(String)) has to set this list.
protected java.lang.String getWidget(CmsWidgetDialogParameter param)
param
- the name (id) of the parameter to get the widget HTML for
protected java.util.List getWidgets()
CmsWidgetDialogParameter
.
protected boolean hasCommitErrors()
true
if the current dialog (page) has commit errors.
true
if the current dialog (page) has commit errorsprotected boolean hasValidationErrors()
true
if the current dialog (page) has validation errors.
true
if the current dialog (page) has validation errorsprotected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, javax.servlet.http.HttpServletRequest request)
CmsWorkplace
initWorkplaceRequestValues
in class CmsDialog
settings
- the workplace settingsrequest
- the current requestCmsWorkplace.initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
protected void setCommitErrors(java.util.List errors)
errors
- the errors that are thrown by save actions or form generationprotected void setKeyPrefix(java.lang.String prefix)
prefix
- the optional localized key prefix identificator for all widgetsI_CmsWidgetParameter.setKeyPrefix(java.lang.String)
protected void setPages(java.util.List pages)
pages
- the allowed pages for this dialogprotected void setValidationErrorList(java.util.List errors)
Use this in the method (@link CmsWidgetDialog#commitWidgetValues(String)) to set the list.
errors
- the validation errorsprotected void validateParamaters() throws java.lang.Exception
The exception is never seen by the user, so it can be just a new
.Exception
()
java.lang.Exception
- if the parameters are not valid
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |