java - Install4j - 组合框组件配置条件

标签 java install4j

我们正在使用安装程序 6.1.6。 今天我们支持 SQL Server 身份验证,我希望添加 Windows 身份验证模式的新功能。

我们的数据库配置设置为配置表单,我想添加一个新的组合框表单组件,其中将包含 2 个服务器身份验证选项。

  1. 是否可以使用仅适用于 Windows 操作系统的条件表达式来定义组合框的Windows 身份验证选项? (对Linux用户显示没有意义)

  2. 一些表单组件是“用户名”“密码”。如果用户选择Windows 身份验证模式,这些字段就不再相关。这种情况下可以隐藏吗?

  3. 在安静模式下运行安装程序时,组合框选项是否会导致冲突?是否将第一个选项设置为默认值?

最佳答案

Is it possible to define the combo-box's Windows Authentication option with a condition expression for Windows OS only? (it doesn't make sense to display it for Linux users)

您可以将“下拉列表”表单组件的“下拉列表条目”属性设置为包含字符串数组的安装程序变量:

${installer:authenticationOptions}

在表单的预激活脚本中,您可以使用如下代码设置变量:

List<String> options = new ArrayList<>();
options.add("One");
options.add("Two");
if (Util.isWindows()) {
    options.add("Three");
}
context.setVariable("authenticationOptions", options.toArray(new String[0]));

Some of the form components are "username" & "password". In case the user chooses the windows authentication mode these fields aren't relevant anymore. Is it possible to conceal them in that case?

是的,通过使用如下代码禁用“选择更改脚本”属性中的组件:

// to disable
formEnvironment.getFormComponentById("123").setEnabled(!selectedItem.equals("Windows authentication"));
// or to hide
formEnvironment.getFormComponentById("123").setVisible(!selectedItem.equals("Windows authentication"));

Is the combo-box option could lead to a conflict when running the installer with a quite mode?

默认情况下,选择第一个索引。这可以通过“下拉列表”表单组件的“初始选择索引”属性进行配置。

替代解决方案:

我会考虑使用“单个单选按钮”表单组件作为您的身份验证选项。它们都绑定(bind)到相同的变量名以形成一个组,并具有与下拉列表相同的效果。使用“可见性脚本”属性,您可以根据操作系统隐藏一些选项,例如使用

Util.isWindows()

该选项仅在 Windows 上可见。通过配置区域中的“耦合表单组件”选项卡,您可以根据选择来选择禁用或启用的其他表单组件。

关于java - Install4j - 组合框组件配置条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50017556/

相关文章:

java - Android:Activity 到 Activity,第二个 Activity 无法调用 setContentView?

java - split() 分隔符之间没有任何内容 = 空字符串

java - Install4j J​​ava 最低版本似乎不起作用

linux - Install4j Linux 安装程序不工作

install4j - 网络应用程序作为服务自动更新,无需启动器

java - Install4j 处理多个屏幕的取消事件

c# - VALA 与 AOT 编译之间的性能差异?

java - 如何制作包含内部版本号的 TeamCity 工件?

java - 使用java读取Excel工作表时,列不按顺序读取

java - install4j Updater - 重新启动后缺少 cmdline 参数