cancel
Showing results for 
Search instead for 
Did you mean: 

Access of IWDView out of wdModifyView, bad parctice? Alternatives?

Former Member
0 Kudos

Hi I just want to make a question here about good and bad practices programming in Web Dynpro.

It is considered as a bad practice to access the view (IWDView object) out of the wdModifyView method. However in my case I need to do it. What I want to do is to check the visibility of the UI elements when an action is raised (by a button or other means). It's not a concrete element or group of elements to be checked in a concrete view, but the check is taken by a general purpose method (will deal with any view) so it has to work with the view itself and not make just a simple check for some context attributes. So I need to access the view and I need to have a reference of the IWDView object (saving it in the context the first time the wdModifyView is executed perhaps). But this is not considered a good practice so I'd like to read alternatives here.

I know I could check the visibility of the elements whenever the wdModifyView is executed, because when the action is raised the elements have the same visibility as when the wdModifyView is executed. However this would lead me to make this check after every round trip wasting time unnecesarily. Frankly I think this would be even a worse practice than access the IWDView element out of the wdModifyView method.

How would you do it while keeping a good programming practice?

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Can you describe your use case in more detail?

The standard way is to use flags (boolean context attributes) that are set in the event handler and checked/reset in wdDoModifyView().

Armin

Former Member
0 Kudos

My case is a class that cheks if the mandatory fields are empty or not. For this the class needs to visit all the view UI elements the first time the view is loaded (first time in the wdModifyView method) to get some info about them: get the labels of the required fields to show them in the message errors later, check their visibility (if they are not enabled or visible then they don't need to be filled)...

The problem is that I'd like to do this not the first time the view is loaded but when I want to make the check so that the visibility state of UI elements is current.

I guess I could use a flag set to true when I want this action to be done, and then check it in wdModifyView, but is it a good practice to transfer all that logic to one single method (wdModifyView)? This could lead to a situation in which most of the logic of the view would be made in that method needing to do a lot of checks every time the view is loaded. Besides I don't know if taking all that logic to that phase could have any side effect.