Step 5 Use the Switch History to Return to the Original Business Object

Visual LANSA Framework

Step 5. Use the Switch History to Return to the Original Business Object

In this step you will use the switch history to allow the end-user to return to the Sections business object from where they initiated the switch.

1.   Open the Employees’ Details command handler iiiCOM06.

2.   Display the Design tab.

3.   In the Repository tab, locate Weblets, then the ub_pushb1 weblet.

 

4.   Drag and drop the ub_pushb1 weblet next to the Save button in the command handler.

 

5.   Display the Source tab.

6.   Add this code before the UHandleEvent webroutine to set the caption of the button to Back:

Override Field(#UB_PUSHB1) Default('Back')

Web_Map For(*both) Fields(#UB_PUSHB1)

 

7.   In the UHandleEvent register the Back button Click event:

Invoke Method(#avFrameworkManager.avRegisterEvent) Named(UB_PUSHB1.CLICK) Signalaswamevent(2)

 

The UHandleEvent will now look like this:

 

8.   Next scroll to the end of the WAM source and add an event routine to handle the Back button Click event:

Evtroutine Handling(#avFrameworkManager.uWAMEvent_2) Options(*noclearmessages *noclearerrors)

Endroutine

 

9.   In this routine add this code so that when the users click on the button, they will be switched back to the business object from which they came:

define field(#ff_objnme) TYPE(*CHAR) LENGTH(32) DESC('Object Name')

define field(#ff_cmdnme) TYPE(*CHAR) LENGTH(32) DESC('Command Name')

 

#avframeworkmanager.avrestorevalue WithID1(SWITCH_HISTORY) WithID2(OBJECT_NAME) ToAValue(#ff_objnme)

#avframeworkmanager.avrestorevalue WithID1(SWITCH_HISTORY) WithID2(COMMAND_NAME) ToAValue(#ff_cmdnme)

 

#avframeworkmanager.avSwitch To(BUSINESSOBJECT) NAMED(#ff_objnme) EXECUTE(#ff_cmdnme) Caller(#com_owner)

 

  • When you want to send the user back to the component from which the switch occurred, you need to look at the switch history on the virtual clipboard.  Remember that you need to retrieve both the business object and the command to which you need to return.  That requires retrieving two values from the virtual clipboard.
  • The code first retrieves the OBJECT_NAME or business object value and then the COMMAND_NAME or command value. 
  • When you have these two values you can perform another switch to return to the previous component.

 Your code should look like this:

 

10.   Compile the command handler and check it in.

 

You are now ready to test the switch history:

11.   In the Framework select a section from the Department Sections business object.

12.   Display the details of the section's employees by clicking on the Details button.

13.   On the Details command handler of the Employees business object click on the Back button to return to the Sections business object.

 

14.   Close the application.