Class ContextParameter

Object
ContextParameter
All Implemented Interfaces:
Serializable

public class ContextParameter extends Object implements Serializable
This class represents the input parameter, the input field. So you can use it to set its label, default value, if required, etc.
See Also:
  • Constructor Details

    • ContextParameter

      public ContextParameter()
    • ContextParameter

      public ContextParameter(InputType type, String name, Date targetDate, PersistedObjectService objService)
    • ContextParameter

      public ContextParameter(InputType type, String name, Object value)
    • ContextParameter

      public ContextParameter(LookupTable lt, Date targetDate)
    • ContextParameter

      public ContextParameter(LookupTable lt, Date targetDate, String defaultValue)
    • ContextParameter

      public ContextParameter(String name, DMFieldCollection fc, String field, String defaultValue)
  • Method Details

    • updateFromFormulaInputDescriptor

      public void updateFromFormulaInputDescriptor(FormulaInputDescriptor fid)
    • addParameterConfigEntry

      public void addParameterConfigEntry(String key, Object value)
      Technically the same functionality as setConfigParameter(String, Object).
      Parameters:
      key -
      value -
      See Also:
    • updateWithLookupTable

      public void updateWithLookupTable(LookupTable lt)
      This is a convenience method to update a ContextParameter with a new version of the same lookup table This can happen e.g. if a quote is worked on a while and passes a validity date border or an old quote is copied
      Parameters:
      lt -
    • isLookupType

      public boolean isLookupType()
    • isCustomerParam

      public final boolean isCustomerParam()
    • isProductParam

      public final boolean isProductParam()
    • isProductGroupParam

      public final boolean isProductGroupParam()
    • isMatrixParam

      public final boolean isMatrixParam()
    • isOptionParam

      public final boolean isOptionParam()
    • isOptionsParam

      public final boolean isOptionsParam()
    • isHiddenParam

      public final boolean isHiddenParam()
    • isRequired

      public Boolean isRequired()
    • setRequired

      public ContextParameter setRequired(Boolean required)
      Sets, if it's mandatory for the input parameter to have a value. The value can be either entered by user or a default value. If the input value is required, but not provided, then it's usually somehow expressed on the screen (usually exclamation mark).

      In case of Quote, all required fields must be populated, otherwise you cannot submit the Quote for approval.

      Parameters:
      required - If the input value will be required or not.
    • getName

      public String getName()
    • getLabel

      public String getLabel()
    • setLabel

      public ContextParameter setLabel(String label)
      Sets the label of the input parameter to the given text.
      Parameters:
      label - The text to be displayed as label of the input field.
    • getLabelTranslations

      public String getLabelTranslations()
    • setLabelTranslationsFromMap

      public ContextParameter setLabelTranslationsFromMap(Map<String,String> translations)
    • setLabelTranslations

      public ContextParameter setLabelTranslations(String labelTranslations)
    • getFilter

      public Map<String,Object> getFilter()
    • setFilter

      public ContextParameter setFilter(Map<String,Object> filter)
    • setFilters

      public ContextParameter setFilters(Filter... filters)
    • getParameterGroup

      public String getParameterGroup()
    • setParameterGroup

      public ContextParameter setParameterGroup(String parameterGroup)
      Allows you to create collapsible sections that organize inputs in the UI. You can assign parameterGroup to each parameter, and they will get categorized. The order of parameter groups (sections) is based on the order in which they are "created" (declared) when the logic is executed. There is one default group for all those that do not have parameterGroup assigned.

      This is supported for Quotes, Contracts and Rebate Agreements (not for Configurators).

    • getURL

      public String getURL()
    • setURL

      public ContextParameter setURL(String url)
    • getType

      public String getType()
    • getInputType

      public InputType getInputType()
    • applyType

      public ContextParameter applyType(InputType inputType)
    • getValueHint

      public String getValueHint()
    • setValueHint

      public ContextParameter setValueHint(String hint)
    • getValueOptions

      public String[] getValueOptions()
    • setValueOptions

      public ContextParameter setValueOptions(String[] valueOptions)
      Sets list of options used in the dropdown input field. This works only for input parameters created via api.option() and api.options()

      Example:

      
       api.option("Country")
       // ...
       api.getParameter("Country").setValueOptions(["USA", "DE"])
       
      Parameters:
      valueOptions -
    • setValueOptions

      public ContextParameter setValueOptions(List<String> valueOptions)
    • getLookupTableId

      public String getLookupTableId()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getValue

      public Object getValue()
    • setValue

      public ContextParameter setValue(Object value)
      Set initial/default value of the input parameter.

      Important: this makes sense only during the SyntaxCheck execution mode. You cannot set the initial value of input field later during regular execution.

      Parameters:
      value -
    • getReadOnly

      public Boolean getReadOnly()
    • setReadOnly

      public ContextParameter setReadOnly(Boolean readOnly)
    • setParameterConfig

      public ContextParameter setParameterConfig(Map<String,Object> parameterConfig)
      Sets the behavior of the input field.

      Example:

      
       PriceParam?.setParameterConfig(["formatType": "MONEY_USD","dataType":"float"])
       
      Parameters:
      parameterConfig - Config parameters as a map.
      Returns:
      See Also:
    • getParameterConfig

      public Map<String,Object> getParameterConfig()
    • setConfigParameter

      public ContextParameter setConfigParameter(String paramName, Object value)
      Adds an additional configuration parameter/option to the input – a parameterConfig property. This option modifies how the input field behaves.

      You can use following paramName with respective values:

      paramName Description
      formatType Sets the format type of the input field (e.g. for "PERCENT" the input will be displayed with % sign and the value returned will be 0..1 instead of 0..100). For possible values, see the FieldFormatType enum.
      from Sets the minimum value of the allowed value range. Applicable to the following input types: INTEGERUSERENTRY, USERENTRY, DATETIMEUSERENTRY (accepts date limits only), DATEUSERENTRY, SLIDER.
      to Sets the maximum value of the allowed value range. Applicable to the following input types: INTEGERUSERENTRY, USERENTRY, DATETIMEUSERENTRY (accepts date limits only), DATEUSERENTRY, SLIDER.
      labels Sets labels to be used for the options, For example ["USA":"United States of America, "DE":"Germany]. Applicable to the OPTION input type.
      disabled Hides the input from the user interface. Supported input types: InputType.CONFIGURATOR (hides the "Open" button).
      dataType Sets the data type of the input field. For example "float", or "integer". Applicable to the following input types: USERENTRY, BOOLEANUSERENTRY, DATEUSERENTRY, DATETIMEUSERENTRY, HIDDEN, INTEGERUSERENTRY, PARSABLEINPUTFILE, QUOTETYPE, REBATEAGREEMENT, TEXTUSERENTRY, TIMEUSERENTRY.
      noRefresh Boolean – Applicable to input fields within a Configurator only. Prevents the Configurator refresh when the value of the field is changed. See AbstractInputBuilder.setNoRefresh(boolean) setNoRefresh()} for more details.
      dmSourceName Name of DS or DM (only for DMFilterBuilder, DMFields or DMField).
      typeCode String – sets the type to be filtered. For FILTERBUILDER input type only.
      targetPage Opens the target location (AppPage). Applicable to the BUTTON input type only. See setTargetPage() for more details.
      targetPageState Opens the particular object detail in the specified location (set by the targetPage). Applicable to the BUTTON input type only. See setTargetPageState() for more details.
      filterFormula Name of the logic which will provide a filter used to limit products/customers in the picker. Example: cp.setConfigParameter("filterFormula", ["name": "ProductFilter_Logic"]). Applicable to the following input types: PRODUCT, PRODUCTGROUP, CUSTOMER, CUSTOMERGROUP.
      autoFocus Boolean – If this is set to true, browser scrolls to the element when the page is loaded and automatically focuses it (places a cursor into the input field). For the radio group, the first element will be focused. If the input is in the read-only mode, autofocus will not be applied.
      sortType String – ASC or DESC. Applicable to MULTITIERENTRY input type only.
      validationType String – VALIDATE or NO_VALIDATION. Applicable to MULTITIERENTRY input type only.
      hideAddButton Boolean – Set to true to hide the "Add" button. Applicable to INPUTMATRIX input type only.
      hideRemoveButton Boolean – Set to true to hide the "Remove" button. Applicable to INPUTMATRIX input type only.
      canModifyRows Boolean – Set to false to hide "Add" and "Remove" buttons. Applicable to INPUTMATRIX input type only.
      readOnlyColumns Specifies columns (as a list) that are set as read only. Applicable to INPUTMATRIX input type only.
      noCellRefresh Boolean – Prevents the Configurator refresh when the value of the Input Matrix cell is edited. Applicable to INPUTMATRIX input type only.
      defaultHeight Number that defines the maximum Input Matrix table height. If there are more entries than the defined default height the scroll bar appears. Applicable to INPUTMATRIX input type only.
      fixTableHeight Boolean that sets the fixed height of the table. Default: true. Applicable to INPUTMATRIX input type within the Configurator only.
      enableClientFilter Boolean – Set to to allow filtering for each column of the table – the search field is displayed within the column name cell. Default: false. Applicable to INPUTMATRIX input type only.
      hiddenColumns Specifies table columns (as a list) that are hidden from the user interface. Applicable to INPUTMATRIX input type within the Configurator only.
      columnValueOptions Specifies options for the drop-down menu for the Option column type. Example: cp.setConfigParameter("columnValueOptions", ["column1" : ["Team Leader","Technical Expert","Observer","Member","Critic"]]). Applicable to INPUTMATRIX input type only.
      columnType Sets types for the table columns. Example: cp.setConfigParameter("columnType", ["Option","Numeric","Text","Date"]). Applicable to INPUTMATRIX input type only.
      disableRowSelection Set to true to disable the row selection (to hide the check-box). Applicable to INPUTMATRIX input type only.
      columnLabels Sets column labels. Example: cp.setConfigParameter("columnLabels", ["First Column", "Second Column"]) Applicable to INPUTMATRIX input type only.
      requiredColumns Sets columns a required. Example: cp.setConfigParameter("requiredColumns", ["col1", "col2"]) Applicable to INPUTMATRIX input type only.
      Parameters:
      paramName -
      value -
      Returns:
    • clearConfigParameter

      public void clearConfigParameter(String paramName)
    • getFormattingOptions

      public Map<String,Object> getFormattingOptions()
    • setFormattingOptions

      public void setFormattingOptions(Map<String,Object> formattingOptions)
      Allows you to set desired formatting options of the input field as a map. For setting a particular formatting option see setFormattingOption(String, Object).
      Parameters:
      formattingOptions -
      See Also:
    • setFormattingOption

      public ContextParameter setFormattingOption(String optionName, Object value)
      Sets (adds or updates) a formatting option (how the input field is displayed) within the formattingOptions map.

      Example – creates an input field and sets the placeholder:

      
       def ce = api.createConfiguratorEntry()
      
       cp = ce.createParameter(InputType.STRINGUSERENTRY, "stringInputField")
       cp.setLabel("String Input Field")
       cp.setFormattingOption("placeholder","I hold the place")
      
       
      Possible values of the optionName parameter:
      optionName Description
      placeholder See setPlaceholderText() for more details.
      defaultWidth See setDefaultWidth() for more details.
      width See setWidth() for more details.
      title See setTitle() for more details.
      helpText See setHelpText() for more details.
      helpLink See setHelpLink() for more details.
      customAttributeName See setCustomAttributeName() for more details.
      customAttributeValue See setCustomAttributeValue() for more details.
      flex See setFlex() for more details.
      Parameters:
      optionName - See the table above.
      value -
      Returns:
    • getAddUnknownValues

      public Boolean getAddUnknownValues()
    • setAddUnknownValues

      public ContextParameter setAddUnknownValues(Boolean addUnknownValues)
    • getTypedId

      public String getTypedId()
    • setTypedId

      public ContextParameter setTypedId(String typedId)
    • getAlwaysEditable

      public Boolean getAlwaysEditable()
    • setAlwaysEditable

      public ContextParameter setAlwaysEditable(Boolean alwaysEditable)
    • addInput

      public void addInput(ContextParameter contextParameter)
      Adds a nested input. This input can be of any type. This is intended to be used when the parent input is of type @link InputType#ROW} or type InputType.COLLAPSE. Depending on the parent type, it is also expected that the added input will have a flex attribute.
      Parameters:
      contextParameter - the input to add
    • getInputs

      public List<ContextParameter> getInputs()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setIfNotNull

      public void setIfNotNull(@NotNull ContextParameter original)
      Copy attributes from the original ContextParameter apart from: name, lookupTableId, type, inputs and valueHint
      Parameters:
      original - ContextParameter as a source for the attributes' copy if not null
    • copyWithoutValue

      public ContextParameter copyWithoutValue()
    • update

      public void update(ContextParameter cp)
    • getObjectService

      public PersistedObjectService getObjectService()