cancel
Showing results for 
Search instead for 
Did you mean: 

Declaring and accessing custom global attributes of component controller

Amey-Mogare
Contributor
0 Kudos

Hi,

I want to declare some global attributes for Component Controller and initialize them in WdDoInit() method.

I have declared them under Component Controller --> Attributes tab --> after wd_context and wd_this (say G_MESSAGE).

However, when I am trying to set them in wdDoInit() method, I get compilation error saying G_MYMESSAGE is unknown and its not defined using data statement.

How do I access these attributes?

Thanks and regards,

Amey

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Mark the Global attribute G_MESSAGE as public. Also when you are going to access it in Component controller you can get it by using wd_this->G_MESSAGE and in View controller as wd_comp_controller->G_MESSAGE.

Hope it Works for you.

Amey-Mogare
Contributor
0 Kudos

Hi Sanket,

Thank you. It worked.

Actually I did try wd_this->g_message line first but it didn't work.

Thomas's trick of activating component before using the attribute in code has done the magic!

With regards,

Amey

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Amey,

You need to access the variable by "wd_this->g_mymessage"

Since wd_this attribute in each controller refers to interface of local controller. you could read the description of that attribute in attribute tab.

Regards

Anurag Chopra

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Good advice already on how to access. One other tip. After creating the attributes active the component before you write any code that accesses the global attributes. This will generate the dynamic classes behind the scenes and help ensure proper access (if all other suggestions fail).

Former Member
0 Kudos

Oh Thomas! you are really great.