org.opencms.frontend.templateone.form
Class CmsSelectWidgetXmlcontentType

java.lang.Object
  extended by org.opencms.widgets.A_CmsWidget
      extended by org.opencms.widgets.A_CmsSelectWidget
          extended by org.opencms.widgets.CmsSelectWidget
              extended by org.opencms.frontend.templateone.form.CmsSelectWidgetXmlcontentType
All Implemented Interfaces:
org.opencms.widgets.I_CmsWidget

public class CmsSelectWidgetXmlcontentType
extends org.opencms.widgets.CmsSelectWidget

A select widget that recursively collects all CmsXmlContent resources of a given type (name) under a given path and creates select options that contain the xmlcontents field value specified by a name (xpath) as display String and the xmlcontents path (given) as the value.

The configuration String has to be of the following form:

    "folder=<vfspath>|displayOptionMacro=<macro>|resourcetypeName=<typename>|sortMacro=<macro>[|propertyname=propertyvalue]*
 
where
    <macro>
 
is a String containing valid OpenCms macros or xpath expression in the form:
 "You are viewing: %(property.Title) "
 
or
 "%(xpath.Firstname) %(xpath.Lastname), Nocakla inc."
 
in which the xpath macros will be replaced with A_CmsXmlDocument.getValue(String, Locale)
    <vfspath>
 
is a valid resource path to a folder in the VFS where search is started from,
    <typename>
 
is a resource type name defined in opencms-modules.xml and
    [|propertyname = propertyvalue]*
 
is a arbitrary number of properties value mappings that have to exist on the resources to show.

Please note

Since:
6.1.3

Field Summary
static java.lang.String CONFIGURATION_OPTION_DISPLAY_MACRO
          Configuration parameter for construction of the option display value by a macro containing xpath macros for the xmlcontent.
static java.lang.String CONFIGURATION_OPTION_SORT_MACRO
          Configuration parameter for choosing the macro to sort the display options by.
static java.lang.String CONFIGURATION_RESOURCETYPENAME
          Configuration parameter to set the name of the resource types to accept.
static java.lang.String CONFIGURATION_TOPFOLDER
          Configuration parameter to set the top folder in the VFS to search for xmlcontent resources.
protected  org.opencms.file.CmsObject m_macroCmsObject
          Only used for the macro resolver to resolve macros for the collected XML contents.
protected  org.opencms.util.CmsMacroResolver m_macroResolver
          The macro resolver to use.
 
Fields inherited from class org.opencms.widgets.A_CmsWidget
HELP_POSTFIX, LABEL_PREFIX
 
Constructor Summary
CmsSelectWidgetXmlcontentType()
          Creates an unconfigured widget that has to be configured by A_CmsWidget.setConfiguration(String) before any html output API call is triggered.
CmsSelectWidgetXmlcontentType(java.lang.String configuration)
          Creates an instance with the given configuration.
 
Method Summary
 java.lang.String getDisplayOptionMacro()
          Returns the displayOptionXpathMacro.
 org.opencms.file.CmsResource getResourceFolder()
          Returns the resourceFolder under which xmlcontent resources will be investigated recursively.
 int getResourceTypeID()
          Returns the resource type id.
 org.opencms.widgets.I_CmsWidget newInstance()
           
protected  java.util.List parseSelectOptions(org.opencms.file.CmsObject cms, org.opencms.widgets.I_CmsWidgetDialog widgetDialog, org.opencms.widgets.I_CmsWidgetParameter param)
          Returns the list of configured select options, parsing the configuration String if required.
 
Methods inherited from class org.opencms.widgets.CmsSelectWidget
getDialogWidget, getWidgetStringValue
 
Methods inherited from class org.opencms.widgets.A_CmsSelectWidget
addSelectOption, getConfiguration, getSelectedValue, getSelectedValues, getSelectOptions, setSelectOptions
 
Methods inherited from class org.opencms.widgets.A_CmsWidget
equals, getDialogHtmlEnd, getDialogIncludes, getDialogInitCall, getDialogInitMethod, getHelpBubble, getHelpKey, getHelpText, getJsHelpMouseHandler, getJSIncludeFile, getLabelKey, hashCode, setConfiguration, setEditorValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_OPTION_DISPLAY_MACRO

public static final java.lang.String CONFIGURATION_OPTION_DISPLAY_MACRO
Configuration parameter for construction of the option display value by a macro containing xpath macros for the xmlcontent.

See Also:
Constant Field Values

CONFIGURATION_OPTION_SORT_MACRO

public static final java.lang.String CONFIGURATION_OPTION_SORT_MACRO
Configuration parameter for choosing the macro to sort the display options by.

See Also:
Constant Field Values

CONFIGURATION_RESOURCETYPENAME

public static final java.lang.String CONFIGURATION_RESOURCETYPENAME
Configuration parameter to set the name of the resource types to accept.

See Also:
Constant Field Values

CONFIGURATION_TOPFOLDER

public static final java.lang.String CONFIGURATION_TOPFOLDER
Configuration parameter to set the top folder in the VFS to search for xmlcontent resources.

See Also:
Constant Field Values

m_macroCmsObject

protected org.opencms.file.CmsObject m_macroCmsObject
Only used for the macro resolver to resolve macros for the collected XML contents.


m_macroResolver

protected org.opencms.util.CmsMacroResolver m_macroResolver
The macro resolver to use.

Constructor Detail

CmsSelectWidgetXmlcontentType

public CmsSelectWidgetXmlcontentType()
Creates an unconfigured widget that has to be configured by A_CmsWidget.setConfiguration(String) before any html output API call is triggered.


CmsSelectWidgetXmlcontentType

public CmsSelectWidgetXmlcontentType(java.lang.String configuration)
Creates an instance with the given configuration.

Parameters:
configuration - see the class description for the format
Method Detail

getDisplayOptionMacro

public java.lang.String getDisplayOptionMacro()
Returns the displayOptionXpathMacro.

Returns:
the displayOptionXpathMacro

getResourceFolder

public org.opencms.file.CmsResource getResourceFolder()
Returns the resourceFolder under which xmlcontent resources will be investigated recursively.

Returns:
the resourceFolder

getResourceTypeID

public int getResourceTypeID()
Returns the resource type id.

Returns:
the resourceTypeID

newInstance

public org.opencms.widgets.I_CmsWidget newInstance()
Specified by:
newInstance in interface org.opencms.widgets.I_CmsWidget
Overrides:
newInstance in class org.opencms.widgets.CmsSelectWidget
See Also:
CmsSelectWidget.newInstance()

parseSelectOptions

protected java.util.List parseSelectOptions(org.opencms.file.CmsObject cms,
                                            org.opencms.widgets.I_CmsWidgetDialog widgetDialog,
                                            org.opencms.widgets.I_CmsWidgetParameter param)
                                     throws org.opencms.main.CmsIllegalArgumentException
Returns the list of configured select options, parsing the configuration String if required.

Overrides:
parseSelectOptions in class org.opencms.widgets.A_CmsSelectWidget
Parameters:
cms - the current users OpenCms context
widgetDialog - the dialog of this widget
param - the widget parameter of this dialog
Returns:
the list of configured select options.
Throws:
org.opencms.main.CmsIllegalArgumentException - if the "folder" property of the configuration does not denote a folder within the VFS
See Also:
A_CmsSelectWidget.parseSelectOptions(org.opencms.file.CmsObject, org.opencms.widgets.I_CmsWidgetDialog, org.opencms.widgets.I_CmsWidgetParameter)