我想将自定义验证器附加到复合组件内的一个输入字段,但验证器根本不会触发。
我完全按照here所描述的那样完成了,但我无法让它发挥作用。同样在我的代码中,对复合组件输入验证器(function CreateMyCustomUserDialog(): Boolean;
var
Form: TSetupForm;
OKButton, CancelButton: TNewButton;
Label1: TLabel;
Edit1: TEdit;
begin
Form := CreateCustomForm();
try
Form.ClientWidth := ScaleX(256);
Form.ClientHeight := ScaleY(256);
Form.Caption := 'User Information';
Form.CenterInsideControl(WizardForm, true);
OKButton := TNewButton.Create(Form);
OKButton.Parent := Form;
OKButton.Width := ScaleX(75);
OKButton.Height := ScaleY(23);
OKButton.Left := Form.ClientWidth - ScaleX(75 + 6 + 75 + 10);
OKButton.Top := Form.ClientHeight - ScaleY(23 + 10);
OKButton.Caption := 'OK';
OKButton.ModalResult := mrOk;
Label1 := TLabel.Create(Form);
Label1.Parent := Form;
Label1.Alignment := taCenter;
Label1.Caption := 'Username:';
Label1.Width := Form.ClientWidth;
Label1.Height := ScaleY(23);
Label1.Top := 30;
Edit1 := TEdit.Create(Form);
Edit1.Parent := Form;
Edit1.Top := 50;
Edit1.Width := 100;
Edit1.Left := (Form.ClientWidth - Edit1.Width) / 2;
Edit1.Text := 'Admin';
CancelButton := TNewButton.Create(Form);
CancelButton.Parent := Form;
CancelButton.Width := ScaleX(75);
CancelButton.Height := ScaleY(23);
CancelButton.Left := Form.ClientWidth - ScaleX(75 + 10);
CancelButton.Top := Form.ClientHeight - ScaleY(23 + 10);
CancelButton.Caption := 'Cancel';
CancelButton.ModalResult := mrCancel;
CancelButton.Cancel := True;
Form.ActiveControl := OKButton;
if Form.ShowModal() = mrOk then
MsgBox('You clicked OK.', mbInformation, MB_OK);
finally
Form.Free();
end;
end;
)的引用标记为红色for="validateService"
。我做错了什么?
component.xhtml
cannot resolve symbol 'validateService'
page.xhtml
<cc:interface>
<cc:attribute name="service"/>
<cc:editableValueHolder name="validateService" targets="#{cc.attrs.service}"/>
</cc:interface>
答案 0 :(得分:0)
我通过直接在复合pomponent输入字段中添加验证器来解决它,如此
<p:inputText id="service"
validator="serviceValidator"/>
但我仍然不知道为什么上述解决方案无效。