public class IdMapper extends Object implements Serializable
@Id
.
For internal use only. May be renamed or removed in a future release.
Constructor and Description |
---|
IdMapper(Component template)
Creates a mapper for the given template.
|
Modifier and Type | Method and Description |
---|---|
ShadowRoot |
getOrCreateShadowRoot()
Gets the shadow root for the template.
|
boolean |
isMapped(String id)
Checks if the given id has been mapped.
|
void |
mapComponentOrElement(Field field,
String id,
String tag,
Consumer<Element> beforeInject)
Maps an element or component to the given field.
|
void |
reset()
Resets the mapper to its original state, clearing any registered
mappings.
|
public IdMapper(Component template)
template
- a template instancepublic void mapComponentOrElement(Field field, String id, String tag, Consumer<Element> beforeInject)
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.
field
- the field to assign the element/component toid
- the id of the element to maptag
- the tag of the injected element or null
if not
knownbeforeInject
- a callback invoked before assigning the element/component to
the fieldpublic ShadowRoot getOrCreateShadowRoot()
Creates a shadow root if the template does not have one.
public void reset()
public boolean isMapped(String id)
id
- the id to checktrue
if the element has been mapped,
false
otherwiseCopyright © 2022. All rights reserved.