Skip to content

Cannot call #fields.detailedErrors() from a Spring Webflow form #175

Open
@jchafik

Description

@jchafik

Thymeleaf 3.0.9.RELEASE
Thymeleaf Security 3.0.2.RELEASE
Thymeleaf Layout 2.2.2

Spring 4.3.13.RELEASE
Spring Webflow 2.4.5.RELEASE

Calling #fields.detailedErrors() from a Spring Webflow form results in a BindingModel$FieldPrefixErrorMessage exception.

The issue is that Webflow has its own getFieldErrors method that does not accept a wildcard without the field prefix (org.springframework.webflow.mvc.view.BindingModel.getFieldErrors(String)). I believe it expects beanName.expression instead of expression, or for you to explicitly call getAllErrors if attempting to get all errors (as is done in the constructor for org.springframework.web.servlet.support.BindStatus):

if ("*".equals(this.expression)) {
    this.objectErrors = this.errors.getAllErrors();
}
else if (this.expression.endsWith("*")) {
    this.objectErrors = this.errors.getFieldErrors(this.expression);
}
else {
    this.objectErrors = this.errors.getFieldErrors(this.expression);
    ...
}

Relevant stack trace:

Caused by: java.lang.IllegalArgumentException: The fieldPrefix is required
    at org.springframework.util.Assert.hasText(Assert.java:181)
    at org.springframework.webflow.mvc.view.BindingModel$FieldPrefixErrorMessage.<init>(BindingModel.java:353)
    at org.springframework.webflow.mvc.view.BindingModel.getFieldErrors(BindingModel.java:123)
    at org.thymeleaf.spring4.util.FieldUtils.computeDetailedErrors(FieldUtils.java:166)
    at org.thymeleaf.spring4.util.FieldUtils.detailedErrors(FieldUtils.java:114)
    at org.thymeleaf.spring4.expression.Fields.detailedErrors(Fields.java:94)

I believed this was introduced by the fix to #90

a417f24#diff-7ed912361ca43f85acc57b043a7f8dd1R166

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions