Class AttributedResult

Object
AttributedResult

public class AttributedResult extends Object
Provides means for output elements' formatting.

The usage is simple, instead of returning the output value, create a new AttributedResult instance like this: api.attributedResult(plain value), customize it by calling its various methods, and return it finally.

Example:


 def cost = out.MarginPct
 def myOptions = ["A" , "B" , "C" ]
 return api.attributedResult(cost)
         .withBackgroundColor(cost < 0.30 ? "red" : "#0101DF")
         .withSuffix(cost < 0.30 ? "!!!" : null)
         .withTextColor(cost < 0.30 ? "white" : null)
         .withTextDecoration(cost < 0.30 ? "underline" : null)
         .withManualOverrideValueOptions(myOptions)
 
  • Constructor Details

    • AttributedResult

      public AttributedResult(Object result)
    • AttributedResult

      public AttributedResult(Object result, Map<String,Object> attrs)
  • Method Details

    • getResult

      public Object getResult()
    • getAttributes

      public Map<String,Object> getAttributes()
    • getAttribute

      public <T> T getAttribute(String name)
    • setAttribute

      public <T> T setAttribute(String name, Object value)
    • clearAttribute

      public <T> T clearAttribute(String name)
    • containsAttribute

      public boolean containsAttribute(String name)
    • withRawCSS

      public AttributedResult withRawCSS(String css)
      Adds any valid CSS style to the cell. Note: There is no check if the CSS is actually valid, the values are just passed through as-is
      Parameters:
      css - The full CSS style parameter in the form of "property:value;"
      See Also:
    • withSuffix

      public AttributedResult withSuffix(String suffix)
      Sets a suffix to be appended to the result.
    • withTextColor

      public AttributedResult withTextColor(String cssColor)
      Sets the text (foreground) color.
      See Also:
    • withTextDecoration

      public AttributedResult withTextDecoration(String textDecoration)
      Sets the decoration to be added to the resulting text.

      Valid options are underline, line-through, and overline.

      See Also:
    • withBackgroundColor

      public AttributedResult withBackgroundColor(String cssColor)
      Sets the background color.
      See Also:
    • withManualOverrideValueOptions

      public AttributedResult withManualOverrideValueOptions(List<Object> options)
      In case the result element is overridable, this method defines a set (list) of values that the user can pick from (vs. default free-style data entry) IMPORTANT NOTE: This is meant to list a few options only. Not a large list of choices! There is not a hard limitation here, but if this is used widely in a particular configuration and the list of options is long the browser may not be able to render it anymore and/or the data transfer speeds may suffer.
      Parameters:
      options - The list of valid options in the UI
      Returns:
    • removeManualOverrideValueOptions

      public AttributedResult removeManualOverrideValueOptions()
      In case the result element is overridable, this method clears a set (list) of values defined with above withManualOverrideValueOptions method IMPORTANT NOTE: This is implemented only for Pricelists, PriceGrids and CalculationGrids.
      Returns:
    • withManualOverrideAllowEmpty

      public AttributedResult withManualOverrideAllowEmpty(Boolean allow)
      In case the result element is overridable, this method defines if the selection box shows also the "empty value" option. Default is true
      Returns: