Class BasicRenderer<SOURCE,​TARGET>

    • Constructor Detail

      • BasicRenderer

        protected BasicRenderer​(ValueProvider<SOURCE,​TARGET> valueProvider)
        Builds a new template renderer using the value provider as the source of values to be rendered.
        Parameters:
        valueProvider - the callback to provide a objects to the renderer, not null
    • Method Detail

      • render

        public Rendering<SOURCE> render​(Element container,
                                        DataKeyMapper<SOURCE> keyMapper,
                                        Element contentTemplate)
        Description copied from class: Renderer
        Handles the rendering of the model objects by using the given <template> element in the given container.

        Subclasses of Renderer usually override this method to provide additional features.

        Overrides:
        render in class ComponentRenderer<Component,​SOURCE>
        Parameters:
        container - the element in which the template will be attached to, not null
        keyMapper - mapper used internally to fetch items by key and to provide keys for given items. It is required when either event handlers or DataGenerator are supported
        contentTemplate - the <template> element to be used for rendering in the container, not null
        Returns:
        the context of the rendering, that can be used by the components to provide extra customization
      • getTemplatePropertyName

        protected String getTemplatePropertyName​(Rendering<SOURCE> context)
        Gets the name of the property to be transmitted and used inside the template. By default, it generates a unique name by using the class name of the renderer and the node id of the template element.

        This method is only called when render(Element, DataKeyMapper, Element) is invoked.

        Parameters:
        context - the rendering context
        Returns:
        the property name to be used in template data bindings
        See Also:
        Rendering.getTemplateElement()
      • createComponent

        public Component createComponent​(SOURCE item)
        Description copied from class: ComponentRenderer
        Creates a component for a given object model item. Subclasses can override this method to provide specific behavior.
        Overrides:
        createComponent in class ComponentRenderer<Component,​SOURCE>
        Parameters:
        item - the model item, possibly null
        Returns:
        a component instance representing the provided item
      • getFormattedValue

        protected String getFormattedValue​(TARGET object)
        Gets the String representation of the target object, to be used inside the template.

        By default it uses String.valueOf(Object) of the object.

        Parameters:
        object - the target object
        Returns:
        the string representation of the object