Skip to content

Using array syntax generates invalid id using freemarker [SPR-8732] #13374

@spring-projects-issues

Description

@spring-projects-issues

Przemek Ch opened SPR-8732 and commented

Method

protected String autogenerateId() throws JspException {
     return StringUtils.deleteAny(getName(), "[]");
}

form AbstractDataBoundFormElementTag class doesn't work with freemarker.

Example

<@spring.formInput path="lead.additionalSalesList[1].saleResult.policyId" attributes='class="policyId_1"'/>

generates

<input id="additionalSalesList[1].saleResult.policyId" class="policyId_0" type="text" value="" name="additionalSalesList[1].saleResult.policyId">

According to https://jira.springsource.org/browse/SPR-2380 the code above should generate id="additionalSalesList1.saleResult.policyId"

[] in ID is not a valid HTML so libraries like jQuery cant handle such elements

Tricks like this $(":input[name='additionalSalesList[1]\\.saleResult\\.policyId']") are needed now to select such items using jQuery.


Affects: 3.0.6

Issue Links:

Referenced from: commits ba03d5b, e7e74c8, a9f4206

2 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions