Question

How can I direct the user to select a value among a predefined list?

How can I direct the user to select a value among a predefined list?

Answer:

You can direct the user to select a value among a predefined list of values using a choice parameter. You will have to include a section like the one below inside the parameterList section of your XML installer project file. In GUI mode, it will be represented by a combobox. In text mode the user will be presented with a list.

<choiceParameter>
     <ask>1</ask>
     <default>http</default>
     <description>Which protocol?</description>
     <explanation>Default protocol to access the login page.</explanation>
     <title>Protocol Selection</title>
     <name>protocol</name>
     <optionList>
       <option>
         <value>http</value>
         <text>HTTP (insecure)</text>
       </option>
       <option>
         <value>https</value>
         <text>HTTPS (secure)</text>
       </option>
     </optionList>
</choiceParameter>

This will create an installer environment variable called protocol that will contain the value of the text selected by the user. You can later refer to the content of the that variable using ${protocol}. In this example, if the user selects HTTP (unsecure), the variable protocol will contain the value http.

Attached File

choice.xml

<project>
    <shortName>sample</shortName>
    <fullName>Sample Project</fullName>
    <version>1.0</version>
    <installerFilename></installerFilename>
    <readmeFile></readmeFile>
    <licenseFile></licenseFile>
    <wrapLicenseFileText>1</wrapLicenseFileText>
    <leftImage></leftImage>
    <logoImage></logoImage>
    <splashImage></splashImage>
    <defaultLanguage></defaultLanguage>
    <allowLanguageSelection>0</allowLanguageSelection>
    <postInstallationScript></postInstallationScript>
    <postInstallationScriptArguments></postInstallationScriptArguments>
    <showPostInstallationScriptResult>0</showPostInstallationScriptResult>
    <preUninstallationScript></preUninstallationScript>
    <preUninstallationScriptArguments></preUninstallationScriptArguments>
    <allowedLanguages></allowedLanguages>
    <cdromDirectory>${product_shortname}-${product_version}-cdrom</cdromDirectory>
    <cdromDiskSize>700000000</cdromDiskSize>
    <cdromFirstDiskSize>650000000</cdromFirstDiskSize>
    <defaultUnixDirectoryPermissions>755</defaultUnixDirectoryPermissions>
    <defaultUnixFilePermissions>644</defaultUnixFilePermissions>
    <outputDirectory>${installbuilder_install_root}/output</outputDirectory>
    <projectSchemaVersion>1.2</projectSchemaVersion>
    <saveRelativePaths>0</saveRelativePaths>
    <slideShowLoop>1</slideShowLoop>
    <slideShowTiming>5</slideShowTiming>
    <startMenuGroupName>${product_fullname}</startMenuGroupName>
    <style>standard</style>
    <uninstallerDirectory></uninstallerDirectory>
    <validatorProgram></validatorProgram>
    <componentList>
        <component>
            <name>default</name>
            <description>Default Component</description>
            <canBeEdited>1</canBeEdited>
            <detailedDescription></detailedDescription>
            <selected>1</selected>
            <show>1</show>
            <desktopShortcutList/>
            <folderList>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfiles</name>
                    <platforms>all</platforms>
                    <shortcutList>
                        <shortcut>
                            <comment>Uninstall</comment>
                            <exec>${installdir}/uninstall</exec>
                            <icon></icon>
                            <name>Uninstall ${product_fullname}</name>
                            <path>${installdir}</path>
                            <platforms>all</platforms>
                            <windowsExec>${installdir}/uninstall.exe</windowsExec>
                            <windowsExecArgs></windowsExecArgs>
                            <windowsIcon></windowsIcon>
                            <windowsPath>${installdir}</windowsPath>
                        </shortcut>
                    </shortcutList>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileslinux</name>
                    <platforms>linux</platforms>
                </folder>
                <folder>
                    <description>Program Files</description>
                    <destination>${installdir}</destination>
                    <name>programfileswindows</name>
                    <platforms>windows</platforms>
                </folder>
            </folderList>
            <startMenuShortcutList>
                <startMenuShortcut>
                    <comment>Uninstall ${product_fullname}</comment>
                    <name>Uninstall ${product_fullname}</name>
                    <windowsExec>${installdir}/uninstall.exe</windowsExec>
                    <windowsExecArgs></windowsExecArgs>
                    <windowsIcon></windowsIcon>
                    <windowsPath>${installdir}/</windowsPath>
                </startMenuShortcut>
            </startMenuShortcutList>
        </component>
    </componentList>
    <customLanguageFileList/>
    <fileList/>
    <parameterList>
        <directoryParameter>
            <name>installdir</name>
            <title></title>
            <description>Installer.Parameter.installdir.description</description>
            <explanation>Installer.Parameter.installdir.explanation</explanation>
            <value>${platform_install_prefix}/${product_shortname}-${product_version}</value>
            <default>${platform_install_prefix}/${product_shortname}-${product_version}</default>
            <allowEmptyValue>0</allowEmptyValue>
            <ask>yes</ask>
            <cliOptionName>prefix</cliOptionName>
            <leftImage></leftImage>
            <mustBeWritable>yes</mustBeWritable>
            <mustExist>0</mustExist>
            <width>40</width>
        </directoryParameter>
        <choiceParameter>
            <name>installtype</name>
            <title>Installation Type</title>
            <description>Which installation type do you want to perform?</description>
            <explanation>Default protocol to access the login page.</explanation>
            <value>http</value>
            <default>http</default>
            <allowEmptyValue>1</allowEmptyValue>
            <ask>1</ask>
            <cliOptionName></cliOptionName>
            <leftImage></leftImage>
            <width>40</width>
            <optionList>
                <option>
                    <text>HTTP (insecure)</text>
                    <value>http</value>
                </option>
                <option>
                    <text>HTTPS (secure)</text>
                    <value>https</value>
                </option>
            </optionList>
            <postShowPageActionList>
             <actionGroup>
              <actionList>
              <setInstallerVariable>
                  <name>installapache</name>
                  <value>1</value>
              </setInstallerVariable>
              <setInstallerVariable>
                  <name>installtomcat</name>
                  <value>1</value>
              </setInstallerVariable>
              </actionList>
              <ruleList>
                 <compareText>
                     <text>${installtype}</text>
                     <logic>equals</logic>
                     <value>server</value>
                 </compareText>
              </ruleList>
          </actionGroup>
         </postShowPageActionList>
        </choiceParameter>
    </parameterList>
    <platformOptionsList/>
    <postInstallationActionList/>
    <preBuildActionList/>
    <preInstallationActionList/>
    <preUninstallationActionList/>
    <slideShowImageList/>
</project>