Skip to content

Commit

Permalink
Doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Apr 11, 2015
1 parent 4e2efcd commit 3c4b1e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/model/Descriptor.java
Expand Up @@ -910,6 +910,9 @@ List<T> newInstancesFromHeteroList(StaplerRequest req, Object formData,
for (Object o : JSONArray.fromObject(formData)) {
JSONObject jo = (JSONObject)o;
Descriptor<T> d = null;
// 'kind' and '$class' are mutually exclusive (see class-entry.jelly), but to be more lenient on the reader side,
// we check them both anyway. 'kind' (which maps to ID) is more unique than '$class', which can have multiple matching
// Descriptors, so we prefer 'kind' if it's present.
String kind = jo.optString("kind", null);
if (kind != null) {
d = findById(descriptors, kind);
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/resources/lib/form/class-entry.jelly
Expand Up @@ -26,6 +26,16 @@ THE SOFTWARE.
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<st:documentation>
Invisible &lt;f:entry> type for embedding a descriptor's $class field.

Most of the time a Descriptor has an unique class name that we can use to instantiate the right Describable
class, so we use the '$class' to represent that to clarify the intent.

In some other times, such as templates, there are multiple Descriptors with the same Descriptor.clazz
but different IDs, and in that case we put 'kind' to indicate that. In this case, to avoid confusing
readers we do not put non-unique '$class'.

See Descriptor.newInstancesFromHeteroList for how the reader side is handled.

<st:attribute name="clazz">
The describable class that we are instantiating via structured form submission.
</st:attribute>
Expand Down

0 comments on commit 3c4b1e6

Please sign in to comment.