UB_xxxxx User Buttons
The Framework is shipped with a set of fields and weblets named UB_xxxxx. These are a collection of weblets which you can use in WAM based filters and command handlers.
There is a UB_xxxxx weblet for each UB_xxxxx field.
In addition, each UB_xxxxx field shipped has a visualization attribute of the corresponding weblet.
The code in the UB_xxxxx weblet draws the UB_xxxxx button on the form.
How are they used?You can place the user buttons on filters and command handlers and use them to trigger functions, for example Save. There are button weblets for the most common uses, for example OK, Save and Delete, and spare buttons you can format for your own particular uses, for example Show Details or Calculate.
How can the captions be changed?
The buttons not already assigned to a particular purpose can be modified to display any caption. The easiest way of doing this is to override the field definition:
OVERRIDE FIELD(#UB_PUSHB1) DEFAULT('''Show Details''')
Or if the application is multilingual then a multilingual text variable would be used:
OVERRIDE FIELD(#UB_PUSHB1) DEFAULT(*MTXTDF_SHOWDETAILS)
How are the buttons placed on a web form?
You place the user buttons on web forms by including them in a Web_Map For(*both) statement of the command handler or filter.
Once the UB_xxxxx field is used in a Web_Map, you may choose to generate the XSL for the WAM. In such case, the field appears somewhere on the page as a button.
However, you would normally want to paint the form yourself to have more control over where all the form elements appear. In such case you would just drag the UB_xxxxx weblet and drop it in the desired place on the form.
The tabbing order of buttons may be controlled
Use the TabIndex property of the avSetButton method.
For example:
Invoke Method(#ThisHandler.avSetButton) ButtonName(UB_SAVE) TabIndex(‘1’)
Invoke Method(#ThisHandler.avSetButton) ButtonName(UB_SAVE) TabIndex(‘2’)
User buttons can be hidden or disabled
User buttons can be added to a web form and then hidden or disabled if they are not relevant.
To hide or disable a button use the avSetButton method of the command handler or filter with the Visible or Enabled keywords. For example, to hide the Save button in a Command Handler defined as
Define_Com Class(#vf_aw010) Name(#ThisHandler) Reference(*Dynamic)
you would
Invoke Method(#ThisHandler.avSetButton) Buttonname(UB_SAVE) Visible(FALSE)
To disable it:
Invoke Method(#ThisHandler.avSetButton) Buttonname(UB_SAVE) Enabled(FALSE)
How to detect when a button is pushed?
You must register a Wam event in the uHandleEvent web routine where the Named keyword has normally the format
<field name>.CLICK
For example, to register a Wam event which fires when the user clicks on the Save button:
#avFrameworkManager.avRegisterEvent Named(UB_SAVE.CLICK) Signalaswamevent(n)
You would then require an event routine to handle that event:
Evtroutine Handling(#avFrameworkManager.uWAMEvent_n) Options(*noclearmessages *noclearerrors)
A simple example of a wam command handler that uses a user button
Begin_Com Role(*EXTENDS #PRIM_WAM) Layoutweblet('vlf_layout')
Define_Com Class(#vf_sw100) Name(#avFrameworkManager)
Define_Com Class(#vf_aw010) Name(#ThisHandler) Reference(*Dynamic)
Define_Com Class(#vf_lw002) Name(#avListManager) Reference(*Dynamic)
Define_Com Class(#fp_in001) Name(#FastPart) Reference(*Dynamic)
* VL Framework map fields. DO NOT CHANGE.
Web_Map For(*both) Fields((#VF_FRAMEI *private) (#VF_FRAMEW *private) (#VF_FRAMES *private) (#VF_ELXTOF *private) (#VF_ELXN01 *private) (#VF_ELXN02 *private) (#VF_ELXN03 *private) (#VF_ELXN04 *private) (#VF_ELXN05 *private) (#VF_ELXN06 *private) (#VF_ELXN07 *private) (#VF_ELXN08 *private) (#VF_ELXN09 *private) (#VF_ELXN10 *private) (#VF_ELXA01 *private) (#VF_ELXA02 *private) (#VF_ELXA03 *private) (#VF_ELXA04 *private) (#VF_ELXA05 *private) (#VF_ELXA06 *private) (#VF_ELXA07 *private) (#VF_ELXA08 *private) (#VF_ELXA09 *private) (#VF_ELXA10 *PRIVATE) (#VF_ELMETA *PRIVATE))
* Map fields used in this form.
Web_Map For(*both) Fields((#empno *ouput) #surname #givename #salary (#UB_SAVE *noid))
Webroutine Name(UHandleEvent)
* Register the event that will execute when clicking on the Save button in this filter as wam event number 1.
Invoke Method(#avFrameworkManager.avRegisterEvent) Named(UB_SAVE.CLICK) Signalaswamevent(1)
* Standard WAM initialisation.
Invoke Method(#avFrameworkManager.avInitializeWAM) Type(COMMAND) Invoker(#com_owner) Listmanager(#avListManager) Handlermanager(#ThisHandler) Fastpartmanager(#FastPart)
Invoke Method(#avFrameworkManager.avHandleWAMEvent) Anchorblock(#vf_framew) Event(#vf_event) Designmode(#vf_framed) Skin(#VF_Frames) Metatag(#vf_elmeta) Tof(#vf_elxtof) N01(#vf_elxn01) N02(#vf_elxn02) N03(#vf_elxn03) N04(#vf_elxn04) N05(#vf_elxn05) N06(#vf_elxn06) N07(#vf_elxn07) N08(#vf_elxn08) N09(#vf_elxn09) N10(#vf_elxn10) A01(#vf_elxA01) A02(#vf_elxA02) A03(#vf_elxA03) A04(#vf_elxA04) A05(#vf_elxA05) A06(#vf_elxA06) A07(#vf_elxA07) A08(#vf_elxA08) A09(#vf_elxA09) A10(#vf_elxA10) Ssiname(#VF_FRAMEI)
Endroutine
* Initialize the command handler
Evtroutine Handling(#avFrameworkManager.uInitialize) Options(*noclearmessages *noclearerrors)
* Get the current employee number from the instance list
Invoke Method(#avListManager.getCurrentInstance) Akey1(#Empno)
Endroutine
* Handle execution of the command handler
Evtroutine Handling(#avFrameworkManager.uexecute) Options(*noclearmessages *noclearerrors)
Fetch Fields(#SURNAME #GIVENAME #SALARY) From_File(PSLMST) With_Key(#EMPNO)
Endroutine
* Handle click of the save button
Evtroutine Handling(#avFrameworkManager.uWAMEvent_1) Options(*noclearmessages *noclearerrors)
Update Fields(#GIVENAME #SURNAME #SALARY) In_File(PSLMST) With_Key(#EMPNO)
Endroutine
End_Com