6 31 2 iHelpHandler Interface

Visual LANSA

6.31.2 iHelpHandler Interface

A flexible way of creating independent (i.e. not stored in the repository) help for components is to use the iHelpHandler interface.

Using the iHelpHandler interface you have the option of implementing whatever help mechanism you like.  You simply need to plug in the appropriate piece of code and the help will be routed via a mechanism that sends notification that help was requested on a particular component. What you do after this is entirely up to you.

This example form implements the iHelpHandler Interface. When F1 is pressed, the focus component will determine whether it is implementing the help interface. If not, help will be handled through the normal automated repository help. If it is, the ProcessHelpRequest method will be executed.

In the following code the Find_Tag method receives a reference to the control that currently has focus. In the example, the ComponentTag property of the requesting component is used to determine the what help to show. If the component has a blank tag, the Handled map on the method is left as false, indicating to LANSA that help should go through the normal channels. However, if the component tag is not blank, it is displayed in a message box. Once control is returned from the message box to the form, the Handled map is set to True indicating that normal repository help should not be shown.

Note that this example uses Full RDMLX:

Mthroutine Name(Find_Tag) Help('Find a tag for the current control.  Use Parent chain to resolve if none specified') Access(*Private)
Define_Map For(*Input) Class(#prim_objt) Name(#i_Requestor) Pass(*by_reference)
Define_Map For(*Result) Class(#prim_alph) Name(#o_tag)
 
* If a control is supplied
If ((#i_Requestor *IsNot *null) *AndIf (#i_requestor *Is #prim_ctrl))
 
* If the Control has a tag, use it, otherwise go up the parent chain, and try again
If (#i_Requestor.ComponentTag <> '')
 
#o_tag := #i_Requestor.ComponentTag
 
Else
 
If (#i_Requestor.Parent *Is #prim_ctrl)
 
* Look for a tag in the parent
#o_tag := #com_owner.Find_tag( #i_Requestor.Parent )
 
Else
 
* If not control supplied, use a default
#o_tag := 'DefaultTag'
 
Endif
 
Endif
 
Else
 
* If not control supplied, use a default
#o_tag := 'DefaultTag'
 
Endif
 
Endroutine 

 

When the ProcessHelpRequest method is being executed, you have complete control over the application. Rather than using normal repository help if the tag is blank, it is quite possible to navigate the parent chain looking for a control that does have a tag. Thus with a simple recursive method it is possible to ensure that regardless of where focus is within a complex for a series of reusable parts, a help tag can be provided. The example Find_Tag method demonstrates this technique.

If this approach to help is adopted within an application, it is necessary to ensure that is implemented for all forms and reusable parts. The recommendation is that the processing be implemented in a base class form and reusable part that all other components inherit.

iHelpHandler Code Example

Ý 6.31 Help Text and Documenting Components