Enable-Disable & Show-Hide UI Elements in Web Dynpro Java
Enable-Disable & Show-Hide UI Elements in Web Dynpro Java
By Sharma KVBK
Scenario: Enabling/Disabling and Showing/Hiding the UI elements during runtime (as shown below).
Navigation:
• Open NWDS
• Open Web Dynpro explorer.
• File->New->Web Dynpro project
• Give the name of the project as ‘Enable_Disable_Show_Hide_UI_Elements’.
Step 2. Creating a Web Dynpro Component.
Save the changes by clicking on save all metadata on the application tool bar.
• First Name
• Last Name
• Date of Birth
• Date of Joining
• Enablekey
• Showkey
• Booleankey
• Visibilitykey
Booleankey should be of Data Type Boolean, Visibilitykey of type UI Element data type Visible.
Select the context attribute and switch to the properties tab of it.
Choose Visibility property for visibility attribute as shown above.
Press OK to continue.
Save the changes by clicking on save all metadata on the application tool bar.
Choose form.
Choose DateofBirth, DateofJoining, FirstName, LastName and Click next.
Confirm by choosing finish.
For Enable or Disable Fields group select the Input Fields and Make the following changes in the Property tab.
For Input Fields in the enabled make it as Booleankey of the context attribute.
For Radio Buttons Enable and Disable in Property tab give keyToSelect as ‘E’ & ‘D’ Respectively and Selected key as ‘ Enablekey’ of the Context Attribute.
For Enable Radio button, create an Event ‘Enable’ on Select in Property tab.
For Disable Radio button, create an Event ‘Disable’ on Select in Property tab.
For Show or Hide Group also make changes in the Property tab for all Input Fields make the Visible as VisibilityKey of The context Tab.
For Show or Hide Radio Buttons Disable in Property tab give keyToSelect as ‘S’ & ‘H’ Respectively and Selected key as ‘ Show’ of the Context Attribute.
For Show Radio button, create an Event ‘Show’ on Select in Property tab.
For Hide Radio Button Create an Event ‘Hide’ on Select in Property tab.
Step 6. Code for the onAction Methods like Enable, Disable, Show, and Hide.
In Implementation tab, write the following Code for both the Events Enable and Disable which are created as methods.
In Implementation tab Write a Piece of Code for both
the Events Show and Hide which are created as methods.
Save the changes by clicking on save all metadata on the application tool bar.
Right click on Application and choose Deploy new archive and run.