本文整理汇总了Java中org.thymeleaf.dom.Element.setRecomputeProcessorsImmediately方法的典型用法代码示例。如果您正苦于以下问题:Java Element.setRecomputeProcessorsImmediately方法的具体用法?Java Element.setRecomputeProcessorsImmediately怎么用?Java Element.setRecomputeProcessorsImmediately使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.dom.Element
的用法示例。
在下文中一共展示了Element.setRecomputeProcessorsImmediately方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processAttribute
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {
String[] value = element.getAttributeValue(attributeName).split(":");
String webjarName = value[0];
String filePath = value[1];
element.removeAttribute(attributeName);
element.setAttribute("th:" + attribute, String.format("@{/{path}/%s(path=${#webjars['%s'].path})}", filePath, webjarName));
// reevaluate th:src
element.setRecomputeProcessorsImmediately(true);
return ProcessorResult.OK;
}
示例2: processElement
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected ProcessorResult processElement(Arguments arguments, Element element) {
// If the form will be not be submitted with a GET, we must add the CSRF token
// We do this instead of checking for a POST because post is default if nothing is specified
if (!"GET".equalsIgnoreCase(element.getAttributeValueFromNormalizedName("method"))) {
try {
String csrfToken = eps.getCSRFToken();
//detect multipart form
if ("multipart/form-data".equalsIgnoreCase(element.getAttributeValueFromNormalizedName("enctype"))) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValueFromNormalizedName("th:action"));
String action = (String) expression.execute(arguments.getConfiguration(), arguments);
String csrfQueryParameter = "?" + eps.getCsrfTokenParameter() + "=" + csrfToken;
element.removeAttribute("th:action");
element.setAttribute("action", action + csrfQueryParameter);
} else {
Element csrfNode = new Element("input");
csrfNode.setAttribute("type", "hidden");
csrfNode.setAttribute("name", eps.getCsrfTokenParameter());
csrfNode.setAttribute("value", csrfToken);
element.addChild(csrfNode);
}
} catch (ServiceException e) {
throw new RuntimeException("Could not get a CSRF token for this session", e);
}
}
// Convert the <blc:form> node to a normal <form> node
Element newElement = element.cloneElementNodeWithNewName(element.getParent(), "form", false);
newElement.setRecomputeProcessorsImmediately(true);
element.getParent().insertAfter(element, newElement);
element.getParent().removeChild(element);
return ProcessorResult.OK;
}
示例3: fixElement
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
public void fixElement(Element element, Arguments arguments) {
boolean elementAdded = false;
boolean removeElement = false;
Set<String> attributeNames = element.getAttributeMap().keySet();
for (String a : attributeNames) {
String attrName = a.toLowerCase();
if (attrName.startsWith("th")) {
if (attrName.equals("th:substituteby") || (attrName.equals("th:replace") || attrName.equals("th:include"))) {
if (!elementAdded) {
Element extraDiv = new Element("div");
String attrValue = element.getAttributeValue(attrName);
element.removeAttribute(attrName);
extraDiv.setAttribute(attrName, attrValue);
element.addChild(extraDiv);
elementAdded = true;
element.setNodeProperty("templateName", attrValue);
// This will ensure that the substituteby and replace processors only run for the child element
element.setRecomputeProcessorsImmediately(true);
}
} else if (attrName.equals("th:remove")) {
Attribute attr = element.getAttributeMap().get(attrName);
if ("tag".equals(attr.getValue())) {
removeElement = true;
// The cache functionality will remove the element.
element.setAttribute(attrName, "none");
}
}
}
}
if (!elementAdded || removeElement) {
element.setNodeProperty("blcOutputParentNode", Boolean.TRUE);
}
}
示例4: processAttribute
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
public ProcessorResult processAttribute(final Arguments arguments, final Element element, String attributeName) {
if (shouldCache(arguments, element, attributeName)) {
fixElement(element, arguments);
if (checkCacheForElement(arguments, element)) {
// This template has been cached.
element.clearChildren();
element.clearAttributes();
element.setRecomputeProcessorsImmediately(true);
}
}
return ProcessorResult.OK;
}