Package com.vaadin.flow.data.renderer
Class NativeButtonRenderer<SOURCE>
- java.lang.Object
-
- com.vaadin.flow.data.renderer.Renderer<SOURCE>
-
- com.vaadin.flow.data.renderer.ComponentRenderer<com.vaadin.flow.component.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 listeners
- All Implemented Interfaces:
ClickableRenderer<SOURCE>,Serializable
public class NativeButtonRenderer<SOURCE> extends BasicRenderer<SOURCE,String> implements ClickableRenderer<SOURCE>
A template renderer to create a clickable button.ClickableRenderer.ItemClickListeners are notified when the rendered buttons are either clicked or tapped (in touch devices).- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.data.renderer.ClickableRenderer
ClickableRenderer.ItemClickListener<SOURCE>
-
-
Constructor Summary
Constructors Constructor Description NativeButtonRenderer(com.vaadin.flow.function.ValueProvider<SOURCE,String> labelProvider)Creates a new button renderer with a dynamic label.NativeButtonRenderer(com.vaadin.flow.function.ValueProvider<SOURCE,String> labelProvider, ClickableRenderer.ItemClickListener<SOURCE> clickListener)Creates a new button renderer with a dynamic label and registers aClickableRenderer.ItemClickListenerto receive events.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 aClickableRenderer.ItemClickListenerto receive events.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddItemClickListener(ClickableRenderer.ItemClickListener<SOURCE> listener)Adds a click listener to the renderer.com.vaadin.flow.component.ComponentcreateComponent(SOURCE item)Creates a component for a given object model item.List<ClickableRenderer.ItemClickListener<SOURCE>>getItemClickListeners()Gets all registered listeners.protected StringgetTemplateForProperty(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
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 aClickableRenderer.ItemClickListenerto receive events. The label is the same for all the items.More click listeners can be added via
addItemClickListener(ItemClickListener).- Parameters:
label- the label for the rendered button, notnullclickListener- a listener to receive click events
-
NativeButtonRenderer
public NativeButtonRenderer(com.vaadin.flow.function.ValueProvider<SOURCE,String> labelProvider)
Creates a new button renderer with a dynamic label.Item click listeners can be added via
addItemClickListener(ItemClickListener).- Parameters:
labelProvider- the provider for the labels of the rendered buttons, notnull
-
NativeButtonRenderer
public NativeButtonRenderer(com.vaadin.flow.function.ValueProvider<SOURCE,String> labelProvider, ClickableRenderer.ItemClickListener<SOURCE> clickListener)
Creates a new button renderer with a dynamic label and registers aClickableRenderer.ItemClickListenerto receive events.More click listeners can be added via
addItemClickListener(ItemClickListener).- Parameters:
labelProvider- the provider for the labels of the rendered buttons, notnullclickListener- a listener to receive click events
-
-
Method Detail
-
addItemClickListener
public com.vaadin.flow.shared.Registration addItemClickListener(ClickableRenderer.ItemClickListener<SOURCE> listener)
Description copied from interface:ClickableRendererAdds a click listener to the renderer. Events are fired when items are clicked or tapped (for touch devices).- Specified by:
addItemClickListenerin 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:ClickableRendererGets all registered listeners.- Specified by:
getItemClickListenersin interfaceClickableRenderer<SOURCE>- Returns:
- an unmodifiable list of registered listeners, not
null
-
getTemplateForProperty
protected String getTemplateForProperty(String property, Rendering<SOURCE> context)
Description copied from class:BasicRendererGets the template String for a given property.This method is only called when
BasicRenderer.render(Element, DataKeyMapper, Element)is invoked.- Overrides:
getTemplateForPropertyin classBasicRenderer<SOURCE,String>- Parameters:
property- the property to be used inside the templatecontext- the rendering context- Returns:
- the template string to be used inside a
<template>element - See Also:
BasicRenderer.getTemplatePropertyName(Rendering)
-
createComponent
public com.vaadin.flow.component.Component createComponent(SOURCE item)
Description copied from class:ComponentRendererCreates a component for a given object model item. Subclasses can override this method to provide specific behavior.- Overrides:
createComponentin classBasicRenderer<SOURCE,String>- Parameters:
item- the model item, possiblynull- Returns:
- a component instance representing the provided item
-
-