cancel
Showing results for 
Search instead for 
Did you mean: 

How to add UI elements dynamically in the views of webdynpro

Former Member
0 Kudos

Hi Experts,

Here i have a requirement where 2 text-box get added on a click of "ADD" button in the view during the execution of the Application. so is it possible to add the text-box to the view or not?

if yes how can it be done.

Thanks in advance

Regards

Lalitkumar.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

The second approach what u mentioned can be used in case when we know that there are only two textboxes generated dynamically on a click of a button. but the requirement doesn't mean only 2 textboxes must be generated, instead of that the text boxes are generated in pair on every click of button. so were are not sure of the no of boxes to be generated.

Anyways thank for the reply. I guess have to go ahead with the first approach. can you just describe the approach more in details.

Thanks.

thomas_jung
Developer Advocate
Developer Advocate

Even with these expanded requirements I wouldn't necessarily recommend dynamic UI element creation in WDDOMODIFYVIEW.

If the UI element requirements are fairly static (2 text boxes for each push of the button), then consider using a Multi-Pane (http://help.sap.com/saphelp_nw70ehp1/helpdata/en/df/da8b412bb5b35fe10000000a1550b0/frameset.htm) or Row Repeater (http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/93d3792e8c60d6e10000000a114a6b/frameset.htm) UI element. These constructs will both create a series of UI elements based upon the number of context elements in a bound node. Therefore if you want to generate two textboxes for each push of a button, in the button event handler you simple add another context element to the context node. You don't need dynamic UI element creation or dynamic data binding.

If you feel that you must use dynamic UI element creation, then first read up on the WDDOMODIFYVIEW phase model event.

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d2/8acd409cc4dd50e10000000a1550b0/frameset.htm

You then probably want to study these three blogs on the topic:

/people/thomas.szcs/blog/2005/12/28/dynamic-programming-in-web-dynpro-abap--introduction-and-part-i-understanding-ui-elements

/people/thomas.szcs/blog/2006/01/03/dynamic-programming-in-web-dynpro-abap--part-ii-handling-viewelements

/people/thomas.szcs/blog/2006/02/22/dynamic-programming-in-web-dynpro-abap--part-iii-aggregations-and-ddic-binding-of-viewelements

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

It is possible to dynamically generate UI elements via their class based APIs within the event WDDOMODIFYVIEW. However for such a simple situation I wouldn't recommend the dynamic generation approach.

Instead I would go ahead and design the form with these two text boxes. Then assign the visible property of the UI elements to a context attribute. At runtime in the event handler of the Add Button, you can simply change the value of the context attribute that you bound tothe visible property. This will cause the UI elements to appear.