本文整理汇总了Java中org.thymeleaf.processor.element.IElementTagStructureHandler.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java IElementTagStructureHandler.setAttribute方法的具体用法?Java IElementTagStructureHandler.setAttribute怎么用?Java IElementTagStructureHandler.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.processor.element.IElementTagStructureHandler
的用法示例。
在下文中一共展示了IElementTagStructureHandler.setAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doProcess
import org.thymeleaf.processor.element.IElementTagStructureHandler; //导入方法依赖的package包/类
protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
IStandardExpressionParser expressionParser = StandardExpressions
.getExpressionParser(context.getConfiguration());
IStandardExpression expression = expressionParser.parseExpression(context, attributeValue);
Boolean enabled = (Boolean) expression.execute(context);
if (enabled) {
expression = expressionParser.parseExpression(context, "@{/resources/konker/images/enabled.svg}");
} else {
expression = expressionParser.parseExpression(context, "@{/resources/konker/images/disabled.svg}");
}
structureHandler.setAttribute("src", (String) expression.execute(context));
structureHandler.setAttribute("class", (String) "enabled-img");
}
示例2: doProcess
import org.thymeleaf.processor.element.IElementTagStructureHandler; //导入方法依赖的package包/类
@Override
protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName,
String attributeValue, IElementTagStructureHandler structureHandler) {
String attrValue = String.valueOf(Expressions.evaluate(context, attributeValue)).trim();
Page<?> page = PageUtils.findPage(context);
String url = PageUtils.createSortUrl(context, attrValue);
// Append class to the element if sorted by this field
Sort sort = page.getSort();
boolean isSorted = sort != null && sort.getOrderFor(attrValue) != null;
String clas = isSorted
? SORTED_PREFIX.concat(sort.getOrderFor(attrValue).getDirection().toString().toLowerCase())
: EMPTY;
structureHandler.setAttribute(HREF, url);
String currentClass = tag.getAttributeValue(CLASS);
structureHandler.setAttribute(CLASS, Strings.concat(currentClass, BLANK, clas));
}
示例3: doProcess
import org.thymeleaf.processor.element.IElementTagStructureHandler; //导入方法依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String origurl = (String) expression.execute(context);
StringBuilder urlBuilder = new StringBuilder(origurl);
CsrfToken token = (CsrfToken) context.getVariable("_csrf");
// token è null quando il csrf è stato disabilitato
if (token!=null) {
final String tokenName = token.getParameterName();
final String tokenValue = token.getToken();
if (urlBuilder.lastIndexOf("?")>-1) {
urlBuilder.append("&");
} else {
urlBuilder.append("?");
}
urlBuilder.append(tokenName).append("=").append(tokenValue);
}
structureHandler.setAttribute("action", urlBuilder.toString());
}
示例4: doProcess
import org.thymeleaf.processor.element.IElementTagStructureHandler; //导入方法依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String semiurl = (String) expression.execute(context);
String resultUrl = yadaDialectUtil.getVersionedAttributeValue(context, semiurl);
/*
* Set the new value into the 'href' attribute
*/
if (resultUrl != null) {
structureHandler.setAttribute(ATTR_NAME, resultUrl);
}
}
示例5: doProcess
import org.thymeleaf.processor.element.IElementTagStructureHandler; //导入方法依赖的package包/类
@Override
protected void doProcess(
final ITemplateContext context, final IProcessableElementTag tag,
final AttributeName attributeName, final String attributeValue,
final IElementTagStructureHandler structureHandler) {
final IEngineConfiguration configuration = context.getConfiguration();
/*
* Obtain the Thymeleaf Standard Expression parser
*/
final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
/*
* Parse the attribute value as a Thymeleaf Standard Expression
*/
final IStandardExpression expression = parser.parseExpression(context, attributeValue);
/*
* Execute the expression just parsed
*/
final String semiurl = (String) expression.execute(context);
String resultUrl = yadaDialectUtil.getVersionedAttributeValue(context, semiurl);
/*
* Set the new value into the 'href' attribute
*/
if (resultUrl != null) {
structureHandler.setAttribute(ATTR_NAME, resultUrl);
}
}