Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ see wiki for more information: [wiki](https://github.com/thmarx/cms/wiki)
* **FEATURE** add system module for default markdown renderer [#394](https://github.com/CondationCMS/cms-server/pull/394)
* **BUG** Fix request context issues [#392](https://github.com/CondationCMS/cms-server/pull/392)
* **BUG** Missing template filter (date) added [#397](https://github.com/CondationCMS/cms-server/pull/397)
* **FEATURE** Add variables to request context to share data in request scope [#403](https://github.com/CondationCMS/cms-server/pull/403)
* **FEATURE** use request variables in expression context [#404](https://github.com/CondationCMS/cms-server/pull/404)

## 7.6.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,28 @@ private Parameter evaluateAttributes(Parameter rawAttributes, Map<String, Object
for (Map.Entry<String, Object> entry : rawAttributes.entrySet()) {
String key = entry.getKey();
String rawValue = (String) entry.getValue(); // Rohwert als String
evaluatedAttributes.put(key, parseValue(rawValue, contextModel)); // Wert erst jetzt parsen
evaluatedAttributes.put(key, parseValue(rawValue, contextModel, requestContext)); // Wert erst jetzt parsen
}
return evaluatedAttributes;
}

// Methode zur Auswertung von Attributwerten im zweiten Schritt
private Object parseValue(String value, Map<String, Object> contextModel) {
private Object parseValue(String value, Map<String, Object> contextModel, RequestContext requestContext) {
if (value.matches("\\d+")) {
return Integer.valueOf(value);
} else if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
return Boolean.valueOf(value);
} else if (value.startsWith("${") && value.endsWith("}")) {
String expressionString = value.substring(2, value.length() - 1);

var contextMap = new HashMap<String, Object>();
contextMap.putAll(contextModel);
if (requestContext != null) {
contextMap.putAll(requestContext.getVariables());
}

var expression = engine.createExpression(expressionString);
return expression.evaluate(new MapContext(contextModel));
return expression.evaluate(new MapContext(contextMap));
}
return value;
}
Expand Down