Class SelectItemsUtils

java.lang.Object
org.omnifaces.util.selectitems.SelectItemsUtils

public final class SelectItemsUtils extends Object
Collection of utility methods for working with SelectItem or data represented by them.
Author:
Arjan Tijms
  • Method Details

    • findValueByStringConversion

      public static Object findValueByStringConversion(FacesContext context, UIComponent component, String value, Converter<Object> converter)
      Finds an object value in the SelectItem instances associated with the given component by means of matching its converted value with the given string value.
      Parameters:
      context - The involved faces context.
      component - the component with which SelectItems should be associated that are used to search in.
      value - a string that should match the string representation of one of the values held by the SelectItems.
      converter - the faces Converter used to generate String representations for the values held by the SelectItems.
      Returns:
      the Object representation of the value where its string representation matches the input value.
    • findValueByStringConversion

      public static Object findValueByStringConversion(FacesContext context, UIComponent component, List<SelectItem> selectItems, String value, Converter<Object> converter)
      Finds an object value in the given SelectItem instances by means of matching its converted value with the given string value. This is a variant of findValueByStringConversion(FacesContext, UIComponent, String, Converter) which takes the already collected select items, so that the caller can cache and reuse them across multiple invocations within the same phase.
      Parameters:
      context - The involved faces context.
      component - The component with which the given SelectItems are associated.
      selectItems - The already collected select items to search in.
      value - A string that should match the string representation of one of the values held by the SelectItems.
      converter - The faces Converter used to generate String representations for the values held by the SelectItems.
      Returns:
      The object representation of the value where its string representation matches the input value.
      Since:
      5.4.1
    • collectAllValuesFromSelectItems

      public static List<Object> collectAllValuesFromSelectItems(FacesContext context, UIComponent component)
      Collects all values associated with all SelectItem instances associated with the given component.

      Note that values from recursively scanned SelectItemGroup instances are included.

      Parameters:
      context - The involved faces context.
      component - the component with which SelectItem instances should be associated
      Returns:
      List of all values hold by SelectItem instances