...
...
...
...
...
...
クライアント入力データの検証
Nexaweb 4.5 では、ユーザーがクライアントユーザーインターフェイスのフィールドに入力したデータを検証するロジックを宣言的に作成できます。
...
textField 属性 | 説明 |
id=" " | 特定の textField 要素に一意の ID を指定します。 |
text=" " | Nexaweb クライアントで、ユーザーが入力したテキストを読み込むための属性を指定します。 |
例:
<textField id=“startDate” text=“” />
これらの textField 要素属性を指定することに加えて、バリデータを呼び出す textField イベントを textField 要素タグで指定することもできます。このドキュメントの「バリデータの呼び出し」を参照してください。
...
Code Block | ||||
---|---|---|---|---|
| ||||
<mco:declarations xmlns:mco="http://nexaweb.com/mco"> <mco:mco id="loginMco" src="mcos.LoginMco" </mco:declarations> <nxml xmlns:validator="http://nexaweb.com/validator"> <validator:requiredFieldValidator id="usernameValidator" value="username.text" onSuccess="" onFailure="macro://failureMacro.execute('Username required')" /> <validator:requiredFieldValidator id="passwordValidator" value="password.text" onSuccess="mco://loginMco.enableLogInButton()" onFailure="macro://failureMacro.execute('Password required')" /> </nxml> <dialog id="loginDialog" title="Login" modal="true" closable="false"> <flowLayout /> <label text="Username:" /> <textField id="username" text="" focused="true" onTextChange="validator://usernameValidator.execute()" /> <label text="Password:" /> <passwordField id="password" text="" onTextChange="validator://passwordValidator.execute()" /> <button text="Log In" enabled="false" onCommand="mco://loginMco.login()" /> </dialog> |
...
バリデータを呼び出すには、要素イベント ハンドラの値として次のコマンドを指定します。
usernameValidator には、呼び出す定義済みバリデータタグの名前を指定します。
...
Code Block | ||||
---|---|---|---|---|
| ||||
<!-- 1 --> <mco:declarations xmlns:mco="http://nexaweb.com/mco"> <mco:mco id="loginMco" src="mcos.LoginMco"> </mco:declarations> <!-- 2 --> <nxml xmlns:validator="http://nexaweb.com/validator"> <validator:requiredFieldValidator <!-- 3--> id="usernameValidator" <!-- 4--> value="username.text" onSuccess="" <!-- 5 --> onFailure="macro://failureMacro.execute('Username required')"/> validator:requiredFieldValidator id="passwordValidator" value="password.text" onSuccess="mco://loginMco.enableLogInButton()" onFailure="macro://failureMacro.execute('Password required')" /> </nxml> <dialog id="loginDialog" title="Login" modal="true" closable="false"> <flowLayout /> <label text="Username:" /> <textField <!-- 6-->id="username" text="" focused="true" <!-- 7 --> onTextChange="validator://usernameValidator.execute()" /> <label text="Password:" /> <passwordField id="password" text="" onTextChange="validator://passwordValidator.execute()" /> <button text="Log In" enabled="false" onCommand="mco://loginMco.login()" /> </dialog> |
...