IzPack TargetPanel是否允许选择多个目录?

时间:2012-05-25 12:01:25

标签: java deployment installer izpack

IzPack TargetPanel允许一个选择一个目标目录。但是我需要允许用户选择两个(一个用于应用,一个用于数据)。怎么做?

1 个答案:

答案 0 :(得分:3)

您可以创建UserInputPanel并将路径作为变量从用户获取。然后,您可以在任何地方使用变量替换。您必须添加userInputSpec.xml文件并定义自己的面板(尽可能多)。要获取目录,请使用<field type="dir" ... >

来自我的应用程序的示例userInputSpec.xml。我在安装程序中包含了mongoDB,并使用它来获取一些设置。

<userInput>
    <panel order="0">      
        <createForPack name="MongoDB" />
        <!-- Other settings like port, ip, username, password-->
        <field type="staticText" align="left" txt="Select the catalogue where data will be stored." id="staticText.registry.db.data.text" />
        <field type="dir" align="left" variable="mongo.data.dir">
            <spec txt="Data directory" size="25" set="$INSTALL_PATH\data" mustExist="false" create="true" />
        </field>
    </panel>    
    <panel order="1">
        <!-- definition of a second panel -->
    </panel>
</userInput>

您还需要将userInputSpec.xml作为资源添加到主安装文件中,并为UserInputPanel

中定义的每个面板添加userInputSpec.xml元素

像这样(在<installation>元素中:

<resources>
    <!-- other resources -->
    <res id="userInputSpec.xml"  src="userInputSpec.xml" />             
</resources>


 <panels>
    <panel classname="HelloPanel"/>             
    <panel classname="InfoPanel"/>
    <panel classname="LicencePanel"/>
    <panel classname="TargetPanel"/>
    <panel classname="TreePacksPanel"/>
    <panel classname="UserInputPanel"/>
    <panel classname="UserInputPanel"/>
    <panel classname="InstallPanel"/>
    <panel classname="ShortcutPanel"/>
    <panel classname="FinishPanel"/>
</panels>

注意到的双重发生          我在userInputSpec

中定义了两个面板

确保UserInputPanels出现在InstallPanel之前,因为在复制文件之前必须先从用户那里获取变量。

这只是我应用的一个例子。请参阅官方文档以了解我使用的元素和属性的含义。用户输入有许多功能。