Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codenameone验证程序未突出显示必填字段_Codenameone - Fatal编程技术网

Codenameone验证程序未突出显示必填字段

Codenameone验证程序未突出显示必填字段,codenameone,Codenameone,我有一个简单的表单来执行每个字段的验证。出于某种原因,我认为与CodenameOne主题相关,我没有得到验证失败字段的红色轮廓或背景,也没有看到错误消息。表单将灰显“提交”按钮,直到所有验证通过,所以这部分工作正常。我就是看不到屏幕上的错误。我已将我的表格代码包括在下面。发生这种情况是因为我使用的默认主题没有显示错误样式所需的UUID吗 当应用样式但在主题中不可用时,是否有方法进行调试 Form registrationForm = new Form("My Registration");

我有一个简单的表单来执行每个字段的验证。出于某种原因,我认为与CodenameOne主题相关,我没有得到验证失败字段的红色轮廓或背景,也没有看到错误消息。表单将灰显“提交”按钮,直到所有验证通过,所以这部分工作正常。我就是看不到屏幕上的错误。我已将我的表格代码包括在下面。发生这种情况是因为我使用的默认主题没有显示错误样式所需的UUID吗

当应用样式但在主题中不可用时,是否有方法进行调试

   Form registrationForm = new Form("My Registration");
    BorderLayout bl = new BorderLayout();
    bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER);
    registrationForm.setLayout(bl);
    registrationForm.setFormBottomPaddingEditingMode(true);
    ComponentGroup cg = new ComponentGroup();
    final TextField nicknameField = new TextField("", "Screen name (publicly viewable)", 25, TextArea.ANY);
    cg.addComponent(nicknameField);
    final TextField emailField = new TextField("", "Email address", 40, TextArea.EMAILADDR);
    cg.addComponent(emailField);
    final TextField passwordField = new TextField("", "Password", 40, TextArea.PASSWORD);
    cg.addComponent(passwordField);
    final TextField passwordConfirmField = new TextField("", "Type your password again", 40, TextArea.PASSWORD);
    cg.addComponent(passwordConfirmField);
    final TextField sloganField = new TextField("", "Slogan (publicly viewable), ex: Go Hokies!", 30, TextArea.ANY);
    cg.addComponent(sloganField);

    Button submit = new Button("Submit");
    Validator v = new Validator();

    v.addConstraint(nicknameField, new LengthConstraint(3));
    v.addConstraint(emailField, RegexConstraint.validEmail("You must enter a valid email address to receive confirmation"));
    v.addConstraint(passwordField, new LengthConstraint(8));
    v.addConstraint(passwordConfirmField, new LengthConstraint(8));
    v.addSubmitButtons(submit);
    submit.addActionListener((e) -> {
        String password = passwordField.getText();
        String passwordConfirm = passwordConfirmField.getText();
        if (!password.equals(passwordConfirm)) {
            Dialog.show("Password error", "The password and password confirmation did not match. Please retype them.", "OK", null);
        } else {
            showConfirmation();
        }
    });   
    cg.addComponent(submit);
    registrationForm.addComponent(BorderLayout.CENTER, cg);
    registrationForm.show();

错误模式将UIID设置为现有UIID,并附加“无效”一词。因此
TextField
将变为
TextField无效

在模拟器中,打开Component Inspector工具并遍历组件以查看它们拥有的UIID。这将允许您自定义处于选中/未选中状态的右UIID

要启用错误消息显示,请使用
设置ShowErrorMessageForFocusedComponent(true)