0

I have two templates built in coach view and I have added them to a client side human interface. How do I implement a common logic between them?

Coach view 1
--------------------------------
button 1     button 2
--------------------------------

Coach view 2
----------------------------------
Text box
----------------------------------

I have two radio buttons in one and a text box in the other. If I press either one, I want to set a text, e.g. hello and bye.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Kamisan
  • 1
  • 1

1 Answers1

0

You should give each button their own control id name, so you know which button they are, like "button1", "button2". Then bind each button to the same string variable, which needs to be a configuration variable in the view or business object bound to the view. When each button is clicked, they will cause the change event to fire because the bound variable is updated, and the value or property of that change will be the control id of the button clicked. I am assuming your text box is bound to a variable in it's coach view also. When you detect a change event, if the value is "button1", then set the value of the string of your text box to whatever text you want. If the value is "button2", set the value of the text box to the text you want. I don't have access to the code I recently did for this or I would give you a more accurate syntax.

I would probably have a configuration variable for each coach view above, one named something like "buttonClicked" and bind each button to it. Then one bound to coach view 2 like "displayText". If either one changes, it's going to fire off a change event, which is why you want to use if/else to make sure the change is "button1" or "button2". If button1 changes, then this.context.config.displayText.setValue("button1 clicked").

Logan
  • 2,369
  • 19
  • 20