当前位置: 首页>>代码示例>>Java>>正文


Java Element.getAttributeValue方法代码示例

本文整理汇总了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;
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:26,代码来源:MyFunctionDialect.java

示例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);
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:38,代码来源:BroadleafCacheProcessor.java

示例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;
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:28,代码来源:UrlRewriteProcessor.java

示例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;
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:15,代码来源:ContentProcessor.java

示例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";
}
 
开发者ID:akdasari,项目名称:SparkCore,代码行数:8,代码来源:RatingsProcessor.java

示例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;
}
 
开发者ID:akdasari,项目名称:SparkCore,代码行数:8,代码来源:RelatedProductProcessor.java

示例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);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:31,代码来源:DataDrivenEnumerationProcessor.java

示例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);
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:13,代码来源:ConfigVariableProcessor.java

示例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>();
    }
 
开发者ID:takbani,项目名称:blcdemo,代码行数:30,代码来源:HeadProcessor.java

示例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));
}
 
开发者ID:akdasari,项目名称:SparkCore,代码行数:11,代码来源:GoogleAnalyticsProcessor.java

示例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;
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:8,代码来源:RelatedProductProcessor.java

示例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 "";
}
 
开发者ID:akdasari,项目名称:SparkCore,代码行数:14,代码来源:SimpleCacheKeyResolver.java

示例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));
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:10,代码来源:TextProcessor.java

示例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;

}
 
开发者ID:akdasari,项目名称:SparkCommerce,代码行数:31,代码来源:PaginationSortLinkProcessor.java

示例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));
}
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:10,代码来源:UTextProcessor.java


注:本文中的org.thymeleaf.dom.Element.getAttributeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。