org.thymeleaf.standard.expression.StandardExpressions Java Examples
The following examples show how to use
org.thymeleaf.standard.expression.StandardExpressions.
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: DictShowProcessor.java From FEBS-Security with Apache License 2.0 | 6 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) { String fieldName = tag.getAttribute(FIELD_NAME).getValue(); String keyy = tag.getAttribute(KEYY).getValue(); final IEngineConfiguration configuration = context.getConfiguration(); final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration); final IStandardExpression expression = parser.parseExpression(context, keyy); final String realvalue = String.valueOf(expression.execute(context)); ApplicationContext appCtx = SpringContextUtils.getApplicationContext(context); DictService dictService = appCtx.getBean(DictService.class); Dict dict = dictService.findDictByFieldNameAndKeyy(fieldName, realvalue); if (log.isDebugEnabled()) { log.debug("dict== fieldName:{}, keyy:{}, realvalue:{}", fieldName, keyy, realvalue); } String label = ""; if (dict != null) { label = dict.getValuee(); } structureHandler.replaceWith(label, false); }
Example #2
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 #3
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 #4
Source File: Expressions.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 5 votes |
public static Object evaluate(IExpressionContext context, String expressionValue) { final String value = String.valueOf(expressionValue).trim(); final IStandardExpressionParser expressionParser = StandardExpressions .getExpressionParser(context.getConfiguration()); final IStandardExpression expression = expressionParser.parseExpression(context, value); return expression.execute(context); }
Example #5
Source File: DictSelectProcessor.java From FEBS-Security with Apache License 2.0 | 4 votes |
@Override protected void doProcess(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) { String fieldName = tag.getAttribute(FIELD_NAME).getValue(); IAttribute valueAttr = tag.getAttribute(KEYY); IAttribute clsAttr = tag.getAttribute(CLS); IAttribute nameAttr = tag.getAttribute(NAME); IAttribute idAttr = tag.getAttribute(ID); final IEngineConfiguration configuration = context.getConfiguration(); final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration); String realvalue = ""; if (valueAttr != null) { final IStandardExpression valueexpression = parser.parseExpression(context, valueAttr.getValue()); realvalue = String.valueOf(valueexpression.execute(context)); if (log.isDebugEnabled()) log.debug("dict== fieldName:{}, keyy:{}, realvalue:{}", fieldName, valueAttr.getValue(), realvalue); } ApplicationContext appCtx = SpringContextUtils.getApplicationContext(context); DictService dictService = appCtx.getBean(DictService.class); List<Dict> dicts = dictService.findDictByFieldName(fieldName); StringBuilder options = new StringBuilder(); String selected = ""; for (Dict dict : dicts) { if (valueAttr != null && realvalue.equals(dict.getKeyy())) selected = " selected=selected "; else selected = ""; options.append("<option value=\"").append(dict.getKeyy()).append("\" ").append(selected).append(">").append(dict.getValuee()).append("</option>"); } StringBuilder select = new StringBuilder("<select"); if (clsAttr != null) select.append(" class=\"").append(clsAttr.getValue()).append("\""); if (nameAttr != null) select.append(" name=\"").append(nameAttr.getValue()).append("\""); if (idAttr != null) select.append(" id=\"").append(idAttr.getValue()).append("\""); select.append(">"); select.append(options); select.append("<select>"); structureHandler.replaceWith(select.toString(), false); }
Example #6
Source File: PageUtils.java From thymeleaf-spring-data-dialect with Apache License 2.0 | 4 votes |
public static Page<?> findPage(final ITemplateContext context) { // 1. Get Page object from local variables (defined with sd:page-object) // 2. Search Page using ${page} expression // 3. Search Page object as request attribute final Object pageFromLocalVariable = context.getVariable(Keys.PAGE_VARIABLE_KEY); if (isPageInstance(pageFromLocalVariable)) { return (Page<?>) pageFromLocalVariable; } // Check if not null and Page instance available with ${page} expression final IEngineConfiguration configuration = context.getConfiguration(); final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration); final IStandardExpression expression = parser.parseExpression(context, Keys.PAGE_EXPRESSION); final Object page = expression.execute(context); if (isPageInstance(page)) { return (Page<?>) page; } // Search for Page object, and only one instance, as request attribute if (context instanceof IWebContext) { HttpServletRequest request = ((IWebContext) context).getRequest(); Enumeration<String> attrNames = request.getAttributeNames(); Page<?> pageOnRequest = null; while (attrNames.hasMoreElements()) { String attrName = (String) attrNames.nextElement(); Object attr = request.getAttribute(attrName); if (isPageInstance(attr)) { if (pageOnRequest != null) { throw new InvalidObjectParameterException("More than one Page object found on request!"); } pageOnRequest = (Page<?>) attr; } } if (pageOnRequest != null) { return pageOnRequest; } } throw new InvalidObjectParameterException("Invalid or not present Page object found on request!"); }