Class UIComponent

  • Direct Known Subclasses:

    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.
    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.
        componentType - type of the component as known to the frontend
    • Method Detail

      • getType

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

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

        public void addConfig​(String key,
                              Object value)
        Adds a new configuration parameter to the component
        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
        the slots and their sub-components
      • addSlot

        public List<UIComponent> addSlot​(String slotName)
        Adds a new empty slot to the component
        slotName - the name of the slot
        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
        slotName - the name of the slot
        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.
        slotName - the slot to add the component to
        subComponent - the sub-component to add