Izpack:验证程序不起作用? [英] Izpack: Validator doesn't work?
问题描述
我的 UserInputSpec.xml文件中有一个字段描述。
I have a field description in my "UserInputSpec.xml" file.
<field type="radio" variable="selected.source" >
<description align="left" txt="Please select TBPAPIIntegrator data source:" id="combo.text" />
<spec>
<choice txt="IMKB Server" id="combo.item.imkb" value="imkb"/>
<choice txt="Exernal Database" id="combo.item.database" value="db"/>
</spec>
<validator class="com.j32bit.installer.validator.SelectSourceValidator" txt="Please select one source!" >
<param name="selected.source" value="${selected.source}"/>
</validator>
</field>
这是我的Validator类:
and this my Validator class:
package com.j32bit.installer.validator;
import java.util.Map;
import com.izforge.izpack.panels.ProcessingClient;
import com.izforge.izpack.panels.Validator;
public class SelectSourceValidator implements Validator{
@Override
public boolean validate(ProcessingClient client) {
Map<String, String> params = client.getValidatorParams();
if( params.get("selected.source").equals("imkb")
|| params.get("selected.source").equals("db"))
return true;
return false;
}
}
变量减速度也如下 Installer.xml中所示:
Also variable deceleration as below in "Installer.xml":
<variables>
<variable name="selected.source" value="" />
</variables>
单选按钮未选中。如果我单击下一步按钮安装程序后仍未选择按钮,则继续下一页,并且验证不起作用。
Radio buttons comes unselected. While buttons still unselected if I click "next" button installer continuous the next page and validation does not work.
请帮助!
预先感谢。
Please help! Thanks in advance.
推荐答案
似乎在< dynamicvariables>中声明了一个变量。 < / dynamicvariables>
或< variables>< / variables>
根本不起作用。相反,您可以仅将变量名称写入字段,并且可以在安装程序中的任何位置使用和引用该变量名称。
我还从UserInputPanelSpec.xml中的字段声明中删除了验证器,并将其移到Installer.xml中的面板声明中。
It seems like declaring a variable in <dynamicvariables></dynamicvariables>
or in <variables></variables>
does not work at all. Instead you can just write a variable name to a field and it can be used and referenced in anywhere in installer.
I also removed validator from field declaration in UserInputPanelSpec.xml and moved it to panel declaration in Installer.xml.
Installer.xml:
Installer.xml:
<panels>
<panel classname="UserInputPanel" id="select.source" >
<validator classname="com.j32bit.installer.validator.SourceValidator"/>
</panel>
</panels>
UserInputPanelSpec.xml:
UserInputPanelSpec.xml:
<!-- SELECT SOURCE PANEL -->
<panel id="select.source">
<field type="radio" variable="selected.source" >
<description align="left" txt="Please select TBPAPIIntegrator data source:" id="radio.text" />
<spec>
<choice txt="IMKB" id="radio.item.imkb" value="imkb" />
<choice txt="Exernal Database" id="radio.item.db" value="db" />
</spec>
</field>
</panel>
现在它可以正常工作了。
Now it is working with no problem.
这篇关于Izpack:验证程序不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!