【问题标题】:Does IzPack TargetPanel allow selection of multiple directories?IzPack TargetPanel 是否允许选择多个目录?
【发布时间】:2012-05-25 12:01:24
【问题描述】:

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

【问题讨论】:

  • 这似乎更取决于应用程序。本身。例如,我通常创建应用程序。将数据写入user.home 的子目录,或由 JRE/OS 选择位置的通用和通用位置(例如,PreferencesCookies、JNLP API PersistenceService..)。跨度>

标签: java deployment installation izpack


【解决方案1】:

您可以创建一个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 作为资源包含在主安装文件中,并为您在userInputSpec.xml 中定义的每个面板添加UserInputPanel 元素

像这样(在&lt;installation&gt; 元素中:

<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 之前,因为您必须在复制文件之前从用户那里获取变量。

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

【讨论】:

    猜你喜欢
    • 2015-05-08
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    • 2011-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多