Class XSelect
- java.lang.Object
-
- de.xima.fc.form.common.items.XSelect
-
- All Implemented Interfaces:
IXDataSourceOptions,IXItem,IXItemBasic,IXValuableItem
public class XSelect extends Object implements IXItem, IXValuableItem, IXDataSourceOptions
Form element handler for select items. A select item allows the user to choose one of the available options. It can be configured to allow only one option or multiple options. It offers different layouts, such as a dropdown select or a list of check boxes or radio buttons.- Author:
- XIMA MEDIA GmbH
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.LoggerLOG
-
Constructor Summary
Constructors Constructor Description XSelect()Creates a new item handler for a select form element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,List<org.apache.commons.lang3.Range<Integer>>>getAllowedDataSourceParameterCount()Use this method to indicate how many parameters each data source type must have in order to be selectable.ArrayList<XItemPropertyDesc>getAvailableProperties(Locale locale)Gets a list of base properties available for this item.IXItemFieldNameConventionsgetFieldNameConventions()Gets the naming conventions for the form fields used by this type of form item.StringgetIcon()StringgetPrefix()Finds the prefix for form items of this type, such ascbfor checkboxes ortffor input fields.booleanisShouldRenderForAttributeOnLabel(XItemRenderData renderData)Whether theforshould be added to the label of this element, if this element does have a label.booleanisShouldRenderUnit(XItemRenderData renderData)Whether theXPropertyEnum.unitshould be rendered.protected booleanisShowDefaultOption(XItemRenderData renderData)booleanisSubmitsValues()Checks whether form items of this type can send values to the server when the form is submitted.voidrenderItem(com.hp.gagawa.java.elements.Div container, XItemRenderData renderData, XItemRenderCtx renderCtx, IXFormRenderContext formRenderCtx)Creates the HTML for this form item that is included in the final rendered form.voidrenderItemPreview(com.hp.gagawa.java.elements.Div container, XItemRenderData renderData, XItemRenderCtx renderCtx, IXFormRenderContext formRenderCtx)Similar to theIXItemBasic.renderItem(Div, XItemRenderData, XItemRenderCtx, IXFormRenderContext)method, but this is called when the form is viewed in the designer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.xima.fc.form.common.models.IXItemBasic
getAutoReRender, isShowInDrawerPanel, isShowInElementSelect, processUpload, validate, validate, validateGlobal
-
-
-
-
Method Detail
-
getAvailableProperties
public ArrayList<XItemPropertyDesc> getAvailableProperties(Locale locale)
Description copied from interface:IXItemBasicGets a list of base properties available for this item.Note that plugins may extend these properties. Use
de.xima.fc.web.common.fd2.XItemPropertiesHelper#getAvailablePropertiesto get a list of all properties, including properties added by plugins.Note: Caching the properties returned by this method is not required. Just create the list of properties and return it.
- Specified by:
getAvailablePropertiesin interfaceIXItemBasic- Parameters:
locale- The current locale that can be used for locale dependent properties.- Returns:
- A list of all base properties available for this item.
-
isShowDefaultOption
protected boolean isShowDefaultOption(XItemRenderData renderData)
-
isShouldRenderUnit
public boolean isShouldRenderUnit(XItemRenderData renderData)
Description copied from interface:IXItemBasicWhether theXPropertyEnum.unitshould be rendered. Note that the unit is rendered only when the item contains the propertyXPropertyEnum.unitand its value is not empty. However, some elements may sometimes not support a unit. For example,XSelectonly support a unit when the it is rendered as a combo box, but not when rendered as a list of checkboxes. In these cases, you can override this method with an appropriate implementation. The default implementation simply returnstrue.- Specified by:
isShouldRenderUnitin interfaceIXItemBasic- Parameters:
renderData- The current render data with the properties and options of the item.- Returns:
truewhen theXPropertyEnum.unitshould be rendered, orfalseotherwise.
-
isShouldRenderForAttributeOnLabel
public boolean isShouldRenderForAttributeOnLabel(XItemRenderData renderData)
Description copied from interface:IXItemBasicWhether theforshould be added to the label of this element, if this element does have a label. The W3C spec requires that theforpoints to a non-hidden form control element (e.g. aninputortextarea). Defaults totrue.- Specified by:
isShouldRenderForAttributeOnLabelin interfaceIXItemBasic- Parameters:
renderData- The current render data with the properties and options of the item.- Returns:
- Whether to include the
forin the label.
-
getIcon
public String getIcon()
- Specified by:
getIconin interfaceIXItemBasic- Returns:
- The CSS class for the icon of this form item, such as for example
ico-fc-XCheckbox.
-
getPrefix
public String getPrefix()
Description copied from interface:IXItemBasicFinds the prefix for form items of this type, such ascbfor checkboxes ortffor input fields. This prefix is used, for example, in the designer to generate a default name for newly added form items (tf-1,cb-2).- Specified by:
getPrefixin interfaceIXItemBasic- Returns:
- The prefix for form items of this type.
-
isSubmitsValues
public boolean isSubmitsValues()
Description copied from interface:IXItemBasicChecks whether form items of this type can send values to the server when the form is submitted. Form items that do not submit values are, for example, not validated and no values are ever stored in the database. Form items such as pictures or charts do no submit values, while classical form elements such as input fields and checkboxes are a prime example of form items that do submit values.- Specified by:
isSubmitsValuesin interfaceIXItemBasic- Returns:
- Whether form element of this type can send values to the server when the form is submitted.
-
renderItem
public void renderItem(com.hp.gagawa.java.elements.Div container, XItemRenderData renderData, XItemRenderCtx renderCtx, IXFormRenderContext formRenderCtx)Description copied from interface:IXItemBasicCreates the HTML for this form item that is included in the final rendered form. You should append one or more HTML elements to the container that is passed to this method.- Specified by:
renderItemin interfaceIXItemBasic- Parameters:
container- The container that will contain this form item in the final form. You should append children to this container.renderData- The current render data with the properties and options of the item.renderCtx- The current render context giving you access to the global configuration.formRenderCtx- The form render context giving you access to the global form configuration.- See Also:
IXItemBasic.renderItemPreview(Div, XItemRenderData, XItemRenderCtx, IXFormRenderContext)
-
renderItemPreview
public void renderItemPreview(com.hp.gagawa.java.elements.Div container, XItemRenderData renderData, XItemRenderCtx renderCtx, IXFormRenderContext formRenderCtx)Description copied from interface:IXItemBasicSimilar to theIXItemBasic.renderItem(Div, XItemRenderData, XItemRenderCtx, IXFormRenderContext)method, but this is called when the form is viewed in the designer. You can, if necessary, render the form slightly differently in the desigern. This is useful, for example, when when you do not want users to be able to interact with the form element directly in the designer preview area.- Specified by:
renderItemPreviewin interfaceIXItemBasic- Parameters:
container- The container that will contain this form item in the final form. You should append children to this container.renderData- The current render data with the properties and options of the item.renderCtx- The current render context giving you access to the global configuration.formRenderCtx- The form render context giving you access to the global form configuration.- See Also:
IXItemBasic.renderItem(Div, XItemRenderData, XItemRenderCtx, IXFormRenderContext)
-
getAllowedDataSourceParameterCount
public Map<String,List<org.apache.commons.lang3.Range<Integer>>> getAllowedDataSourceParameterCount()
Description copied from interface:IXDataSourceOptionsUse this method to indicate how many parameters each data source type must have in order to be selectable. For example, the default XSelect form element lets the user select CSV, DB and PLUGIN data sources with no parameters:@Override public Map<String, List<Range<Integer>>> getAllowedDataSourceParameterCount() { final Map<String, List<Range<Integer>>> ranges = new HashMap<>(); ranges.put(EDatasource.CSV.name(), Arrays.asList(Range.is(0))); ranges.put(EDatasource.DB.name(), Arrays.asList(Range.is(0))); ranges.put(EDatasource.PLUGIN.name(), Arrays.asList(Range.is(0))); return ranges; }- Specified by:
getAllowedDataSourceParameterCountin interfaceIXDataSourceOptions- Returns:
- A map between each data source type as the key and a list of allowed parameter counts (inclusive range) as
the value. When
nullis returned, the defaults (which may change) are used. When a key for a data source type is missing or is mapped tonull, no data sources of that type are selectable.
-
getFieldNameConventions
public IXItemFieldNameConventions getFieldNameConventions()
Description copied from interface:IXItemBasicGets the naming conventions for the form fields used by this type of form item. The default assumption is that in the rendered form, only a single form field (such as<input>) exists, with the name as configured in the form designer. The default implementation returnsDefaultXItemFieldNameConventions, which is suitable for such form items.Some form items may have more complex naming conventions. For example, an upload form item could have a secondary input field for storing the UUID of the upload; and the name of that derived input field could e.g. be the configured name (e.g.
upl1) plus some suffix (e.g.upl1.uuid). Other form could have more derived field names with various data, as is the case for e.g. the builtin appointment picker form item with various related field names suchapp1_date,app1_time,app1_date_time, orapp1.typeuuidetc.This method must return the field name conventions for such items, so that these conventions can be respected and enforced by formcycle. formcycle must be aware of the naming conventions for various reason, e.g. in order to be able to reject submitted request values when the request value belongs to a form item that is unavailable
in a certain stateorfor certain user groups.- Specified by:
getFieldNameConventionsin interfaceIXItemBasic- Returns:
- The naming conventions for this type of item. A
nullvalue is treated as ifDefaultXItemFieldNameConventionshad been returned.
-
-