cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Programming (Web Dynpro)

0 Kudos

Hi All,

I have been successful to create UI elements, group them and render them dynamically only within the wdDoModifyView method of the view. I want to create the UI elements based on certain selection of the design time specified UI elements. For e.g. based on product category, I want to generate the UI elements such as its attributes. I want to regenerate them whenever the product category changes. Is there a way of specifyin view (IWDView) parameter for the method wdDoModifyView programmatically?

Any hint, tips will be very valuable for my project.

Thanks in advance.

Regards,

Hemanth

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I don't think you can modify the interface of wdDoModify, but you can archieve the same effect with a set of static variables within your view ( in the //@@begin others) area and manipulating these in your view's actions.

For example, I had to change the visibility of certain columns so that based on a checkbox selection, the columns dissapear. I defined a static array for these visibility values and on wdDoModifyView, I check against these static values. It's a good idea to have a 'changed' variable so that if the value has not been modified, your code does nothing.

Former Member
0 Kudos

NO! Never use static variables in a view controller.

Concerning your example with changing visibility of table columns: Bind the TableColumn's "visible" property against a view context attribute and manipulate the attribute from any event handler you want.

See also the JavaDoc for

IWDNodeElement.isChanged(), IWDNodeElement.isChangedByClient()

Armin

Former Member
0 Kudos

Your suggestion doesn't work because in my case the columns are created dynamically based on a previous table selection. I don't know how many columns there are ahead of time, and don't want to pollute my context with the UI only interfaces.

In order to control the attributes of these columns, I need a mechanism to handle them. Static variables seem to be the only way to do this. Unless you have a better idea.

Former Member
0 Kudos

Hi Tomas,

even if you don't want to "pollute" your context, there's still no need to declare static variables. Declare the array (or maybe better a List, since you don't know how many columns you'll have) in the @begin others...section, create a method for the View controller using the methods-Tab, which returns the array (list) and manipulate the contents whereever you want (the method will also be visible in the static wdDoModifyView method, since, added to the metadata of the view controller, it will be exposed to the generated view controller API).

Hope that helps.

Regards

Stefan

0 Kudos

Hi All,

I think, you all have overlooked my actual questions. I want to generate UI elements programtically based on a field value "Product Category". Based on this field value, I fetch the data from the backend and generate the UI elements. The bottleneck is that the regeneration can happen only via wdDoModifyView method. Is there a way to call this method programatically? If yes, how can I get the "view" parameter instance of the method wdDoModifyView? I can alternatively use a new view to show this UI elements but is there a way to show them in the existing view?

Thanks and regards,

Hemanth

Former Member
0 Kudos

Why do you need to call this method explicitively?

Just change the internal state, wdDoModifyView gets called every time rendering occurs. So if you bind an action to the product category field, it would change the UI anytime the view gets changed.

Former Member
0 Kudos

Hi Hemanth,

we didn't really overlook your question, this little side-step was necessary anyway.

Ok, back to your question:

1. The only place where you should change the view contents programatically is the wdDoModifyView method.

2. Of course you could "grab" the view instance in this method on the first call and store it somewhere in the context for example, but this is also discouraged.

3. There's nothing to say against it to create/modify all the necessary UI elements inside the wdDoModifyView method. This is not really a "bottleneck" anyway.

4. You can remove (and destroy) all children in the corresponding view by calling view.resetView(), this resets the view to the state you specified at design time. There's no need to use an alternative view for this.

Hope that helps.

Regards,

Stefan

Former Member
0 Kudos

Tomas,

my suggestion could not take that into account because it was not mentioned in your first message.

A view controller context is not "polluted" by attributes storing UI element property values (what do you mean by "interfaces" here?), it is exactly the right place to store this information.

Concerning this kind of usage of static members in a view controller: It's not a matter of style or taste, it is plain wrong

Armin

Answers (0)