Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

...

...

...

...

...

クライアント入力データの検証

Nexaweb 4.5 では、ユーザーがクライアントユーザーインターフェイスのフィールドに入力したデータを検証するロジックを宣言的に作成できます。

...

 

検証する要素の定義

バリデータは UI でユーザー入力を検証する手段を提供するものなので、主に textField 要素または passwrodField 要素で呼び出します。

...

textField 属性
説明
id=" "
特定の textField 要素に一意の ID を指定します。
text=" "
Nexaweb クライアントで、ユーザーが入力したテキストを読み込むための属性を指定します。

例:

<textField id=“startDate” text=“” />

これらの textField 要素属性を指定することに加えて、バリデータを呼び出す textField イベントを textField 要素タグで指定することもできます。このドキュメントの「バリデータの呼び出し」を参照してください。

...

Code Block
linenumbers
languagehtml/xmltrue
<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
languagehtml/xmllinenumberstrue
 <!-- 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> 

...