cancel
Showing results for 
Search instead for 
Did you mean: 

Access to UI elements in onAction method

0 Kudos

Hi everbody,

I have a really simple question:

how can I access UI elements of a view in onAction methods so that I can change their attributes?

(In the wdModifyView method I had no problem because I got access by the IWDView parameter).

Regards,

Christian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christian ,

You can do this by Context programming.

Create a Context Attrib of type "IWDView" and intialize this attrib in wdModifyView.

Use this ContextAttrib in any "onActionXXX" to get the UIElements.

Ex : wdContext.currentContextElement().getView().getElement("ID");

Regards, Anilkumar

Former Member
0 Kudos

No, this is bad advice. UI element instances should only be referenced in wdDoModifyView(). To change properties from event handlers, use data binding.

Armin

Former Member
0 Kudos

Hi,

Anilkmar wrote:

"You can do this by Context programming.

Create a Context Attrib of type "IWDView" and intialize this attrib in wdModifyView."

How do I create an Element of type IWDView?

do you do that in implementation in doModify?

The point is, I need to create TextViews dynamically, depending on incoming xml-files.

thanx for a hint.

Former Member
0 Kudos

To dynamically create view parts from configuration data, for example from RSS XML files, add a change-flag to the view context indicating that new configuration data are available.

In wdDoModifyView(), check this flag and recreate the view parts as needed, reset the change-flag afterwards.

Do not store the IWDView reference in the context for accessing UI elements from event handlers.

Armin

Answers (3)

Answers (3)

0 Kudos

Thank you all for your answers. I finally solved it by the way Armin proposed.

Best Regards,

Christian

Former Member
0 Kudos

hi,

Why do you need it outside ? You are not supposed to access it outside the wdDoModifyView.

It is not advisable to copy the UL object or store and then access it.

what you can do is write the code in modify view inside a if condition and change the condition depending on the requirement.

Regards

Bharathwaj

Former Member
0 Kudos

Hi Cristian,

Yes you can achieve by the way Anil has described.

What else you can do is, make context attribute related to the property of the UI element instead of saving whole view object in context.

Like, if you want to change visibility property of any UI element then, make one context attribute of type VISIBILITY and then onActionXXX method alter the value of this context attribute as you required.

Regards,

Bhavik