Search in sources :

Example 1 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ForTemplateView method createModelItem.

private StateNode createModelItem(String text, String key) {
    StateNode modelItem1 = new StateNode(TemplateOverridesMap.class, ModelMap.class);
    updateModelItem(modelItem1, text, key);
    return modelItem1;
}
Also used : StateNode(com.vaadin.flow.internal.StateNode)

Example 2 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ModelValueBindingTest method getValue.

public void getValue() {
    ModelValueBindingProvider binding = new ModelValueBindingProvider("bar");
    StateNode node = new StateNode(ModelMap.class);
    ModelMap.get(node).setValue("bar", "someValue");
    Assert.assertEquals("someValue", binding.getValue(node));
}
Also used : StateNode(com.vaadin.flow.internal.StateNode) ModelValueBindingProvider(com.vaadin.flow.template.angular.ModelValueBindingProvider)

Example 3 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ScriptParsingTest method inlineStyles.

@Test
public void inlineStyles() {
    String contents = // 
    ".foo {\n" + // 
    "  font-weight: bold;\n" + "}\n";
    TemplateNode templateNode = parse(// 
    "<style>" + contents + // 
    "</style>");
    // 
    Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
    ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
    Assert.assertEquals("style", elementTemplate.getTag());
    TextTemplateNode textNode = ((TextTemplateNode) elementTemplate.getChild(0));
    String nodeContents = (String) textNode.getTextBinding().getValue(new StateNode());
    Assert.assertEquals(contents, nodeContents);
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) TemplateNode(com.vaadin.flow.template.angular.TemplateNode) TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 4 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class ScriptParsingTest method inlineScript.

@Test
public void inlineScript() {
    String script = "window.alert('hello');\n" + "window.alert('world');\n";
    TemplateNode templateNode = parse(// 
    "<script>" + script + // 
    "</script>");
    // 
    Assert.assertEquals(ElementTemplateNode.class, templateNode.getClass());
    ElementTemplateNode elementTemplate = (ElementTemplateNode) templateNode;
    Assert.assertEquals("script", elementTemplate.getTag());
    TextTemplateNode textNode = ((TextTemplateNode) elementTemplate.getChild(0));
    String nodeContents = (String) textNode.getTextBinding().getValue(new StateNode());
    Assert.assertEquals(script, nodeContents);
}
Also used : TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) TemplateNode(com.vaadin.flow.template.angular.TemplateNode) TextTemplateNode(com.vaadin.flow.template.angular.TextTemplateNode) ElementTemplateNode(com.vaadin.flow.template.angular.ElementTemplateNode) StateNode(com.vaadin.flow.internal.StateNode) Test(org.junit.Test)

Example 5 with StateNode

use of com.vaadin.flow.internal.StateNode in project flow by vaadin.

the class BeanModelTypeTest method modelToApplication.

@Test
public void modelToApplication() {
    BeanModelType<Bean> beanType = new BeanModelType<>(Bean.class, PropertyFilter.ACCEPT_ALL);
    ModelMap model = ModelMap.get(new StateNode(ModelMap.class));
    model.setValue("string", "3");
    model.setValue("intValue", Integer.valueOf(3));
    Bean bean = beanType.modelToApplication(model.getNode());
    Assert.assertEquals("3", bean.getString());
    Assert.assertEquals(3, bean.getIntValue());
    Assert.assertNull(bean.getIntObject());
}
Also used : ModelMap(com.vaadin.flow.internal.nodefeature.ModelMap) StateNode(com.vaadin.flow.internal.StateNode) Bean(com.vaadin.flow.templatemodel.Bean) Test(org.junit.Test)

Aggregations

StateNode (com.vaadin.flow.internal.StateNode)160 Test (org.junit.Test)99 Element (com.vaadin.flow.dom.Element)29 ElementPropertyMap (com.vaadin.flow.internal.nodefeature.ElementPropertyMap)19 JsonObject (elemental.json.JsonObject)19 TemplateNode (com.vaadin.flow.template.angular.TemplateNode)18 ModelMap (com.vaadin.flow.internal.nodefeature.ModelMap)16 ArrayList (java.util.ArrayList)14 StateNodeTest (com.vaadin.flow.internal.StateNodeTest)13 Serializable (java.io.Serializable)13 StateTree (com.vaadin.flow.internal.StateTree)10 ModelList (com.vaadin.flow.internal.nodefeature.ModelList)10 UI (com.vaadin.flow.component.UI)9 TemplateElementStateProviderTest (com.vaadin.flow.dom.TemplateElementStateProviderTest)9 ElementTemplateNode (com.vaadin.flow.template.angular.ElementTemplateNode)9 Bean (com.vaadin.flow.templatemodel.Bean)9 ChildElementConsumer (com.vaadin.flow.dom.ChildElementConsumer)8 AttachExistingElementFeature (com.vaadin.flow.internal.nodefeature.AttachExistingElementFeature)8 ElementData (com.vaadin.flow.internal.nodefeature.ElementData)8 TemplateOverridesMap (com.vaadin.flow.internal.nodefeature.TemplateOverridesMap)6