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);
}
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;
}
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"));
}
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'.");
}
}
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);
}
Aggregations