org.thymeleaf.engine.AttributeName Java Examples
The following examples show how to use
org.thymeleaf.engine.AttributeName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnabledImageTagProcessor.java From konker-platform with Apache License 2.0 | 6 votes |
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"); }
Example #2
Source File: PrincipalAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 6 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String type = iProcessableElementTag.getAttributeValue("type"); final String property = iProcessableElementTag.getAttributeValue("property"); final String text = ShiroFacade.getPrincipalText(type, property); final String elementCompleteName = iProcessableElementTag.getElementCompleteName(); final IModelFactory modelFactory = iTemplateContext.getModelFactory(); final IModel model = modelFactory.createModel(); model.add(modelFactory.createOpenElementTag(elementCompleteName)); model.add(modelFactory.createText(HtmlEscape.escapeHtml5(text))); model.add(modelFactory.createCloseElementTag(elementCompleteName)); iElementTagStructureHandler.replaceWith(model, false); }
Example #3
Source File: PaginationSortBaseAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 6 votes |
@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, getForcedDirection()); // 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)); }
Example #4
Source File: PaginationSummaryAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 6 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { // Compose message with parameters: // {0} first reg. position // {1} latest page reg. position // {2} total elements // pagination.summary=Showing {0} to {1} of {2} entries Locale locale = context.getLocale(); Page<?> page = PageUtils.findPage(context); int firstItem = PageUtils.getFirstItemInPage(page); int latestItem = PageUtils.getLatestItemInPage(page); int totalElements = (int) page.getTotalElements(); boolean isEmpty = page.getTotalElements() == 0; String attrValue = String.valueOf(attributeValue).trim(); String messageTemplate = COMPACT.equals(attrValue) ? COMPACT_MESSAGE_KEY : DEFAULT_MESSAGE_KEY; String messageKey = isEmpty ? NO_VALUES_MESSAGE_KEY : messageTemplate; String message = Messages.getMessage(BUNDLE_NAME, messageKey, locale, firstItem, latestItem, totalElements); structureHandler.setBody(message, false); }
Example #5
Source File: PageObjectAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 6 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { if (context instanceof WebEngineContext) { Object page = Expressions.evaluate(context, attributeValue); if (!(page instanceof Page<?>)) { throw new InvalidObjectParameterException( "Parameter " + attributeValue + " is not an Page<?> instance!"); } ((WebEngineContext) context).setVariable(Keys.PAGE_VARIABLE_KEY, page); } }
Example #6
Source File: HasAllPermissionsAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAllPermissions(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #7
Source File: ThymeleafFacade.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
public static String getRawValue(final IProcessableElementTag element, final AttributeName attributeName) { notNull(element, "element must not be null"); notNull(attributeName, "attributeName must not be empty"); final String rawValue = trim(element.getAttributeValue(attributeName)); notEmpty(rawValue, "value of '" + attributeName + "' must not be empty"); return rawValue; }
Example #8
Source File: GuestAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { if (ShiroFacade.isGuest()) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #9
Source File: HasAllRolesAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAllRoles(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #10
Source File: UserAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { if (ShiroFacade.isUser()) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #11
Source File: HasAnyRolesAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAnyRoles(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #12
Source File: AuthenticatedAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { if (ShiroFacade.isAuthenticated()) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #13
Source File: HasPermissionAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAllPermissions(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #14
Source File: NotAuthenticatedAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { if (ShiroFacade.isNotAuthenticated()) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #15
Source File: HasAnyPermissionsAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAnyPermissions(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #16
Source File: LacksRoleAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (!ShiroFacade.hasAnyRoles(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #17
Source File: LacksPermissionAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (!ShiroFacade.hasAnyPermissions(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #18
Source File: HasRoleAttrProcessor.java From thymeleaf-extras-shiro with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext iTemplateContext, IProcessableElementTag iProcessableElementTag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler iElementTagStructureHandler) { final String rawValue = getRawValue(iProcessableElementTag, attributeName); final List<String> values = evaluateAsStringsWithDelimiter(iTemplateContext, rawValue, DELIMITER); if (ShiroFacade.hasAllRoles(values)) { iElementTagStructureHandler.removeAttribute(attributeName); } else { iElementTagStructureHandler.removeElement(); } }
Example #19
Source File: DataProcessor.java From thymeleaf-extras-data-attribute with Apache License 2.0 | 5 votes |
@Override public void process(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) { TemplateMode templateMode = getTemplateMode(); IAttribute[] attributes = tag.getAllAttributes(); for (IAttribute attribute : attributes) { AttributeName attributeName = attribute.getAttributeDefinition().getAttributeName(); if (attributeName.isPrefixed()) { if (TextUtil.equals(templateMode.isCaseSensitive(), attributeName.getPrefix(), dialectPrefix)) { processDataAttribute(context, tag, attribute, structureHandler); } } } }
Example #20
Source File: PaginationUrlAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { if (context instanceof WebEngineContext) { Object url = Expressions.evaluate(context, attributeValue); ((WebEngineContext) context).setVariable(Keys.PAGINATION_URL_KEY, url); } }
Example #21
Source File: PaginationAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { String attrValue = String.valueOf(attributeValue).trim(); PaginationDecorator decorator = PaginationDecoratorRegistry.getInstance().getDecorator(attrValue); String html = decorator.decorate(tag, context); boolean isUlNode = Strings.UL.equalsIgnoreCase(tag.getElementCompleteName()); if (isUlNode) { structureHandler.replaceWith(html, false); } else { structureHandler.setBody(html, false); } }
Example #22
Source File: PaginationSplitAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { if (context instanceof WebEngineContext) { Number split = (Number) Expressions.evaluate(context, attributeValue); ((WebEngineContext) context).setVariable(Keys.PAGINATION_SPLIT_KEY, split.intValue()); } }
Example #23
Source File: PageSizeSelectorAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { Locale locale = context.getLocale(); loadSelectorValues(locale); String selectorStyle = String.valueOf(attributeValue).trim(); String messageKey = getMessageKey(selectorStyle); String options = composeSelectorOptions(selectorStyle, context); String message = Messages.getMessage(BUNDLE_NAME, messageKey, locale, options); structureHandler.setBody(message, false); }
Example #24
Source File: PaginationQualifierAttrProcessor.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { if (context instanceof WebEngineContext) { String attrValue = String.valueOf(attributeValue).trim(); ((WebEngineContext) context).setVariable(Keys.PAGINATION_QUALIFIER_PREFIX, attrValue); } }
Example #25
Source File: ThSysTagProcessor.java From mayday with GNU General Public License v3.0 | 5 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { final IEngineConfiguration configuration = context.getConfiguration(); final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration); final IStandardExpression expression = parser.parseExpression(context, attributeValue); final String title = (String) expression.execute(context); structureHandler.setBody(title + " - " + MaydayConst.OPTIONS.get("blog_name"), false); }
Example #26
Source File: ChallengeAttrProcessor.java From webauthn4j-spring-security with Apache License 2.0 | 4 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, AttributeName attributeName, String attributeValue, IElementTagStructureHandler structureHandler) { Challenge challenge = getChallenge(context); String challengeValue = java.util.Base64.getUrlEncoder().withoutPadding().encodeToString(challenge.getValue()); structureHandler.setAttribute(TARGET_ATTR_NAME, challengeValue); }
Example #27
Source File: PropertiesProcessor.java From wenku with MIT License | 4 votes |
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { structureHandler.setBody(PropertiesUtil.getValue(CastUtil.castString(expressionResult)), false); }
Example #28
Source File: PrettytimeProcessor.java From wenku with MIT License | 4 votes |
@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { structureHandler.setBody(RelativeDateFormat.format((Date) expressionResult), false); }