本文整理汇总了Java中org.thymeleaf.dom.Element.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getAttributeValue方法的具体用法?Java Element.getAttributeValue怎么用?Java Element.getAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.dom.Element
的用法示例。
在下文中一共展示了Element.getAttributeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isVisible
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) {
String attributeValue = element.getAttributeValue(attributeName);
if (StringUtils.indexOf(attributeValue, "isAdminPage") != -1) {
Object context = arguments.getContext();
if (context instanceof SpringWebContext) {
SpringWebContext webContext = (SpringWebContext) context;
HttpServletRequest httpServletRequest = webContext.getHttpServletRequest();
boolean val = StringUtils.indexOf(httpServletRequest.getRequestURI(), "/_admin/") != -1;
attributeValue = StringUtils.replace(attributeValue, "isAdminPage", Boolean.toString(val));
}
}
final Configuration configuration = arguments.getConfiguration();
final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);
final IStandardExpression expression = expressionParser.parseExpression(configuration, arguments, attributeValue);
final Object value = expression.execute(configuration, arguments);
final boolean visible = EvaluationUtil.evaluateAsBoolean(value);
return visible;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: getAttributeValue
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
/**
* Returns a default name
* @param element
* @param valueName
* @return
*/
protected String getAttributeValue(Element element, String valueName, String defaultValue) {
String returnValue = element.getAttributeValue(valueName);
if (returnValue == null) {
return defaultValue;
} else {
return returnValue;
}
}
示例5: getRatingsVar
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
private String getRatingsVar(Element element) {
String ratingsVar = element.getAttributeValue("ratingsVar");
if (StringUtils.isNotEmpty(ratingsVar)) {
return ratingsVar;
}
return "ratingSummary";
}
示例6: getRelatedProductsResultVar
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
private String getRelatedProductsResultVar(Element element) {
String resultVar = element.getAttributeValue("relatedProductsResultVar");
if (resultVar == null) {
resultVar = "relatedProducts";
}
return resultVar;
}
示例7: modifyModelAttributes
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected void modifyModelAttributes(Arguments arguments, Element element) {
String key = element.getAttributeValue("key");
if (StringUtils.isEmpty(key)) {
throw new IllegalArgumentException("No 'key' parameter was passed to find enumeration values");
}
DataDrivenEnumeration ddEnum = enumService.findEnumByKey(key);
if (ddEnum == null) {
throw new IllegalArgumentException("Could not find a data driven enumeration keyed by " + key);
}
List<DataDrivenEnumerationValue> enumValues = new ArrayList<DataDrivenEnumerationValue>(ddEnum.getEnumValues());
final String sort = element.getAttributeValue("sort");
if (StringUtils.isNotEmpty(sort)) {
Collections.sort(enumValues, new Comparator<DataDrivenEnumerationValue>() {
@Override
public int compare(DataDrivenEnumerationValue arg0, DataDrivenEnumerationValue arg1) {
if (sort.equals("ASCENDING")) {
return arg0.getDisplay().compareTo(arg1.getDisplay());
} else {
return arg1.getDisplay().compareTo(arg0.getDisplay());
}
}
});
}
addToModel(arguments, "enumValues", enumValues);
}
示例8: 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 = BLCSystemProperty.resolveSystemProperty(attributeName);
addToModel(arguments, resultVar, attributeValue);
}
示例9: computeFragment
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected List<Node> computeFragment(final Arguments arguments, final Element element) {
// The pageTitle attribute could be an expression that needs to be evaluated. Try to evaluate, but fall back
// to its text value if the expression wasn't able to be processed. This will allow things like
// pageTitle="Hello this is a string"
// as well as expressions like
// pageTitle="${'Hello this is a ' + product.name}"
String pageTitle = element.getAttributeValue("pageTitle");
try {
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, pageTitle);
pageTitle = (String) expression.execute(arguments.getConfiguration(), arguments);
} catch (TemplateProcessingException e) {
// Do nothing.
}
((Map<String, Object>) arguments.getExpressionEvaluationRoot()).put("pageTitle", pageTitle);
((Map<String, Object>) arguments.getExpressionEvaluationRoot()).put("additionalCss", element.getAttributeValue("additionalCss"));
extensionManager.processAttributeValues(arguments, element);
//the commit at https://github.com/thymeleaf/thymeleaf/commit/b214d9b5660369c41538e023d4b8d7223ebcbc22 along with
//the referenced issue at https://github.com/thymeleaf/thymeleaf/issues/205
// return new FragmentAndTarget(HEAD_PARTIAL_PATH, WholeFragmentSpec.INSTANCE);
return new ArrayList<Node>();
}
示例10: modifyModelAttributes
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected void modifyModelAttributes(Arguments arguments, Element element) {
String orderNumber = element.getAttributeValue("orderNumber");
Order order = null;
if (orderNumber != null) {
order = orderService.findOrderByOrderNumber(orderNumber);
}
addToModel(arguments, "analytics", analytics(getWebPropertyId(), order));
}
示例11: getProductsResultVar
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
private String getProductsResultVar(Element element) {
String resultVar = element.getAttributeValue("productsResultVar");
if (resultVar == null) {
resultVar = "products";
}
return resultVar;
}
示例12: getStringValue
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
protected String getStringValue(Arguments arguments, Element element, String attrName, boolean removeAttribute) {
if (element.hasAttribute(attrName)) {
String cacheKeyParam = element.getAttributeValue(attrName);
Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
.parseExpression(arguments.getConfiguration(), arguments, cacheKeyParam);
if (removeAttribute) {
element.removeAttribute(attrName);
}
return expression.execute(arguments.getConfiguration(), arguments).toString();
}
return "";
}
示例13: getText
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected String getText(final Arguments arguments, final Element element, final String attributeName) {
final String attributeValue = element.getAttributeValue(attributeName);
final Object result = ProcessorUtil.parse(arguments, attributeValue, true);
return (result == null ? "" : process(result));
}
示例14: getModifiedAttributeValues
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected Map<String, String> getModifiedAttributeValues(Arguments arguments, Element element, String attributeName) {
Map<String, String> attributes = new HashMap<String, String>();
HttpServletRequest request = SparkRequestContext.getSparkRequestContext().getRequest();
String baseUrl = request.getRequestURL().toString();
Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());
String sort = element.getAttributeValue(attributeName);
if (StringUtils.isNotBlank(sort)) {
params.put(ProductSearchCriteria.SORT_STRING, new String[]{sort});
} else {
params.remove(ProductSearchCriteria.SORT_STRING);
}
// If there is a page number parameter, remove it. This ensures that when the search results refresh the
// first page of results will be displayed.
params.remove(ProductSearchCriteria.PAGE_NUMBER);
String url = ProcessorUtils.getUrl(baseUrl, params);
attributes.put("href", url);
return attributes;
}
示例15: getText
import org.thymeleaf.dom.Element; //导入方法依赖的package包/类
@Override
protected final String getText(final Arguments arguments, final Element element, final String attributeName) {
final String attributeValue = element.getAttributeValue(attributeName);
final Object result = ProcessorUtil.parse(arguments, attributeValue, false);
return (result == null ? "" : process(result));
}