Versions Compared

Key

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

このステップでは、最初の画面ラッパーのコードをコピーし、画面ラッパーをフレームワークにスナップインします。

  1. Visual LANSA エディターで、iiiRMP03 という名前の、新しい再使用可能なパーツを作成します。記述には DisplayEmployee ラッパーとします。

  2. 再利用可能パーツのコードを以下のコードに置き換えます。
    Function Options(*DIRECT)
    BEGIN_COM ROLE(*

[ Image Removed |../../index.htm#lansa/lansa050fp_0225.htm]
現在地: RAMP-TSガイド > RAMP VLF-WIN のチュートリアル > 上級 RAMP Womdows チュートリアル > RAMP-WINAD08 ステップ 2. 画面ラッパーを作成してスナップインする

...

  1. EXTENDS #VF_AC010) HEIGHT(227) LAYOUTMANAGER(#MAIN_LAYOUT) WIDTH(497)

...


  1. * ================================================================================

...


  1. * Simple Field and Group Definitions

...


  1. * ================================================================================

...


  1. Group_By Name(#XG_HEAD) Fields(#EMPNO #SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #DEPTMENT #SECTION)

...


  1. * Body and Button arrangement panels

...


  1. DEFINE_COM CLASS(#PRIM_PANL) NAME(#BUTTON_PANEL) DISPLAYPOSITION(2) HEIGHT(227) HINT(*MTXTDF_DET1) LAYOUTMANAGER(#BUTTON_FLOW) LEFT(409) PARENT(#COM_OWNER) TABPOSITION(3) TABSTOP(False) TOP(0) WIDTH(88)

...


  1. DEFINE_COM CLASS(#PRIM_PANL) NAME(#BODY_HEAD) DISPLAYPOSITION(1) HEIGHT(227) HINT(*MTXTDF_DET1) LAYOUTMANAGER(#BODY_HEAD_FLOW) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(0) VERTICALSCROLL(True) WIDTH(409)

...


  1. * Attachment and flow layout managers

...


  1. DEFINE_COM CLASS(#PRIM_ATLM) NAME(#MAIN_LAYOUT)

...


  1. DEFINE_COM CLASS(#PRIM_FWLM) NAME(#BUTTON_FLOW) DIRECTION(TopToBottom) FLOWOPERATION(Center) MARGINBOTTOM(4) MARGINLEFT(4) MARGINRIGHT(4) MARGINTOP(4) SPACING(4) SPACINGITEMS(4)

...


  1. DEFINE_COM CLASS(#PRIM_FWLM) NAME(#BODY_HEAD_FLOW) DIRECTION(TopToBottom) MARGINBOTTOM(4) MARGINLEFT(4) MARGINRIGHT(4) MARGINTOP(4) SPACING(4) SPACINGITEMS(4)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_EMPNO) MANAGE(#EMPNO) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_SURNAME) MANAGE(#SURNAME) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_GIVENAME) MANAGE(#GIVENAME) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_ADDRESS1) MANAGE(#ADDRESS1) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_ADDRESS2) MANAGE(#ADDRESS2) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_ADDRESS3) MANAGE(#ADDRESS3) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_POSTCODE) MANAGE(#POSTCODE) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_PHONEHME) MANAGE(#PHONEHME) PARENT(#BODY_HEAD_FLOW)

...


  1. DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_SAVE_BUTTON) MANAGE(#SAVE_BUTTON) PARENT(#BUTTON_FLOW)

...


  1. * The save button

...


  1. DEFINE_COM CLASS(#PRIM_PHBN) NAME(#SAVE_BUTTON) CAPTION(*MTXTDF_SAVE) DISPLAYPOSITION(1) LEFT(4) PARENT(#BUTTON_PANEL) TABPOSITION(1) TOP(4)

...


  1. * Collection for detail fields

...


  1. DEFINE_COM CLASS(#Prim_ACol<#prim_evef>) NAME(#PanelFields)

...


  1. * Fields in the head area

...


  1. DEFINE_COM CLASS(#EMPNO.Visual) DISPLAYPOSITION(1) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) READONLY(True) TABPOSITION(1) TOP(4) USEPICKLIST(False) WIDTH(209)

...


  1. DEFINE_COM CLASS(#SURNAME.Visual) DISPLAYPOSITION(2) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(2) TOP(27) USEPICKLIST(False) WIDTH(324)

...


  1. DEFINE_COM CLASS(#GIVENAME.Visual) DISPLAYPOSITION(3) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(3) TOP(50) USEPICKLIST(False) WIDTH(324)

...


  1. DEFINE_COM CLASS(#ADDRESS1.Visual) DISPLAYPOSITION(4) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(4) TOP(73) USEPICKLIST(False) WIDTH(363)

...


  1. DEFINE_COM CLASS(#ADDRESS2.Visual) DISPLAYPOSITION(5) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(5) TOP(96) USEPICKLIST(False) WIDTH(363)

...


  1. DEFINE_COM CLASS(#ADDRESS3.Visual) DISPLAYPOSITION(6) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(6) TOP(119) USEPICKLIST(False) WIDTH(363)

...


  1. DEFINE_COM CLASS(#POSTCODE.Visual) DISPLAYPOSITION(7) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(7) TOP(142) USEPICKLIST(False) WIDTH(216)

...


  1. DEFINE_COM CLASS(#PHONEHME.Visual) DISPLAYPOSITION(8) HEIGHT(19) HINT(*MTXTDF_DET1) LEFT(4) PARENT(#BODY_HEAD) TABPOSITION(8) TOP(165) USEPICKLIST(False) WIDTH(286)

...


  1. DEFINE_COM CLASS(#PRIM_ATLM) NAME(#ATLM_1)

...


  1. DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_1) ATTACHMENT(Center) PARENT(#ATLM_1)

...


  1. DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_2) ATTACHMENT(Center) MANAGE(#BODY_HEAD) PARENT(#MAIN_LAYOUT)

...


  1. DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_3) ATTACHMENT(Right) MANAGE(#BUTTON_PANEL) PARENT(#MAIN_LAYOUT)

...


  1. * A screen wrapper is a VL reusable part of class VF_SY122. 内部のあらゆるタイプのルーチンとは対照的に、グローバルなスコープとして定義する必要があります。

...


  1. DEFINE_COM CLASS(#vf_sy122) NAME(#myscreen_wrapper) DISPLAYPOSITION(3) HEIGHT(227) PARENT(#COM_OWNER) WIDTH(409)

...


  1. DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_4) ATTACHMENT(Center) PARENT(#MAIN_LAYOUT)

...


  1. DEFINE_COM CLASS(#PRIM_ATLI) NAME(#ATLI_6) ATTACHMENT(Center) MANAGE(#myscreen_wrapper) PARENT(#MAIN_LAYOUT)

...


  1. *
    *

...

  1. --------------------------------------------------------------------------------

...


  1. * Handle Initialization

...


  1. * --------------------------------------------------------------------------------

...


  1. Mthroutine Name(uInitialize) Options(*REDEFINE)

...


  1. Define_Com Class(#Prim_evef) Name(#FormField) Reference(*dynamic)

...


  1. Invoke Method(#Com_Ancestor.uInitialize)

...


  1. For Each(#Control) In(#Body_Head.ComponentControls)

...


  1. If_Ref Com(#Control) Is(*INSTANCE_OF #prim_evef)

...


  1. Set_Ref Com(#FormField) To(*dynamic #Control)

...


  1. Invoke Method(#PanelFields.Insert) Item(#FormField)

...


  1. Endif

...


  1. Endfor

...


  1. * In the command's uInitialize method routine, set the screen wrapper's uCommand property to #com_owner

...


  1. Set Com(#myscreen_wrapper) Ucommand(#com_owner)

...


  1. Endroutine

...


  1. * ----------------------------------------------------------------------------------------------------

...


  1. * Handle Command Execution

...


  1. *

...


  1. * You may also disable the entire form to prevent any input while RAMP is navigating

...


  1. * ----------------------------------------------------------------------------------------------------

...


  1. Mthroutine Name(uExecute) Options(*REDEFINE)

...


  1. Invoke Method(#Com_Ancestor.uExecute)

...


  1. #myscreen_wrapper.makerampTSavailable

...


  1. Set Com(#Save_Button) Enabled(False)

...


  1. #com_owner.enabled := false

...


  1. Endroutine

...


  1. * ================================================================================

...


  1. * Event Handlers

...


  1. * ================================================================================

...


  1. * RAMP has signalled it's ready. Invoke your navigation here.

...


  1. * Once the navigaton starts, processing resumes in the vHandleArrive event handler.

...


  1. Evtroutine Handling(#myscreen_wrapper.RampTSAvailable)

...


  1. Invoke Method(#myscreen_wrapper.navigatetoscreen) Name('DisplayEmployee')

...


  1. Endroutine

...



  1. Evtroutine Handling(#myscreen_wrapper.vHandleArrive) Arrivedscreen(#CurrentScreen) Previousscreen(#PreviousScreen) Arrivedpayload(#Payload)

...


  1. Case (#CurrentScreen)

...


  1. When Value_Is(= 'DisplayEmployee')

...


  1. Set Com(#SAVE_BUTTON) Enabled(false)

...


  1. * Error handling: Payloads are destroyed when the ARRIVE script finishes executing. Therefore, a payload of UPDATE_EMPLOYEE would most likely mean there was a validation error.

...


  1. If (#Payload = UPDATE_EMPLOYEE)

...


  1. Use Builtin(message_box_show) With_Args(ok ok info "Validation Error" "Please correct any errors")

...


  1. Else

...


  1. * Unlock the framework

...


  1. Set Com(#avFrameworkManager) Ulocked(false)

...


  1. #myscreen_wrapper.getvalue From('txtEmpno') Value(#empno.value)

...


  1. #myscreen_wrapper.getvalue From('txtSurname') Value(#surname.value)

...


  1. #myscreen_wrapper.getvalue From('txtGivename') Value(#givename.value)

...


  1. #myscreen_wrapper.getvalue From('txtAddress1') Value(#address1.value)

...


  1. #myscreen_wrapper.getvalue From('txtAddress2') Value(#address2.value)

...


  1. #myscreen_wrapper.getvalue From('txtAddress3') Value(#address3.value)

...


  1. #myscreen_wrapper.getvalue From('txtPhone') Value(#phonehme.value)

...


  1. #myscreen_wrapper.getvalue From('txtPostcode') Value(#POSTCODE.value)

...



  1. #com_owner.enabled := true

...


  1. Endif

...


  1. Endcase

...


  1. Endroutine

...


  1. * --------------------------------------------------------------------------------

...


  1. * Handle Save

...


  1. * --------------------------------------------------------------------------------

...


  1. Mthroutine Name(Save)

...


  1. * Set the 5250 field values to the values from this panel

...


  1. #myscreen_wrapper.setvalue Infield('txtSurname') Value(#surname.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtGivename') Value(#givename.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtAddress1') Value(#address1.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtAddress2') Value(#address2.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtAddress3') Value(#address3.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtPhone') Value(#phonehme.value)

...


  1. #myscreen_wrapper.setvalue Infield('txtPostcode') Value(#POSTCODE.value)

...


  1. * Send the Enter key with the payload

...


  1. #myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyEnter) Payload(UPDATE_EMPLOYEE)

...


  1. Endroutine

...



  1. * Listen to messages from RAMP and the 5250 application

...


  1. Evtroutine Handling(#myscreen_wrapper.RampMessage) Umessagetype(#MsgType) Umessagetext(#MsgText)

...


  1. Case (#msgtype.value)

...


  1. When Value_Is('= VF_ERROR')

...


  1. * Fatal messages reported by Ramp (e.g. Navigation request failed, etc). If in design mode, show the underlying 5250 screen. Otherwise, make the error message appear in a message box on top of the command

...


  1. If (#usystem.iDesignMode = true)

...


  1. Set Com(#myscreen_wrapper) Visible(True)

...


  1. Else

...


  1. Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)

...


  1. #com_owner.avshowmessages

...


  1. Endif

...


  1. * Messages sent by the IBM i application or unknown form was encountered

...


  1. When Value_Is('= VF_INFO' '= VF_UNKNOWN_FORM')

...


  1. Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)

...


  1. * Failure to initialize RAMP. Could occur for mainly one of two reasons

...


  1. When Value_Is('= VF_INIT_ERROR')

...


  1. Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)

...


  1. #com_owner.avshowmessages

...


  1. Otherwise

...


  1. Use Builtin(message_box_show) With_Args(ok ok info *Component ('Unknown message type ' + #MsgType + 'encountered'))

...


  1. Endcase

...


  1. Endroutine

...


  1. * --------------------------------------------------------------------------------

...


  1. * Handle changes in any of the fields on the panel

...


  1. * --------------------------------------------------------------------------------

...


  1. Evtroutine Handling(#PanelFields<>.Changed)

...


  1. * Enable the save button

...


  1. Set Com(#SAVE_BUTTON) Enabled(True)

...


  1. * Lock the framework and set a message for the user

...


  1. Use Builtin(bconcat) With_Args('Changes made to employee' #GiveName #Surname 'have not been saved yet.' 'Do you want to save them before continuing?') To_Get(#sysvar$av)

...


  1. Set Com(#avFrameworkManager) Ulocked(USER) Ulockedmessage(#sysvar$av)

...


  1. Endroutine

...


  1. * --------------------------------------------------------------------------------

...


  1. * Enter key pressed

...


  1. * --------------------------------------------------------------------------------

...


  1. Evtroutine Handling(#PanelFields<>.KeyPress) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Keycode(#KeyCode)

...


  1. If Cond('#KeyCode.Value = Enter')

...


  1. * If there no changes have been made issue message and ignore enter

...


  1. If Cond('#SAVE_BUTTON.Enabled *EQ True')

...


  1. Invoke Method(#Com_Owner.Save)

...


  1. Else

...


  1. * Issue 'There are no changes to save' message

...


  1. Use Builtin(Message_box_show) With_Args(ok ok Info *Component *MTXTDF_NO_SAVE)

...


  1. Endif

...


  1. Endif

...


  1. Endroutine

...


  1. * --------------------------------------------------------------------------------

...


  1. * Handle the save button

...


  1. * --------------------------------------------------------------------------------

...


  1. Evtroutine Handling(#SAVE_BUTTON.Click)

...


  1. #com_owner.Save

...


  1. Endroutine

...


  1. * --------------------------------------------------------------------------------

...


  1. * Handle Termination

...


  1. * --------------------------------------------------------------------------------

...


  1. Mthroutine Name(uTerminate) Options(*REDEFINE)

...


  1. * Clean up the colelction of fields on the panel

...


  1. Invoke Method(#PanelFields.RemoveAll)

...


  1. * Do any termination defined in the ancestor

...


  1. Invoke Method(#Com_Ancestor.uTerminate)

...


  1. Endroutine

...


  1. End_Com

...




  1. コンポーネントの [デザイン] タブを表示し、画面ラッパーのユーザー・インターフェースを確認します。

    Image Added

  2. 画面ラッパーをコンパイルします。

  3. フレームワークで、Employees ビジネス・オブジェクトのプロパティを表示します。

  4. 新しいコマンド、[詳細ラッパー] を作成し、Employeesビジネス・オブジェクトで有効にして、iiiRMP03 画面ラッパーをこれに関連付けます。

    Image Added

  5. フレームワークを保存して再起動します。

  6. 社員を選択し、社員の [詳細ラッパー] コマンド・ハンドラーを表示して、画面ラッパーをテストします。

    Image Added