Search in sources :

Example 26 with Element

use of org.apache.tapestry5.dom.Element in project tapestry-5 by apache.

the class DocumentLinkerImpl method updateDocument.

/**
 * Updates the supplied Document, possibly adding <head> or <body> elements.
 *
 * @param document
 *         to be updated
 */
public void updateDocument(Document document) {
    Element root = document.getRootElement();
    if (root == null) {
        return;
    }
    // TAP5-2200: Generating XML from pages and templates is not possible anymore
    // only add JavaScript and CSS if we're actually generating
    final String mimeType = document.getMimeType();
    if (mimeType != null && !HTML_MIME_TYPES.contains(mimeType)) {
        return;
    }
    addStylesheetsToHead(root, includedStylesheets);
    // only add the generator meta only to html documents
    boolean isHtmlRoot = root.getName().equals("html");
    if (!omitGeneratorMetaTag && isHtmlRoot) {
        Element head = findOrCreateElement(root, "head", true);
        Element existingMeta = head.find("meta");
        addElementBefore(head, existingMeta, "meta", "name", "generator", "content", tapestryBanner);
    }
    addScriptElements(root);
}
Also used : Element(org.apache.tapestry5.dom.Element)

Example 27 with Element

use of org.apache.tapestry5.dom.Element in project tapestry-5 by apache.

the class HiddenFieldLocationRulesImpl method match.

private boolean match(Element element, RelativeElementPosition position) {
    assert element != null;
    String key = element.getName();
    RelativeElementPosition actual = configuration.get(key);
    if (actual == null)
        return false;
    return actual == position;
}
Also used : RelativeElementPosition(org.apache.tapestry5.services.RelativeElementPosition)

Example 28 with Element

use of org.apache.tapestry5.dom.Element in project tapestry-5 by apache.

the class SubmitTest method submit_form.

@Test
public void submit_form() {
    Element submitButton = doc.getElementById("capitalize1");
    assertEquals("submit", submitButton.getAttribute("type"));
    fieldValues.put("t1", "hello");
    doc = tester.clickSubmit(submitButton, fieldValues);
    assertTrue(doc.toString().contains("Value is: HELLO"));
}
Also used : Element(org.apache.tapestry5.dom.Element) Test(org.testng.annotations.Test)

Example 29 with Element

use of org.apache.tapestry5.dom.Element in project tapestry-5 by apache.

the class SubmitTest method not_in_form.

@Test
public void not_in_form() {
    try {
        Element submitButton = doc.getElementById("orphanedSubmit");
        tester.clickSubmit(submitButton, fieldValues);
        throw new RuntimeException("Should not be reachable.");
    } catch (RuntimeException ex) {
        assertEquals(ex.getMessage(), "Could not locate an ancestor element of type 'form'.");
    }
}
Also used : Element(org.apache.tapestry5.dom.Element) Test(org.testng.annotations.Test)

Example 30 with Element

use of org.apache.tapestry5.dom.Element in project tapestry-5 by apache.

the class SubmitTest method not_a_submit.

@Test(expectedExceptions = IllegalArgumentException.class)
public void not_a_submit() {
    Element submitButton = doc.getElementById("t1");
    tester.clickSubmit(submitButton, fieldValues);
}
Also used : Element(org.apache.tapestry5.dom.Element) Test(org.testng.annotations.Test)

Aggregations

Element (elemental2.dom.Element)269 HTMLElement (elemental2.dom.HTMLElement)215 Test (org.junit.Test)175 HTMLDivElement (elemental2.dom.HTMLDivElement)129 HTMLButtonElement (elemental2.dom.HTMLButtonElement)63 HTMLInputElement (elemental2.dom.HTMLInputElement)60 Element (org.apache.tapestry5.dom.Element)39 DOMTokenList (elemental2.dom.DOMTokenList)38 Test (org.testng.annotations.Test)34 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)32 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)29 MarkupWriter (org.apache.tapestry5.MarkupWriter)16 ArrayList (java.util.ArrayList)14 IsElement (org.jboss.gwt.elemento.core.IsElement)14 List (java.util.List)13 Elements (org.jboss.gwt.elemento.core.Elements)13 HTMLSelectElement (elemental2.dom.HTMLSelectElement)12 EventType.click (org.jboss.gwt.elemento.core.EventType.click)12 ComponentModel (org.apache.tapestry5.model.ComponentModel)11 Ids (org.jboss.hal.resources.Ids)11