本文整理汇总了Java中org.thymeleaf.dom.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于org.thymeleaf.dom包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContentItems
import org.thymeleaf.dom.Element; //导入依赖的package包/类
/**
* @param contentName name of the content to be looked up (can be null)
* @param maxResults maximum results to return
* @param request servlet request
* @param mvelParameters values that should be considered when filtering the content list by rules
* @param structuredContentType the type of content that should be returned
* @param locale current locale
* @param arguments Thymeleaf Arguments passed into the tag
* @param element element context that this Thymeleaf processor is being executed in
* @return
*/
protected List<StructuredContentDTO> getContentItems(String contentName, Integer maxResults, HttpServletRequest request,
Map<String, Object> mvelParameters,
SandBox currentSandbox,
StructuredContentType structuredContentType,
Locale locale, Arguments arguments, Element element) {
List<StructuredContentDTO> contentItems;
if (structuredContentType == null) {
contentItems = structuredContentService.lookupStructuredContentItemsByName(contentName, locale, maxResults, mvelParameters, isSecure(request));
} else {
if (contentName == null || "".equals(contentName)) {
contentItems = structuredContentService.lookupStructuredContentItemsByType(structuredContentType, locale, maxResults, mvelParameters, isSecure(request));
} else {
contentItems = structuredContentService.lookupStructuredContentItemsByName(structuredContentType, contentName, locale, maxResults, mvelParameters, isSecure(request));
}
}
//add additional fields to the model
extensionManager.getProxy().addAdditionalFieldsToModel(arguments, element);
return contentItems;
}
示例2: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
String elementName = element.getNormalizedName();
String useCDN = element.getAttributeValue("useCDN");
if (LINK.equals(elementName) || (useCDN != null && "true".equals(useCDN))) {
attrs = super.getModifiedAttributeValues(arguments, element, attributeName);
String srcAttr = attrs.remove("src");
attrs.put(HREF, srcAttr);
} else {
attrs.put(HREF, element.getAttributeValue(attributeName));
}
return attrs;
}
示例3: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
SparkRequestContext blcContext = SparkRequestContext.getSparkRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
Integer page = (Integer) expression.execute(arguments.getConfiguration(), arguments);
if (page != null && page > 1) {
params.put(ProductSearchCriteria.PAGE_NUMBER, new String[] { page.toString() });
} else {
params.remove(ProductSearchCriteria.PAGE_NUMBER);
}
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例4: checkExpired
import org.thymeleaf.dom.Element; //导入依赖的package包/类
/**
* Returns true if the item has been
* @param element
* @param cacheElement
* @return
*/
protected boolean checkExpired(Element element, net.sf.ehcache.Element cacheElement) {
if (cacheElement.isExpired()) {
return true;
} else {
String cacheTimeout = element.getAttributeValue("cacheTimeout");
if (!StringUtils.isEmpty(cacheTimeout) && StringUtils.isNumeric(cacheTimeout)) {
Long timeout = Long.valueOf(cacheTimeout) * 1000;
Long expiryTime = cacheElement.getCreationTime() + timeout;
if (expiryTime < System.currentTimeMillis()) {
return true;
}
}
}
return false;
}
示例5: getNewLocalVariables
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected Map<String, Object> getNewLocalVariables(Arguments arguments, Element element) {
initServices(arguments);
HashMap<String, String> productOptionDisplayValues = new HashMap<String, String>();
Map<String, Object> newVars = new HashMap<String, Object>();
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue("orderItem"));
Object item = expression.execute(arguments.getConfiguration(), arguments);
if (item instanceof DiscreteOrderItem) {
DiscreteOrderItem orderItem = (DiscreteOrderItem) item;
for (String i : orderItem.getOrderItemAttributes().keySet()) {
for (ProductOption option : orderItem.getProduct().getProductOptions()) {
if (option.getAttributeName().equals(i) && !StringUtils.isEmpty(orderItem.getOrderItemAttributes().get(i).toString())) {
productOptionDisplayValues.put(option.getLabel(), orderItem.getOrderItemAttributes().get(i).toString());
}
}
}
}
newVars.put("productOptionDisplayValues", productOptionDisplayValues);
return newVars;
}
示例6: getNewLocalVariables
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected Map<String, Object> getNewLocalVariables(Arguments arguments, Element element) {
FieldWrapper fieldWrapper = new FieldWrapper();
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue("fieldBuilder"));
String fieldBuilder = (String) expression.execute(arguments.getConfiguration(), arguments);
if (fieldBuilder != null) {
RuleBuilderFieldService ruleBuilderFieldService = ruleBuilderFieldServiceFactory.createInstance(fieldBuilder);
if (ruleBuilderFieldService != null) {
fieldWrapper = ruleBuilderFieldService.buildFields();
}
}
Map<String, Object> newVars = new HashMap<String, Object>();
newVars.put("fieldWrapper", fieldWrapper);
return newVars;
}
示例7: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
SearchFacetDTO facet = (SearchFacetDTO) expression.execute(arguments.getConfiguration(), arguments);
String key = facet.getFacet().getField().getAbbreviation();
params.remove(key);
params.remove(SearchCriteria.PAGE_NUMBER);
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例8: processElement
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected ProcessorResult processElement(Arguments arguments, Element element) {
StringBuffer sb = new StringBuffer();
sb.append("<SCRIPT>\n");
sb.append(" var params = \n ");
sb.append(buildContentMap(arguments)).append(";\n ");
sb.append(getUncacheableDataFunction(arguments, element)).append(";\n");
sb.append("</SCRIPT>");
// Add contentNode to the document
Node contentNode = new Macro(sb.toString());
element.clearChildren();
element.getParent().insertAfter(element, contentNode);
element.getParent().removeChild(element);
// Return OK
return ProcessorResult.OK;
}
示例9: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
Integer page = (Integer) expression.execute(arguments.getConfiguration(), arguments);
if (page != null && page > 1) {
params.put(ProductSearchCriteria.PAGE_NUMBER, new String[] { page.toString() });
} else {
params.remove(ProductSearchCriteria.PAGE_NUMBER);
}
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例10: modifyModelAttributes
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected void modifyModelAttributes(Arguments arguments, Element element) {
String resultVar = element.getAttributeValue("resultVar");
if (resultVar == null) {
resultVar = "value";
}
String attributeName = element.getAttributeValue("name");
String attributeValue = SCSystemProperty.resolveSystemProperty(attributeName);
addToModel(arguments, resultVar, attributeValue);
}
示例11: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
SparkRequestContext blcContext = SparkRequestContext.getSparkRequestContext();
HttpServletRequest request = blcContext.getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
SearchFacetDTO facet = (SearchFacetDTO) expression.execute(arguments.getConfiguration(), arguments);
String key = facet.getFacet().getField().getAbbreviation();
params.remove(key);
params.remove(ProductSearchCriteria.PAGE_NUMBER);
String url = ProcessorUtils.getUrl(baseUrl, params);
attrs.put("href", url);
return attrs;
}
示例12: 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;
}
示例13: 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;
}
示例14: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName));
Object component = expression.execute(arguments.getConfiguration(), arguments);
String fieldName = "";
String id = "";
if (component instanceof ListGrid) {
ListGrid lg = (ListGrid) component;
fieldName = "listGrid-";
if (ListGrid.Type.MAIN.toString().toLowerCase().equals(lg.getListGridType())) {
fieldName += ListGrid.Type.MAIN.toString().toLowerCase();
} else {
fieldName = fieldName + lg.getListGridType() + '-' + lg.getSubCollectionFieldName();
}
} else if (component instanceof Field) {
Field field = (Field) component;
fieldName = "field-" + field.getName();
}
if (StringUtils.isNotBlank(fieldName)) {
id = cleanCssIdString(fieldName);
}
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("id", id);
return attrs;
}
示例15: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attrs = new HashMap<String, String>();
HttpServletRequest request = BroadleafRequestContext.getBroadleafRequestContext().getRequest();
boolean secureRequest = true;
if (request != null) {
secureRequest = isRequestSecure(request);
}
String elementValue = element.getAttributeValue(attributeName);
if (elementValue.startsWith("/")) {
elementValue = "@{ " + elementValue + " }";
}
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, elementValue);
String assetPath = (String) expression.execute(arguments.getConfiguration(), arguments);
// We are forcing an evaluation of @{} from Thymeleaf above which will automatically add a contextPath, no need to
// add it twice
assetPath = staticAssetPathService.convertAssetPath(assetPath, null, secureRequest);
attrs.put("src", assetPath);
return attrs;
}