/hudson-core/src/main/resources/lib/form/descriptorList.jelly
http://github.com/hudson/hudson · Unknown · 86 lines · 73 code · 13 blank · 0 comment · 0 complexity · e13eb9500c03bcdc898390baf2b8a0fe MD5 · raw file
- <!--
- The MIT License
- Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- -->
- <?jelly escape-by-default='true'?>
- <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
- <st:documentation>
- Generate config pages from a list of Descriptors into a section.
- <st:attribute name="title">
- Human readable title of the section to be rendered in HTML.
- </st:attribute>
- <st:attribute name="descriptors" use="required">
- hudson.model.Descriptor collection whose configuration page is rendered.
- </st:attribute>
- <st:attribute name="instances">
- Map<Descriptor,Describable> that defines current instances of those descriptors.
- These are used to fill initial values. Other classes that define the get(Descriptor)
- method works fine, too, such as DescribableList.
- </st:attribute>
- <st:attribute name="field">
- Either @field or @instances are required (or @field needs to be inherited from the ancestor <entry> elemetn.
- If field is specified, instances are assumed to be instance[field].
- When this attribute is specified, JSON structure is properly set up so that the databinding
- can set the field (or pass this collection as a constructor parameter of the same name.
- This is more modern way of doing databinding, and thus preferred approach.
- </st:attribute>
- <st:attribute name="targetType">
- the type for which descriptors will be configured.
- default to ${it.class}
- </st:attribute>
- </st:documentation>
- <j:if test="${attrs.field==null}">
- <!-- inherit @field if we should do so -->
- <j:set target="${attrs}" property="field" value="${entry.field}" />
- </j:if>
- <j:set var="targetType" value="${attrs.targetType ?: it.class}"/>
- <j:set var="instances" value="${attrs.instances ?: instance[field] ?: descriptor['default'+h.capitalize(field)]}"/>
- <j:if test="${!empty(descriptors) or context['org.apache.commons.jelly.body']!=null}">
- <f:section title="${attrs.title}" name="${attrs.field?:attrs.name}">
- <j:if test="${attrs.field!=null}">
- <tr>
- <td>
- <input type="hidden" name="stapler-class-bag" value="true" />
- </td>
- </tr>
- </j:if>
- <d:invokeBody />
- <j:forEach var="d" items="${descriptors}">
- <f:optionalBlock name="${d.jsonSafeClassName}" help="${d.helpFile}"
- title="${d.displayName}" checked="${instances.get(d)!=null}">
- <j:set var="descriptor" value="${d}" />
- <j:set var="instance" value="${instances.get(d)}" />
- <st:include from="${d}" page="${d.configPage}" optional="true" />
- </f:optionalBlock>
- </j:forEach>
- </f:section>
- </j:if>
- </j:jelly>