To utilize the HCSC_FOLDER_TABS you need to add an HTML area to your page in the location you want your tabs to be displayed. Then you need to add HCSC_TAB_CLICK_SBP subpage to your page for the listener to be invoked via FieldChange PeopleCode. Then you need to follow these four coding steps. The first three steps need to be in a Postbuild or Postbuild equivalent event and then add fieldchange peoplecode to the component record for the DERIVED_TAB.TAB_BUTTON_ID.
- Define the tab sets(s)
- Instantiate Listener and controller
- Link tabset, HTML area listener to controller
- Add field change PeopleCode to execute your listener logic.
To define the Tabset you will have to create two arrays of string. One array will contain the Tab names and the other the Tab labels
&asTabNames = CreateArrayRept("", 0);
&asTabLabels = CreateArrayRept("", 0);
&sTabSet = "ZZ_TEST"; /* 1 */ &asTabNames.Push("A"); &asTabLabels.Push("IDM"); &asTabNames.Push("B"); &asTabLabels.Push("Tab2");
The second step is to Instantiate Listener and controller. There will be more on the Listener below as you will need to write your special logic to control the data being shown under each tab in your Listener.
/* 2 */ Local ZZ_ECP_TABS:TabListener &oTabListener; &oTabListener = create ZZ_ECP_TABS:TabListener(); &coTabs = create HCSC_FOLDER_TABS:FolderTabs();
And final step of the PostBuild PeopleCode is to link tabset, HTML area listener to controller.
/* 3 */ &coTabs.DynamicSetupData(Page.ZZ_HCSC_TABS, &sTabSet, &asTabNames, &asTabLabels, Record.DERIVED_TAB.GetField(Field.HTML_AREA_01), Record.DERIVED_TAB.GetField(Field.HIDDEN_AREA), False, 0, &oTabListener); &coTabs.ActivatePage(Page.ZZ_HCSC_TABS);
Then you need to add your Component FieldChange code on the TAB_BUTTON_ID.
import HCSC_FOLDER_TABS:FolderTabs; Component HCSC_FOLDER_TABS:FolderTabs &coTabs; REM Invoke Listener logic as user has pushed a tab; &coTabs.HandleTabEvent();
The only thing left to do is write your listener logic in your HandleTabEvent method:
Below is my TabListener that I put together for this Test:
import HCSC_FOLDER_TABS:TabSetListener; class TabListener extends HCSC_FOLDER_TABS:TabSetListener method TabListener(); method SetStateForFolderTabs(&pPage As string, &pTabSet As string, &pTab As string); private instance Rowset &rsA, &rsB, &rsC, &rsE, &rsF, &rsG; end-class; Component Rowset &idm; REM ************************************************; REM Constructor establishes pointers to page objects; REM ************************************************; method TabListener If %Component = Component.ZZ_HCSC_TABS Then &rsA = &idm; End-If; end-method; /* TabListener */ REM ************************************************; REM Control page content associated with selected tab; REM ************************************************; method SetStateForFolderTabs /+ &pPage as String, +/ /+ &pTabSet as String, +/ /+ &pTab as String +/ &rsA.HideAllRows(); Evaluate &pTab When "A" REM IDM; &rsA.ShowAllRows(); Break; When "B" REM TAB 2; WinMessage(&pTab); Break; End-Evaluate; end-method; /* SetStateForFolderTabs */
Below is a picture of what this demo code above produced.
No comments:
Post a Comment