cancel
Showing results for 
Search instead for 
Did you mean: 

How can I bind a Controller class variable to my Context?

Former Member
0 Kudos

I have a number of fields which need to update some variables in my controller class. So, I want to add these fields to my screen so that when I change their content it updated the variables in the controller class.

How do I bind these (manually) as I don't think the Wizard works for this when actioned from the Context?.

Any help would be much appreciated. I have never had to bind global variables before.

John Sapora

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I know that I can manually create set/get methods to craete an attribute, but that's only half the work. I need to bind it in some way, so do I need to create some kind of context node for my global variables?.

John Sapora

Former Member
0 Kudos

Hi John,

It is not clear what you mean by variable of controller class - that is IMPL class (view controller).

Variables to be shown on screen have to come through context node and are binded to the view htm page.

You can create new attributes by right clicking on context node and create new attribute - then you can display these on UI by either going to View Configuration or by editing HTM page.

We don't bind IMPL class attributes to the UI attributes. If you have to update controller class attribute with what you enter on UI - you can write code in any of IMPL class method like do_prepare_output to read the value using GET method of context node class and then put it in IMPL class.

Global binding is something like to custom controller or component controller, I don't think that is what you are looking for here.

I hope it helps.

Thanks,

Rohit

former_member214667
Contributor
0 Kudos

Hi John,

If you want to show a field on UI and use UI configuration to place it at the right place, then you need to have it as an attribute in a context node of the view. And if you want to update some variable of the view implementation class, that's a little tricky. For that, you need to be able to access the view controller class instance from the context node class. This will allow you to set this variable from the SETTER. For this, you can define an attribute of same type reference as view controller class in your context node class. You can then instantiate this reference from INIT() method of context node class. This method is called when the context node is initialized and the view class reference is passed in the importing parameter 'owner'. Once you have this reference, you can then set all public variables of your view controller class from any method of the context node class.

Regards,

Shiromani

Former Member
0 Kudos

Many thanks to all for the advice.

John