com.vaadin.flow.component.template.internal.
Class IdMapper
All Implemented Interfaces:
Creates or maps Element instances to fields mapped using @Id
.
For internal use only. May be renamed or removed in a future release.
Since:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the shadow root for the template.
boolean
Checks if the given id has been mapped.
void
Maps an element or component to the given field.
void
reset()
Resets the mapper to its original state, clearing any registered mappings.
-
Constructor Details
-
IdMapper
Creates a mapper for the given template.
Parameters:
template
- a template instance
-
-
Method Details
-
mapComponentOrElement
public void mapComponentOrElement(Field field, String id, String tag, Consumer<Element> beforeInject) Maps an element or component to the given field.
If an element with the given id exists in the template element tree, that element is used.
If no element exists (the typical case), a virtual element is created and later on, when the template has been rendered in the client, is connected to the rendered element with the given id.
Parameters:
field
- the field to assign the element/component toid
- the id of the element to maptag
- the tag of the injected element ornull
if not knownbeforeInject
- a callback invoked before assigning the element/component to the field -
getOrCreateShadowRoot
Gets the shadow root for the template.
Creates a shadow root if the template does not have one.
Returns:
the shadow root for the template
-
reset
public void reset()Resets the mapper to its original state, clearing any registered mappings.
-
isMapped
Checks if the given id has been mapped.
Parameters:
id
- the id to checkReturns:
true
if the element has been mapped,false
otherwise
-