Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using array syntax generates invalid id [SPR-2380] #7069

Closed
spring-issuemaster opened this issue Aug 3, 2006 · 12 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Aug 3, 2006

Bjørn Sættem opened SPR-2380 and commented

The tag <form:input path="array[0]" />

generates

<input id="array[0]" name="array[0]" type="text" value=""/>
but "[" and "]" are invalid in an identifier name. Ref. http://www.w3.org/TR/html4/types.html#type-name


Affects: 2.0 RC2

Issue Links:

  • #9375 form tags path attribute leaving square brackets out of id attribute of html tag

2 votes, 3 watchers

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 15, 2007

Fried Hoeben commented

Seems quite easy to change generated id to array0, which would be valid.

In AbstractDataBoundFormElementTag
protected String autogenerateId() throws JspException {
return getName().replaceAll("[", "").replaceAll("]","");
}

Of course a workaround is to specifiy the id explicitly...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 15, 2007

Juergen Hoeller commented

I've finally addressed this for Spring 2.5, so that no custom ids have to be specified in such a case anymore (in order to get valid HTML ids).

Thanks for raising this issue again, Fried!

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 31, 2010

Pablo commented

The same is happening in spring 2.5 with freemarker.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 29, 2011

Przemek Ch commented

The same is happening in spring 3.0.6 with freemarker.

<@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">

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 4, 2012

Stevo Slavić commented

This issue covered Spring form tag library generated id on JSP views/forms (see example in issue description), fix works OK, so IMO this issue shouldn't have been reopened, and should be closed now again.

A separate ticket, #13374, covers related issue on FreeMarker views/forms.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 5, 2012

Rossen Stoyanchev commented

Issue was resolved a while ago for JSP tags. A separate ticket tracks the same for Freemarker #13374.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 15, 2012

sivakrishna beerala commented

I am getting the same issue in spring web 3.0.5.please rcheck it once.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 15, 2012

Stevo Slavić commented

Sivakrishna, are you using Freemarker?

If so, then this is fixed in 3.2 M1 which is not released yet, but you have 3.2 snapshot builds in Spring snapshot repository or you can build latest Spring yourself (see this for instructions).

Otherwise, e.g. if it's issue in JSP views, feel free to provide sample reproduction project. If it's neither in JSP nor Freemarker, but in some other view technology instead, file a new JIRA ticket and attach a sample reproduction project.

See this guide on contributing Spring framework issue reproduction projects: https://github.com/SpringSource/spring-framework-issues#readme

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 19, 2012

sivakrishna beerala commented

No Iam not using Freemarker.i am using it in spring mvc jsp file itself.after checking the genarated html file its showing mailsList0,mailsList1 .... and so on
but in my jsp file i was declared path='mailsList[0]'. please do the need ful things to this bug.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 19, 2012

Stevo Slavić commented

Sivakrishna, this is expected behavior, result of a fix. IMO this issue can be closed as fixed in 2.5.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 19, 2012

Chris Beams commented

Re-resolving in light of comments.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 20, 2012

sivakrishna beerala commented

Hi

I intialized my array object to how much size i needed in form class then my problem solved.
Thanks to all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.