/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

  1. <!--
  2. The MIT License
  3. Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. -->
  20. <?jelly escape-by-default='true'?>
  21. <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">
  22. <st:documentation>
  23. Generate config pages from a list of Descriptors into a section.
  24. <st:attribute name="title">
  25. Human readable title of the section to be rendered in HTML.
  26. </st:attribute>
  27. <st:attribute name="descriptors" use="required">
  28. hudson.model.Descriptor collection whose configuration page is rendered.
  29. </st:attribute>
  30. <st:attribute name="instances">
  31. Map&lt;Descriptor,Describable> that defines current instances of those descriptors.
  32. These are used to fill initial values. Other classes that define the get(Descriptor)
  33. method works fine, too, such as DescribableList.
  34. </st:attribute>
  35. <st:attribute name="field">
  36. Either @field or @instances are required (or @field needs to be inherited from the ancestor &lt;entry> elemetn.
  37. If field is specified, instances are assumed to be instance[field].
  38. When this attribute is specified, JSON structure is properly set up so that the databinding
  39. can set the field (or pass this collection as a constructor parameter of the same name.
  40. This is more modern way of doing databinding, and thus preferred approach.
  41. </st:attribute>
  42. <st:attribute name="targetType">
  43. the type for which descriptors will be configured.
  44. default to ${it.class}
  45. </st:attribute>
  46. </st:documentation>
  47. <j:if test="${attrs.field==null}">
  48. <!-- inherit @field if we should do so -->
  49. <j:set target="${attrs}" property="field" value="${entry.field}" />
  50. </j:if>
  51. <j:set var="targetType" value="${attrs.targetType ?: it.class}"/>
  52. <j:set var="instances" value="${attrs.instances ?: instance[field] ?: descriptor['default'+h.capitalize(field)]}"/>
  53. <j:if test="${!empty(descriptors) or context['org.apache.commons.jelly.body']!=null}">
  54. <f:section title="${attrs.title}" name="${attrs.field?:attrs.name}">
  55. <j:if test="${attrs.field!=null}">
  56. <tr>
  57. <td>
  58. <input type="hidden" name="stapler-class-bag" value="true" />
  59. </td>
  60. </tr>
  61. </j:if>
  62. <d:invokeBody />
  63. <j:forEach var="d" items="${descriptors}">
  64. <f:optionalBlock name="${d.jsonSafeClassName}" help="${d.helpFile}"
  65. title="${d.displayName}" checked="${instances.get(d)!=null}">
  66. <j:set var="descriptor" value="${d}" />
  67. <j:set var="instance" value="${instances.get(d)}" />
  68. <st:include from="${d}" page="${d.configPage}" optional="true" />
  69. </f:optionalBlock>
  70. </j:forEach>
  71. </f:section>
  72. </j:if>
  73. </j:jelly>