Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

[ Image Removed |../../index.htm#lansa/l4wdev03_0460.htm]
現在地:
Anchor_Toc137627880_Toc137627880例3 - 複数のビジュアライゼーションのリンク
部署の動的ピックリストを作成しましたが、課、さらには社員のピックリストが必要になっても不思議ではありません。

Sectionには次のコードを使用できます。前の例と同様に、Loadメソッドによりピックリストが取り込まれます。しかし、Sectionは実行時にDeptmentにリンクする必要があるため、再利用可能パーツにはiMonitorSubjectも実装します。 Function Options

Function Options(*DIRECT)
Begin_

...

Com Role(*

...

EXTENDS #PRIM_

...

OBJT *

...

implements #Prim_dc.

...

iDynamicPicklist #Prim_dc.iMonitorSubject)

...


Mthroutine Name(Load)

...

Options(*redefine)

...


#Picklist.RemoveAll

...


Select Fields(*all)

...

From_File(Sectab)

...

With_Key(#Deptment)

...


#Picklist.Add(

...

#Section #Secdesc )

...


Endselect

...


Endroutine
Mthroutine Name(ApplyMonitoredValue)

...

Options(*Redefine)

...


#Deptment :=

...

#MonitorSubject.GetValue

...


Endroutine

...


End_Com  

次のフォームでは、DeptmentとSectionの両方のビジュアライゼーションを使用しています。モニターが、Deptmentをソース、Sectionをターゲットとして定義されています。Deptmentが変更されると、SectionビジュアライゼーションのApplyMonitorValueメソッドが実行されます。ソース・オブジェクトへの参照が受け取られ、GetValueメソッドを呼び出して値を取得できるようになります。

ApplyMonitorValueが終了するとすぐに、Loadメソッドが実行されます。 Function Options

Function Options(*DIRECT)
Begin_

...

Com Role(*

...

EXTENDS #PRIM_FORM)

...

Clientheight(304)

...

Clientwidth(589)

...

Left(277)

...

Top(135)

...

Width(605)

...


Define_

...

Com Class(#Deptment.VisualPicklist)

...

Name(#Deptment)

...

Displayposition(1)

...

Left(8)

...

Parent(#COM_OWNER)

...

Tabposition(1)

...

Top(8)

...

Width(401)
Define_

...

Com Class(#Section.VisualPicklist)

...

Name(#Section)

...

Displayposition(2)

...

Left(8)

...

Parent(#COM_OWNER)

...

Tabposition(2)

...

Top(32)

...

Width(401)

...


Define_

...

Com Class(#prim_lm)

...

Name(#DepartmentSection)

...

Source(#Deptment)

...

Target(#Section)

...


Evtroutine Handling(#Deptment.Changed)

...


* Ensure the Section is valid after a department change
#Section :=

...

*null

...


Select Fields(#Section)

...

From_File(sectab)

...

With_Key(#Deptment)
Leave
Endselect

...


Endroutine
End_Com  

フォームの変数値は依然として維持しなければならないことに注意してください。ユーザーは必ず、Deptmentが変更されたときに、Sectionが合理的な値に変更されるようにしなければなりません。ここでは、部署の新しい値に対する、テーブルの最初の部分です。 The code following is for a dynamic picklist for EMPNO.
Function Options

次のコードは、EMPNO の動的ピックリストです。

Function Options(*DIRECT)
Begin_

...

Com Role(*

...

EXTENDS #PRIM_

...

OBJT *

...

implements #Prim_dc.

...

iDynamicPicklist #Prim_dc.iMonitorSubject)

...


Mthroutine Name(Load)

...

Options(*redefine)

...


#Picklist.RemoveAll

...


Select Fields(*all)

...

From_File(pslmst1)

...

With_Key(

...

#Deptment #Section)

...


#Picklist.Add(

...

#Empno ("&

...

1 &

...

2 (&3)").Substitute(

...

#Givename #Surname #Empno )

...

)

...


Endselect

...


Endroutine
Mthroutine Name(ApplyMonitoredValue)

...

Options(*Redefine)

...


Case ((

...

#MonitorSubject *

...

As #Prim_objt).ComponentPatternName)

...


When (=

...

Deptment)

...


#Deptment :=

...

#MonitorSubject.GetValue

...


When (=

...

Section)

...


#Section :=

...

#MonitorSubject.GetValue

...


Endcase

...


Endroutine

...


End_Com

...

考え方としては、課のコードとおおむね同じです。ただし、ApplyMonitorValue 考え方としては、課のコードとおおむね同じです。ただし、ApplyMonitorValue への変更に注意してください。Empno は、Deptment は、Deptment Section の両方の値を知る必要があります。受け取られた iMonitorSubject はソース・コンポーネントの参照であるため、ComponentPatternName はソース・コンポーネントの参照であるため、ComponentPatternName を使用して、変更があった変数を判断できます。

ComponentPatternName はフィールド識別子を返すため、10 文字以上のフィールドに対してこのコードを利用する場合や、Identifer 文字以上のフィールドに対してこのコードを利用する場合や、Identifer Field Name と異なる場合は注意してください。 その後、Empno を次のようにフォームに追加した場合、さらに2つのモニターを追加して、Deptment と Sectionへの変更を

その後、Empno を次のようにフォームに追加した場合、さらに2つのモニターを追加して、DeptmentSectionへの変更を Empno に通知する必要があります。 Function Options

Function Options(*DIRECT)
Begin_

...

Com Role(*

...

EXTENDS #PRIM_FORM)

...

Clientheight(304)

...

Clientwidth(589)

...

Left(277)

...

Top(135)

...

Width(605)

...


Define_

...

Com Class(#Deptment.VisualPicklist)

...

Name(#Deptment)

...

Displayposition(1)

...

Left(8)

...

Parent(#COM_OWNER)

...

Tabposition(1)

...

Top(8)

...

Width(401)
Define_

...

Com Class(#Section.VisualPicklist)

...

Name(#Section)

...

Displayposition(2)

...

Left(8)

...

Parent(#COM_OWNER)

...

Tabposition(2)

...

Top(32)

...

Width(401)
Define_

...

Com Class(#EMPNO.VisualPicklist)

...

Name(#Empno)

...

Displayposition(3)

...

Left(8)

...

Parent(#COM_OWNER)

...

Tabposition(3)

...

Top(56)

...

Width(401)

...


Define_

...

Com Class(#prim_lm)

...

Name(#DepartmentSection)

...

Source(#Deptment)

...

Target(#Section)
Define_

...

Com Class(#prim_lm)

...

Name(#SectionEmployee)

...

Source(#Section)

...

Target(#Empno)
Define_

...

Com Class(#prim_lm)

...

Name(#DepartmentEmployee)

...

Source(#Deptment)

...

Target(#Empno)

...


Evtroutine Handling(#Deptment.Changed)

...


* Ensure the Section and Empno are valid after a department change
#Com_owner.GetDefaultSection
#Com_owner.GetDefaultEmpno
Endroutine

...


Evtroutine Handling(#Section.Changed)

...


* Ensure the Empno is valid after a department change
#Com_owner.GetDefaultEmpno
Endroutine

...


Mthroutine Name(GetDefaultSection)

...

Access(*private)

...


#Section :=

...

*null

...


Select Fields(#Section)

...

From_File(sectab)

...

With_Key(#Deptment)
Leave
Endselect

...


Endroutine
Mthroutine Name(GetDefaultEmpno)

...

Access(*private)

...


#Empno :=

...

*null

...


Select Fields(#Empno)

...

From_File(pslmst1)

...

With_Key(

...

#Deptment #Section)
Leave
Endselect

...


Endroutine

...


End_Com

...