我们正在使用安装程序 6.1.6。 今天我们支持 SQL Server 身份验证,我希望添加 Windows 身份验证模式的新功能。
我们的数据库配置设置为配置表单,我想添加一个新的组合框表单组件,其中将包含 2 个服务器身份验证选项。
是否可以使用仅适用于 Windows 操作系统的条件表达式来定义组合框的Windows 身份验证选项? (对Linux用户显示没有意义)
一些表单组件是“用户名”和“密码”。如果用户选择Windows 身份验证模式,这些字段就不再相关。这种情况下可以隐藏吗?
在安静模式下运行安装程序时,组合框选项是否会导致冲突?是否将第一个选项设置为默认值?
最佳答案
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/