com.vaadin.flow.data.renderer.
Class NativeButtonRenderer<SOURCE>
- java.lang.Object
-
- com.vaadin.flow.data.renderer.Renderer<SOURCE>
-
- com.vaadin.flow.data.renderer.ComponentRenderer<Component,SOURCE>
-
- com.vaadin.flow.data.renderer.BasicRenderer<SOURCE,String>
-
- com.vaadin.flow.data.renderer.NativeButtonRenderer<SOURCE>
-
Type Parameters:
SOURCE
- the type of the item to be received in the click listenersAll Implemented Interfaces:
ClickableRenderer<SOURCE>, Serializable
public class NativeButtonRenderer<SOURCE> extends BasicRenderer<SOURCE,String> implements ClickableRenderer<SOURCE>
A template renderer to create a clickable button.
ItemClickListener
s are notified when the rendered buttons are either clicked or tapped (in touch devices).Since:
1.0.
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.data.renderer.ClickableRenderer
ClickableRenderer.ItemClickListener<SOURCE>
-
-
Constructor Summary
Constructors Constructor and Description NativeButtonRenderer(String label)
Creates a new button renderer with the specified label.
NativeButtonRenderer(String label, ClickableRenderer.ItemClickListener<SOURCE> clickListener)
Creates a new button renderer with the specified label and registers a
ItemClickListener
to receive events.NativeButtonRenderer(ValueProvider<SOURCE,String> labelProvider)
Creates a new button renderer with a dynamic label.
NativeButtonRenderer(ValueProvider<SOURCE,String> labelProvider, ClickableRenderer.ItemClickListener<SOURCE> clickListener)
Creates a new button renderer with a dynamic label and registers a
ItemClickListener
to receive events.
-
Method Summary
All Methods Modifier and Type Method and Description Registration
addItemClickListener(ClickableRenderer.ItemClickListener<SOURCE> listener)
Adds a click listener to the renderer.
Component
createComponent(SOURCE item)
Creates a component for a given object model item.
List<ClickableRenderer.ItemClickListener<SOURCE>>
getItemClickListeners()
Gets all registered listeners.
protected String
getTemplateForProperty(String property, Rendering<SOURCE> context)
Gets the template String for a given property.
-
Methods inherited from class com.vaadin.flow.data.renderer.BasicRenderer
getFormattedValue, getTemplatePropertyName, getValueProvider, render
-
Methods inherited from class com.vaadin.flow.data.renderer.ComponentRenderer
setComponentRendererTag, updateComponent
-
Methods inherited from class com.vaadin.flow.data.renderer.Renderer
getEventHandlers, getValueProviders, render, setEventHandler, setProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.data.renderer.ClickableRenderer
onClick
-
-
-
-
Constructor Detail
-
NativeButtonRenderer
public NativeButtonRenderer(String label)
Creates a new button renderer with the specified label. The label is the same for all the items.
Item click listeners can be added via
ClickableRenderer.addItemClickListener(ItemClickListener)
.Parameters:
label
- the label of the rendered button, notnull
-
NativeButtonRenderer
public NativeButtonRenderer(String label, ClickableRenderer.ItemClickListener<SOURCE> clickListener)
Creates a new button renderer with the specified label and registers a
ItemClickListener
to receive events. The label is the same for all the items.More click listeners can be added via
ClickableRenderer.addItemClickListener(ItemClickListener)
.Parameters:
label
- the label for the rendered button, notnull
clickListener
- a listener to receive click events
-
NativeButtonRenderer
public NativeButtonRenderer(ValueProvider<SOURCE,String> labelProvider)
Creates a new button renderer with a dynamic label.
Item click listeners can be added via
ClickableRenderer.addItemClickListener(ItemClickListener)
.Parameters:
labelProvider
- the provider for the labels of the rendered buttons, notnull
-
NativeButtonRenderer
public NativeButtonRenderer(ValueProvider<SOURCE,String> labelProvider, ClickableRenderer.ItemClickListener<SOURCE> clickListener)
Creates a new button renderer with a dynamic label and registers a
ItemClickListener
to receive events.More click listeners can be added via
ClickableRenderer.addItemClickListener(ItemClickListener)
.Parameters:
labelProvider
- the provider for the labels of the rendered buttons, notnull
clickListener
- a listener to receive click events
-
-
Method Detail
-
addItemClickListener
public Registration addItemClickListener(ClickableRenderer.ItemClickListener<SOURCE> listener)
Description copied from interface:
ClickableRenderer
Adds a click listener to the renderer. Events are fired when items are clicked or tapped (for touch devices).
Specified by:
addItemClickListener
in interfaceClickableRenderer<SOURCE>
Parameters:
listener
- the listener to receive click events, notnull
Returns:
a registration that can be used to remove the listener from this renderer
-
getItemClickListeners
public List<ClickableRenderer.ItemClickListener<SOURCE>> getItemClickListeners()
Description copied from interface:
ClickableRenderer
Gets all registered listeners.
Specified by:
getItemClickListeners
in interfaceClickableRenderer<SOURCE>
Returns:
an unmodifiable list of registered listeners, not
null
-
getTemplateForProperty
protected String getTemplateForProperty(String property, Rendering<SOURCE> context)
Description copied from class:
BasicRenderer
Gets the template String for a given property.
This method is only called when
BasicRenderer.render(Element, DataKeyMapper, Element)
is invoked.Overrides:
getTemplateForProperty
in classBasicRenderer<SOURCE,String>
Parameters:
property
- the property to be used inside the templatecontext
- the rendering contextReturns:
the template string to be used inside a
<template>
elementSee Also:
-
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 classBasicRenderer<SOURCE,String>
Parameters:
item
- the model item, possiblynull
Returns:
a component instance representing the provided item
-
-