How to Dynamically Change Radio Button Labels using PeopleCode

If you want to dynamically change the labels of a radio button on a page, you can use a new method in the field class: GetPageField.
The GetPageField method references a field by the unique page field name. The page field name is the name specified on the General tab in the page field properties in the page defintion;
Here is an example where you can change the radio button labels dynamically on a page;

Local boolean &ChangeLables;
If  &ChangeLables = True Then
    &Fld_1 = GetPageField(Page.Page_1,"Radio_Button_1");
    &Fld_2 = GetPageField(Page.Page_1,"Radio_Button_2");
    &Fld_1.Label = "Label_1"
    &Fld_2.Label = "Label_2";

Another Example from PeopleBooks
The following example initializes four Field objects to four specific radio button page fields and conditionally sets their labels to either a long version or a short version.
&Fld1 = GetPageField(Page.GNNWG_PAGE, "INITIALIZE"); /* Initialize Radio Button */ &Fld2 = GetPageField(Page.GNNWG_PAGE, "COMMIT"); /* Commit Radio Button */ &Fld3 = GetPageField(Page.GNNWG_PAGE, "ROLLBACK"); /* Rollback Radio Button */ &Fld4 = GetPageField(Page.GNNWG_PAGE, "SAMFAIL"); /* SAMFAIL Radio Button */ If &SetLabel = "Long" Then &Fld1.Label = "Initialize_Long_Label_Name"; &Fld2.Label = "Commit_Long_Label_Name"; &Fld3.Label = "Rollback_Long_Label_Name"; &Fld4.Label = "SAMFAIL_Long_Label_Name"; Else &Fld1.Label = "Initialize"; &Fld2.Label = "Commit"; &Fld3.Label = "Rollback"; &Fld4.Label = "SAMFAIL"; End-If;
Even though all of the radio buttons represent the same record field, GetPageField enables you to reference each radio button individually.

Ayesha Wee

    Blogger Comment
    Facebook Comment


Post a Comment