Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d7b94bf501083b082c0d50a1a56421cdcb75b2ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!-- **************************************************************************
#
# Copyright (c) 2010, InfraDNA, Inc.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors: 
#
#   
#        
#
#************************************************************************** --> 

<?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>
    Renders a single &lt;select> control for choosing a Describable.
    Depending on the currently selected value, its config.jelly will be
    rendered below &lt;select, allowing the user to configure Describable.

    <st:attribute name="field" use="required">
      form field name. Used for databinding.
    </st:attribute>
    <st:attribute name="title" use="required">
      Human readable title of this control.
    </st:attribute>
    <st:attribute name="descriptors">
      Collection that lists up all the valid candidate descriptors.
      If unspecified, inferred from the type of the field.
    </st:attribute>
    <st:attribute name="default">
      If specified, this will be chosen as the default value in case the current selection is null.
    </st:attribute>
  </st:documentation>

  <j:set target="${attrs}" property="descriptors" value="${attrs.descriptors ?: descriptor.getPropertyType(instance,attrs.field).getApplicableDescriptors()}" />

  <f:dropdownList name="${attrs.field}" title="${attrs.title}" help="${descriptor.getHelpFile(attrs.field)}">
    <d:invokeBody />

    <j:set var="current" value="${instance[attrs.field]}"/>
    <j:forEach var="descriptor" items="${attrs.descriptors}" varStatus="loop">
      <f:dropdownListBlock value="${loop.index}" title="${descriptor.displayName}"
        selected="${current.descriptor==descriptor || (current==null and descriptor==attrs.default)}" staplerClass="${descriptor.clazz.name}">
        <j:set var="instance" value="${current.descriptor==descriptor ? current : null}" />
        <st:include from="${descriptor}" page="${descriptor.configPage}" />
      </f:dropdownListBlock>
    </j:forEach>
  </f:dropdownList>
</j:jelly>

Back to the top