[
https://issues.apache.org/jira/browse/WICKET-7114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17899329#comment-17899329
]
Pedro Santos commented on WICKET-7114:
--------------------------------------
To fix the repeated markup id in the development environment it would suffice
to simplify the DefaultMarkupIdGenerator to always work as it does in
deployment mode. During development, Wicket already outputs the component id in
the wicket:id attribute. If the OP is ok with, I can create a pull request with
his test case.
I took a look at Roman's post. If he is inside a stateless page, a new session
will be created for each response, making the session.nextSequenceValue() to
start at 1 every time. It would happen if all AJAX behaviors have overwritten
Behavior#getStatelessHint to return true (a bad practice imo). In such case,
parts of the page returned by AJAX responses would indeed be vulnerable to
duplicated ids.
> DefaultMarkupIdGenerator creates duplicate IDs in
> RuntimeConfigurationType.DEVELOPMENT
> --------------------------------------------------------------------------------------
>
> Key: WICKET-7114
> URL: https://issues.apache.org/jira/browse/WICKET-7114
> Project: Wicket
> Issue Type: Bug
> Components: wicket-core
> Affects Versions: 8.15.0, 9.17.0, 10.1.0
> Reporter: Simon Voges
> Priority: Minor
>
> While testing an application for accessibility, I noticed the analyzer
> reporting duplicated ids in markup. The issue was hard to reproduce, so I
> didn't give it much attention.
> When I finally found a way to reproduce it, I tracked it down to a bug in
> {{{}DefaultMarkupIdGenerator{}}}. If the application is running in
> Development mode, the {{DefaultMarkupIdGenerator}} will prefix every
> generated MarkupId with the Components id. If the component is a repeaters
> child, the ID will be numeric.
> Dependening on the order of the Components, it is possible that
> {{DefaultMarkupIdGenerator}} will generate duplicated ids.
>
> ||markupIdPrefix (component.getId())||markupIdPostfix (sequence value as hex
> string)||effective markupId||
> |11|a|11a|
> |1|1a|11a|
> Fixing it by adding a delimiter seems like a straightforward solution, but
> I'm not sure what could break down the road. I'm especially worried that many
> tests might brake in the wild, because it is just so convenient to use the
> markup ids in the tests.
>
> Duplicate IDs are a problem because it just breaks the spec.
> {quote}
> The id global attribute defines an identifier (ID) which must be unique in
> the whole document.
> {quote}
> [mdn
> webdocs|https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id]
> *Steps to reproduce*
> Please have a look into https://github.com/HerrDietz/WICKET-7114. This repo
> contains two test cases. One is a unit test for {{DefaultMarkupIdGenerator}},
> the other one renders a page containing a duplicated id.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)