Class UIComponent

  • Direct Known Subclasses:
    RootUIComponent

    public class UIComponent
    extends Object
    An UIComponent represents a piece of UI element for a client frontend to render; it is kept very simple and delegates the actual rendering and behavior to the frontend. It has a reference to a component's name as defined by the frontend, a map of configuration parameters, and several named "slots", or placeholders, which may contain other sub-components, thus defining a tree. No checks are performed on the actual validity of configuration parameters and their values, the validity of a particular slot for a certain component or the validity of certain types of sub-components within a particular slot: that is the frontend's responsibility.
    Author:
    Yannick Schaus - Initial contribution
    • Constructor Detail

      • UIComponent

        public UIComponent​(String componentType)
        Constructs a component by its type name - component names are not arbitrary, they are defined by the target frontend.
        Parameters:
        componentType - type of the component as known to the frontend
    • Method Detail

      • getType

        public String getType()
        Retrieves the type of the component.
        Returns:
        the component type
      • getConfig

        public Map<String,​Object> getConfig()
        Gets all the configuration parameters of the component
        Returns:
        the map of configuration parameters
      • addConfig

        public void addConfig​(String key,
                              Object value)
        Adds a new configuration parameter to the component
        Parameters:
        key - the parameter key
        value - the parameter value
      • getSlots

        public Map<String,​List<UIComponent>> getSlots()
        Returns all the slots of the components including their sub-components
        Returns:
        the slots and their sub-components
      • addSlot

        public List<UIComponent> addSlot​(String slotName)
        Adds a new empty slot to the component
        Parameters:
        slotName - the name of the slot
        Returns:
        the empty list of components in the newly created slot
      • getSlot

        public List<UIComponent> getSlot​(String slotName)
        Gets the list of sub-components in a slot
        Parameters:
        slotName - the name of the slot
        Returns:
        the list of sub-components in the slot
      • addComponent

        public void addComponent​(String slotName,
                                 UIComponent subComponent)
        Add a new sub-component to the specified slot. Creates the slot if necessary.
        Parameters:
        slotName - the slot to add the component to
        subComponent - the sub-component to add