cancel
Showing results for 
Search instead for 
Did you mean: 

multithreading and static of wdDoModifyView in a view controller

Former Member
0 Kudos

wdDoModifyView javadoc recommends to use a static variable of view controller (VC) to pass/publish a references of UI elements to event handlers of VC.

it means then that different instances of VC serving different users share same static variable... i see here a problem, do not you?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

P P: How do you come to this conclusion?

Armin

Former Member
0 Kudos

Armin Reichert: see TJA311 WebDynpro Part 1 Unit 10, example optional 1 solution 6-3,6-4 -))

my new conclusion is that any UI elements should only be access in wdDoModifyView method

the javadoc discourage from using instance fields not static fields but recommends not to use UIs outside of the method:

  • Hook method called to modify a view just before rendering.

  • This method conceptually belongs to the view itself, not to the

  • controller (cf. MVC pattern).

  • It is made static to discourage a way of programming that

  • routinely stores references to UI elements in instance fields

  • for access by the view controller's event handlers, and so on.

  • The Web Dynpro programming model recommends that UI elements can

  • only be accessed by code executed within the call to this hook method.

Former Member
0 Kudos

Yes, the general rule is:

Access to UI element instances is only allowed in wdDoModifyView().

Don't store UI element references in static class variables.

Dont't access UI element references in event handlers.

Armin

Former Member
0 Kudos

i find it very unconvenient not to have references to UIs from their events handlers

Former Member
0 Kudos

It was a design decision to separate view layout and data.

To change UI element property values, data binding is the preferred way. To change the view layout, wdDoModifyView() is the only place.

Do you have a concrete use case or is it just a general feeling?

Armin

Former Member
0 Kudos

what come to my mind is for example: 10 buttons + 10 labels. A button changes corresponding label text on push.

Former Member
0 Kudos

This can be done using data binding: Bind the Label.text to a context attribute and change the attribute value in the button's action handler.

Armin

Former Member
0 Kudos

Hi PP

The Web Dynpro programming paradigm can take some getting used to, especially if you are coming from the world of, say, JSP.

Unless your UI absolutely cannot be defined at design-time, there should almost never be a need to write code in the wdDoModifyView method.

Web Dynpro attempts to completely seperate UI from data. So, in your example, you would create 10 buttons, and 10 labels. Each label would have its "Text" attribute linked to a String attribute in the view context. Each button would call an "onClick" handler which would change a particular context attribute, and that change will be reflected automatically by the label which is linked to it.

If you have a specific problem you are trying to solve, I will be glad to try and help you.

Regards,

Walter

Former Member
0 Kudos

yes, with data binding i can change props values by changing context attrs, for more complex UI manipulation/creation i need a reference. May be i need the complex case rather rare though...

Former Member
0 Kudos

Hi P.P,

Please read the commented statements before the wdDoModify() method.

<b>* It is made static to discourage a way of programming that routinely stores references to UI elements in instance fields for access by the view controller's event handlers, and so on.</b>

As the statement says, you are very much discouraged to pass references from & to wdDoModify() method. This is my understanding of the statement.

Best Regards,

Nibu.