use of com.vaadin.flow.template.angular.AbstractBindingValueProvider in project flow by vaadin.
the class AbstractTemplateBuilderFactoryTest method createExpressionBinding_JsExpression.
@Test
public void createExpressionBinding_JsExpression() {
AbstractBindingValueProvider binding = AbstractTemplateBuilderFactory.createExpressionBinding("bean234+'name'");
Assert.assertEquals(JsExpressionBindingProvider.class, binding.getClass());
}
use of com.vaadin.flow.template.angular.AbstractBindingValueProvider in project flow by vaadin.
the class AbstractTemplateBuilderFactoryTest method createExpressionBinding_simpleExpression.
@Test
public void createExpressionBinding_simpleExpression() {
AbstractBindingValueProvider binding = AbstractTemplateBuilderFactory.createExpressionBinding("bean234");
Assert.assertEquals(ModelValueBindingProvider.class, binding.getClass());
binding = AbstractTemplateBuilderFactory.createExpressionBinding("bean234.property");
Assert.assertEquals(ModelValueBindingProvider.class, binding.getClass());
}
use of com.vaadin.flow.template.angular.AbstractBindingValueProvider in project flow by vaadin.
the class DefaultElementBuilderFactory method handlePropertyParsing.
private void handlePropertyParsing(Attribute attribute, ElementTemplateBuilder builder, Element element, String name) {
String key = extractKey(name, 1);
AbstractBindingValueProvider binding = createExpressionBinding(stripForLoopVariableIfNeeded(attribute.getValue()));
if (key.startsWith("class.")) {
String className = key.substring("class.".length());
String classAttribute = element.attr("class");
if (Stream.of(classAttribute.split("\\s+")).anyMatch(className::equals)) {
throw new TemplateParseException(String.format("The class attribute can't contain '%s' " + "when there's also a binding for [class.%s]", className, className));
}
builder.setClassName(className, binding);
} else if (key.startsWith("attr.")) {
String attributeName = key.substring("attr.".length());
if (element.hasAttr(attributeName)) {
throw new TemplateParseException(String.format("The '%s' attribute can't be present when there " + "is also a binding for [attr.%s]", attributeName, attributeName));
}
builder.setAttribute(attributeName, binding);
} else {
builder.setProperty(key, binding);
}
}
Aggregations