use of com.vaadin.flow.component.polymertemplate.PolymerTemplate in project flow by vaadin.
the class PolymerPublishedEventRpcHandler method getTemplateItem.
/**
* Get the template model object and type.
*
* @param template
* polymer template to get model from
* @param argValue
* argument value
* @param convertedType
* value type
* @return the provided model value
* @throws IllegalStateException
* if the component is not attached to the UI
*/
@Override
public Object getTemplateItem(Component template, JsonObject argValue, Type convertedType) {
final Optional<UI> ui = template.getUI();
if (ui.isPresent()) {
StateNode node = ui.get().getInternals().getStateTree().getNodeById((int) argValue.getNumber("nodeId"));
ModelType propertyType = ((PolymerTemplate<?>) template).getModelType(convertedType);
return propertyType.modelToApplication(node);
}
throw new IllegalArgumentException("Event sent for a non attached template component");
}
use of com.vaadin.flow.component.polymertemplate.PolymerTemplate in project flow by vaadin.
the class PolymerPublishedEventRpcHandlerTest method getTemplateItem.
public static Object getTemplateItem(Component template, JsonObject argValue, Type convertedType) {
final Optional<UI> ui = template.getUI();
if (ui.isPresent()) {
StateNode node = ui.get().getInternals().getStateTree().getNodeById((int) argValue.getNumber("nodeId"));
ModelType propertyType = ((PolymerTemplate<?>) template).getModelType(convertedType);
return propertyType.modelToApplication(node);
}
throw new IllegalStateException("Event sent for a non attached template component");
}
Aggregations