Class 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 = api.getElement("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 Detail

      • AttributedResult

        public AttributedResult​(Object result)
    • Method Detail

      • getResult

        public Object getResult()
      • 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:
        CSS Reference
      • withSuffix

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

        public AttributedResult withManualOverrideValueOptions​(List<Object> options)
        In case the result element is overridable, this method defines a set (list) of values tha 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:
      • 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: