Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Unique IDs for Repeatable Content

Note

It was decided to make editableComboBox work in a hetero-list or repeatable by using CSS class instead of ID to identify the combobox element, so use of IDs in repeatable content is still not supported. If the scheme described below would help you, let us know on the dev alias.

Some form content in Hudson consists of elements that may be added multiple times (build steps, java versions, log levels, etc.), resulting in form elements that get dynamically duplicated in the page when the user adds another instance. This causes problems if the duplicated content includes any id attributes, as these ids should be unique in the page.

Starting in Hudson 1.350 you can generate unique ids for f:hetero-list (which includes config.jelly for a Builder) or f:repeatable content as follows:

In the content that will be repeated, use @ID@ to generate a unique value in an id. Example:

<div id="mydiv_@ID@">...</div>

To use the same id value multiple times, add a positive number in the token. Example:

<div id="mydiv_@ID1@">...</div>
<script>var d = document.getElementById('mydiv_@ID1@'); ...</script>

or

<f:entry title="${%Project Name}" field="projectName">
  <f:editableComboBox id="myplugin_project_@ID1@" items="${app.topLevelItemNames}"/>
</f:entry>

In short:

  • Every @ID@ gets a unique value.
  • The first case of each @ID##@ also gets a new unique value, but all subsequent cases of the same ## get the same value. Remember that other content/elements may use the same ## value, so use a prefix to make the end result unique, as with mydiv_ and myplugin_project_ in the examples above.

Back to the top