Package org.apache.wicket.markup

Examples of org.apache.wicket.markup.ComponentTag


  @Test
  public void testModelReplacement()
  {
    AttributeModifier modifier = new AttributeModifier("test", Model.of("Ellioth Smith Rocks"));
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("test");
    tag.setName("id");
    modifier.replaceAttributeValue(null, tag);
    Map<String, Object> attributes = tag.getAttributes();
    assertTrue(!attributes.isEmpty());
    String replacement = (String)attributes.get("test");
    assertNotNull(replacement);
    assertEquals("Ellioth Smith Rocks", replacement);
  }
View Full Code Here


  @Test
  public void testModelReplacementOverwritingExistingAttributeValue()
  {
    AttributeModifier modifier = new AttributeModifier("test", Model.of("Ellioth Smith Rocks"));
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("test");
    tag.setName("id");
    Map<String, Object> attributes = tag.getAttributes();
    attributes.put("test", "My mother rocks");
    modifier.replaceAttributeValue(null, tag);
    String replacement = (String)attributes.get("test");
    assertNotNull(replacement);
    assertEquals("Ellioth Smith Rocks", replacement);
View Full Code Here

        return false;
      }
    };

    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("test");
    tag.setName("id");
    Map<String, Object> attributes = tag.getAttributes();
    attributes.put("test", "My mother rocks");
    modifier.replaceAttributeValue(null, tag);
    String replacement = (String)attributes.get("test");
    assertNotNull(replacement);
    assertEquals("My mother rocks", replacement);
View Full Code Here

      {
        return replacementValue + " together";
      }
    };
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("test");
    tag.setName("id");
    modifier.replaceAttributeValue(null, tag);
    Map<String, Object> attributes = tag.getAttributes();
    assertTrue(!attributes.isEmpty());
    String replacement = (String)attributes.get("test");
    assertNotNull(replacement);
    assertEquals("happy together", replacement);
  }
View Full Code Here

      {
        return currentValue + " two";
      }
    };
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    tag.setId("test");
    tag.setName("id");
    Map<String, Object> attributes = tag.getAttributes();
    attributes.put("test", "one");
    modifier.replaceAttributeValue(null, tag);
    String replacement = (String)attributes.get("test");
    assertNotNull(replacement);
    assertEquals("one two", replacement);
View Full Code Here

  @Test
  public void nullModelDoesNotAppendEmptyAttribute()
  {
    AttributeModifier appender = AttributeModifier.append("class", null);
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    appender.replaceAttributeValue(null, tag);
    Map<String, Object> attributes = tag.getAttributes();
    assertTrue(attributes.isEmpty());
  }
View Full Code Here

  @Test
  public void removeAttribute()
  {
    AttributeModifier appender = AttributeModifier.remove("class");
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    Map<String, Object> attributes = tag.getAttributes();
    attributes.put("class", "someValue");
    appender.replaceAttributeValue(null, tag);
    assertTrue(attributes.isEmpty());
  }
View Full Code Here

  public void appendSpecialAttribute()
  {
    String attrName = "attrName";
    AttributeModifier appender = AttributeModifier.append(attrName, "VA_REMOVE");
    XmlTag xmlTag = new XmlTag();
    ComponentTag tag = new ComponentTag(xmlTag);
    Map<String, Object> attributes = tag.getAttributes();
    attributes.put(attrName, "VA_REMOVE");
    appender.replaceAttributeValue(null, tag);
    assertFalse(attributes.isEmpty());
    assertEquals("VA_REMOVE VA_REMOVE", attributes.get(attrName));
  }
View Full Code Here

            }
          };
        }
      };

      ComponentTag tag = new ComponentTag(htmlVoidElement, XmlTag.TagType.OPEN_CLOSE);
      expander.onComponentTag(tag);

      MarkupElement markupElement = expander.nextElement();

      // assert the next element is returned by the parent
View Full Code Here

            }
          };
        }
      };

      ComponentTag tag = new ComponentTag(htmlNonVoidElement, XmlTag.TagType.OPEN_CLOSE);
      expander.onComponentTag(tag);

      ComponentTag markupElement = (ComponentTag)expander.nextElement();

      // assert the next element is returned by the parent
      assertEquals(htmlNonVoidElement, markupElement.getName());
      assertTrue(markupElement.closes(tag));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.ComponentTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.