Package com.vaadin.ui

Class CustomLayout

    • Constructor Detail

      • CustomLayout

        public CustomLayout()
        Default constructor only used by subclasses. Subclasses are responsible for setting the appropriate fields. Either setTemplateName(String), that makes layout fetch the template from theme, or setTemplateContents(String).
        Since:
        7.5.0
      • CustomLayout

        public CustomLayout​(InputStream templateStream)
                     throws IOException
        Constructs a custom layout with the template given in the stream.
        Parameters:
        templateStream - Stream containing template data. Must be using UTF-8 encoding. To use a String as a template use for instance new ByteArrayInputStream("<template>".getBytes()).
        streamLength - Length of the templateStream
        Throws:
        IOException
      • CustomLayout

        public CustomLayout​(String template)
        Constructor for custom layout with given template name. Template file is fetched from "<theme>/layout/<templateName>".
    • Method Detail

      • getState

        protected CustomLayoutState getState()
        Description copied from class: AbstractComponent
        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
        Overrides:
        getState in class AbstractLayout
        Returns:
        updated component shared state
      • addComponent

        public void addComponent​(Component c,
                                 String location)
        Adds the component into this container to given location. If the location is already populated, the old component is removed.
        Parameters:
        c - the component to be added.
        location - the location of the component.
      • removeComponent

        public void removeComponent​(String location)
        Removes the component from this container from given location.
        Parameters:
        location - the Location identifier of the component.
      • getComponent

        public Component getComponent​(String location)
        Gets the child-component by its location.
        Parameters:
        location - the name of the location where the requested component resides.
        Returns:
        the Component in the given location or null if not found.
      • replaceComponent

        public void replaceComponent​(Component oldComponent,
                                     Component newComponent)
        Description copied from interface: ComponentContainer
        Replaces the component in the container with another one without changing position.

        This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.

        Specified by:
        replaceComponent in interface ComponentContainer
        Parameters:
        oldComponent - the old component that will be replaced.
        newComponent - the new component to be replaced.
      • getTemplateName

        public String getTemplateName()
        Get the name of the template
      • getTemplateContents

        public String getTemplateContents()
        Get the contents of the template
      • setTemplateName

        public void setTemplateName​(String templateName)
        Set the name of the template used to draw custom layout. With GWT-adapter, the template with name 'templatename' is loaded from VAADIN/themes/themename/layouts/templatename.html. If the theme has not been set (with Application.setTheme()), themename is 'default'.
        Parameters:
        templateName -
      • setTemplateContents

        public void setTemplateContents​(String templateContents)
        Set the contents of the template used to draw the custom layout.
        Parameters:
        templateContents -
      • changeVariables

        public void changeVariables​(Object source,
                                    Map<String,​Object> variables)
        Description copied from interface: VariableOwner
        Called when one or more variables handled by the implementing class are changed.
        Specified by:
        changeVariables in interface VariableOwner
        Parameters:
        source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
        variables - the Mapping from variable names to new variable values.
      • paintContent

        public void paintContent​(PaintTarget target)
                          throws PaintException
        Description copied from interface: LegacyComponent

        Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.

        It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.

        Specified by:
        paintContent in interface LegacyComponent
        Parameters:
        target - the target UIDL stream where the component should paint itself to.
        Throws:
        PaintException - if the paint operation failed.
      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)
        Description copied from interface: Component
        Reads the component state from the given design.

        The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.

        It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.

        This method must not modify the design.

        Specified by:
        readDesign in interface Component
        Overrides:
        readDesign in class AbstractComponent
        Parameters:
        design - The element to obtain the state from
        designContext - The DesignContext instance used for parsing the design
      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)
        Description copied from interface: Component
        Writes the component state to the given design.

        The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.

        This method must not modify the component state.

        Specified by:
        writeDesign in interface Component
        Overrides:
        writeDesign in class AbstractComponent
        Parameters:
        design - The element to write the component state to. Any previous attributes or child nodes are not cleared.
        designContext - The DesignContext instance used for writing the design