Package org.opencms.workplace
Class CmsWidgetDialogParameter
- java.lang.Object
-
- org.opencms.workplace.CmsWidgetDialogParameter
-
- All Implemented Interfaces:
org.opencms.widgets.I_CmsWidgetParameter
public class CmsWidgetDialogParameter extends java.lang.Object implements org.opencms.widgets.I_CmsWidgetParameter
Implements the widget parameter interface for the use of OpenCms widgets on dialogs that are not based on XML contents.- Since:
- 6.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_DIALOG_PAGE
The name of the default dialog page.protected java.lang.Object
m_baseCollection
The (optional) base collection for read / writing collection based parameters.protected java.lang.Object
m_baseObject
The (optional) base object for read / writing the parameter value to.protected java.lang.String
m_baseObjectProperty
The (optinal) object property to read / write this parameter value to.protected java.lang.String
m_defaultValue
The default value of the parameter.protected java.lang.String
m_dialogPage
The name of the dialog (page) the widget is used on.protected java.lang.Throwable
m_error
Indicates if the widget value has an error.protected java.lang.String
m_id
The id of the parameter on the form.protected int
m_index
The index of this parameter in the (optional) list of parameters.protected int
m_maxOccurs
The maximum number of occurences of this parameter.protected int
m_minOccurs
The minimum number of occurences of this parameter.protected java.lang.String
m_name
The name of the parameter.protected java.lang.String
m_prefix
Optional localized key prefix identificator.protected java.lang.String
m_value
The value of the parameter.protected org.opencms.widgets.I_CmsWidget
m_widget
The widget used for the parameter.static int
MAX_OCCURENCES
The maximum number of occurences of a widget dialog element in a list of elements.
-
Constructor Summary
Constructors Constructor Description CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String htmlName, java.lang.String defaultValue, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter based on a given object's property.CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String htmlName, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String defaultValue, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter based on a given object's property.CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.CmsWidgetDialogParameter(java.lang.String value, java.lang.String defaultValue, java.lang.String name, org.opencms.widgets.I_CmsWidget widget, java.lang.String dialog, int minOccurs, int maxOccurs, int index)
Create a new Widget parameter with specified occurence settings.CmsWidgetDialogParameter(java.lang.String name, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter.CmsWidgetDialogParameter(java.lang.String name, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter.CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index)
Create a new Widget parameter.CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index, int originalIndex)
Create a new Widget parameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commitValue(CmsWidgetDialog dialog)
"Commits" (writes) the value of this widget back to the underlying base object.static java.lang.String
createId(java.lang.String name, int index)
Returns a from id representation for the given widget name and id.java.lang.String
getDefault(org.opencms.file.CmsObject cms)
java.lang.String
getDialogPage()
Returns the name of the dialog (or dialog page) this widget parameter is used on.java.lang.Throwable
getError()
Returns the Exception caused when this parameter value was commited, ornull
if error occurred.java.lang.String
getId()
int
getIndex()
java.lang.String
getKey()
int
getMaxOccurs()
int
getMinOccurs()
java.lang.String
getName()
java.lang.String
getStringValue(org.opencms.file.CmsObject cms)
org.opencms.widgets.I_CmsWidget
getWidget()
Returns the widget for this parameter.boolean
hasError()
boolean
hasValue(int index)
Checks if a value for this widget base type with the given id is available.protected void
init(java.lang.String value, java.lang.String defaultValue, java.lang.String name, org.opencms.widgets.I_CmsWidget widget, java.lang.String dialog, int minOccurs, int maxOccurs, int index)
Initializes a widget parameter with the given values.boolean
isCollectionBase()
Returnstrue
if this widget parameter is mapped to a Collection base object.void
prepareCommit()
Prepares this widget dialog parameter to be committed.void
setError(java.lang.Throwable error)
Sets the error state of this widget.void
setindex(int index)
Sets the index to the provided value.void
setKeyPrefix(java.lang.String prefix)
void
setStringValue(org.opencms.file.CmsObject cms, java.lang.String value)
-
-
-
Field Detail
-
DEFAULT_DIALOG_PAGE
public static final java.lang.String DEFAULT_DIALOG_PAGE
The name of the default dialog page.- See Also:
- Constant Field Values
-
MAX_OCCURENCES
public static final int MAX_OCCURENCES
The maximum number of occurences of a widget dialog element in a list of elements.- See Also:
- Constant Field Values
-
m_baseCollection
protected java.lang.Object m_baseCollection
The (optional) base collection for read / writing collection based parameters.
-
m_baseObject
protected java.lang.Object m_baseObject
The (optional) base object for read / writing the parameter value to.
-
m_baseObjectProperty
protected java.lang.String m_baseObjectProperty
The (optinal) object property to read / write this parameter value to.
-
m_defaultValue
protected java.lang.String m_defaultValue
The default value of the parameter.
-
m_dialogPage
protected java.lang.String m_dialogPage
The name of the dialog (page) the widget is used on.
-
m_error
protected java.lang.Throwable m_error
Indicates if the widget value has an error.
-
m_id
protected java.lang.String m_id
The id of the parameter on the form.
-
m_index
protected int m_index
The index of this parameter in the (optional) list of parameters.
-
m_maxOccurs
protected int m_maxOccurs
The maximum number of occurences of this parameter.
-
m_minOccurs
protected int m_minOccurs
The minimum number of occurences of this parameter.
-
m_name
protected java.lang.String m_name
The name of the parameter.
-
m_prefix
protected java.lang.String m_prefix
Optional localized key prefix identificator.
-
m_value
protected java.lang.String m_value
The value of the parameter.
-
m_widget
protected org.opencms.widgets.I_CmsWidget m_widget
The widget used for the parameter.
-
-
Constructor Detail
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index)
Create a new Widget parameter.- Parameters:
base
- the base of the parameterindex
- the index of this parameter in the list
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index, int originalIndex)
Create a new Widget parameter.- Parameters:
base
- the base of the parameterindex
- the index of this parameter in the listoriginalIndex
- the original index in the previous version of the list
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.- Parameters:
base
- the base object to map the parameter to / fromproperty
- the base object property to map the parameter to / fromwidget
- the widget used for this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.- Parameters:
base
- the base object to map the parameter to / fromproperty
- the base object property to map the parameter to / fromdialogPage
- the dialog page to use the widget onwidget
- the widget used for this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String htmlName, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter based on a given object's property.- Parameters:
base
- the base object to map the parameter to / fromproperty
- the base object property to map the parameter to / fromhtmlName
- the form id name to use in the generated HTMLdialogPage
- the dialog page to use the widget onwidget
- the widget used for this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String defaultValue, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter based on a given object's property.- Parameters:
base
- the base object to map the parameter to / fromproperty
- the base object property to map the parameter to / fromdefaultValue
- the default value to use for this parameterdialogPage
- the dialog page to use the widget onwidget
- the widget used for this parameteminOccurs
- the required minimum numer of occurences of this parametermaxOccurs
- the maximum allowed numer of occurences of this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.Object base, java.lang.String property, java.lang.String htmlName, java.lang.String defaultValue, java.lang.String dialogPage, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter based on a given object's property.- Parameters:
base
- the base object to map the parameter to / fromproperty
- the base object property to map the parameter to / fromhtmlName
- the form id name to use in the generated HTMLdefaultValue
- the default value to use for this parameterdialogPage
- the dialog page to use the widget onwidget
- the widget used for this parameteminOccurs
- the required minimum numer of occurences of this parametermaxOccurs
- the maximum allowed numer of occurences of this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.String name, org.opencms.widgets.I_CmsWidget widget)
Create a new Widget parameter.- Parameters:
name
- the name of the parameterwidget
- the widget used for this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.String name, org.opencms.widgets.I_CmsWidget widget, int minOccurs, int maxOccurs)
Create a new Widget parameter.- Parameters:
name
- the name of the parameterwidget
- the widget used for this parameterminOccurs
- the required minimum numer of occurences of this parametermaxOccurs
- the maximum allowed numer of occurences of this parameter
-
CmsWidgetDialogParameter
public CmsWidgetDialogParameter(java.lang.String value, java.lang.String defaultValue, java.lang.String name, org.opencms.widgets.I_CmsWidget widget, java.lang.String dialog, int minOccurs, int maxOccurs, int index)
Create a new Widget parameter with specified occurence settings.- Parameters:
value
- the initial value of the parameterdefaultValue
- the default value of the parametername
- the id of the parameterwidget
- the widget used for this parameterdialog
- the dialog this parameter is used onminOccurs
- the required minimum numer of occurences of this parametermaxOccurs
- the maximum allowed numer of occurences of this parameterindex
- the index of this parameter in the list
-
-
Method Detail
-
createId
public static java.lang.String createId(java.lang.String name, int index)
Returns a from id representation for the given widget name and id.- Parameters:
name
- the widget parameter nameindex
- the widget parameter index- Returns:
- a from id representation for the given widget name and id
-
commitValue
public void commitValue(CmsWidgetDialog dialog) throws org.opencms.main.CmsException
"Commits" (writes) the value of this widget back to the underlying base object.- Parameters:
dialog
- the widget dialog where the parameter is used on- Throws:
org.opencms.main.CmsException
- in case the String value of the widget is invalid for the base Object
-
getDefault
public java.lang.String getDefault(org.opencms.file.CmsObject cms)
- Specified by:
getDefault
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getDefault(org.opencms.file.CmsObject)
-
getDialogPage
public java.lang.String getDialogPage()
Returns the name of the dialog (or dialog page) this widget parameter is used on.This information can be used to create multi-page dialogs where the widgets are spread over several pages.
- Returns:
- the name of the dialog (or dialog page) this widget parameter is used on
-
getError
public java.lang.Throwable getError()
Returns the Exception caused when this parameter value was commited, ornull
if error occurred.- Returns:
- the Exception caused when this parameter value was commited
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getId()
-
getIndex
public int getIndex()
- Specified by:
getIndex
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getIndex()
-
getKey
public java.lang.String getKey()
- Specified by:
getKey
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getKey()
-
getMaxOccurs
public int getMaxOccurs()
- Specified by:
getMaxOccurs
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getMaxOccurs()
-
getMinOccurs
public int getMinOccurs()
- Specified by:
getMinOccurs
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getMinOccurs()
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.getName()
-
getStringValue
public java.lang.String getStringValue(org.opencms.file.CmsObject cms) throws org.opencms.main.CmsRuntimeException
- Specified by:
getStringValue
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- Throws:
org.opencms.main.CmsRuntimeException
- See Also:
I_CmsWidgetParameter.getStringValue(org.opencms.file.CmsObject)
-
getWidget
public org.opencms.widgets.I_CmsWidget getWidget()
Returns the widget for this parameter.- Returns:
- the widget for this parameter
-
hasError
public boolean hasError()
- Specified by:
hasError
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.hasError()
-
hasValue
public boolean hasValue(int index)
Checks if a value for this widget base type with the given id is available.This should only be used if the base object is a collection.
- Parameters:
index
- the index to check- Returns:
true
if a value for this widget base type with the given id is available
-
isCollectionBase
public boolean isCollectionBase()
Returnstrue
if this widget parameter is mapped to a Collection base object.- Returns:
true
if this widget parameter is mapped to a Collection base object
-
prepareCommit
public void prepareCommit()
Prepares this widget dialog parameter to be committed.This is required if the base type is mapped to a Collection object, because the collection needs to be cleared before the new values are set.
-
setError
public void setError(java.lang.Throwable error)
Sets the error state of this widget.If the argument is
null
then the state is set to "no error".- Parameters:
error
- the error state to set
-
setindex
public void setindex(int index)
Sets the index to the provided value.- Parameters:
index
- the new index value to set
-
setKeyPrefix
public void setKeyPrefix(java.lang.String prefix)
- Specified by:
setKeyPrefix
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- See Also:
I_CmsWidgetParameter.setKeyPrefix(java.lang.String)
-
setStringValue
public void setStringValue(org.opencms.file.CmsObject cms, java.lang.String value) throws org.opencms.main.CmsIllegalArgumentException
- Specified by:
setStringValue
in interfaceorg.opencms.widgets.I_CmsWidgetParameter
- Throws:
org.opencms.main.CmsIllegalArgumentException
- See Also:
I_CmsWidgetParameter.setStringValue(org.opencms.file.CmsObject, java.lang.String)
-
init
protected void init(java.lang.String value, java.lang.String defaultValue, java.lang.String name, org.opencms.widgets.I_CmsWidget widget, java.lang.String dialog, int minOccurs, int maxOccurs, int index)
Initializes a widget parameter with the given values.- Parameters:
value
- the initial value of the parameterdefaultValue
- the default value of the parametername
- the id of the parameterwidget
- the widget used for this parameterdialog
- the dialog this parameter is used onminOccurs
- the required minimum numer of occurences of this parametermaxOccurs
- the maximum allowed numer of occurences of this parameterindex
- the index of this parameter in the list
-
-