How to link controllers with view pages?

Application Name: Reference application Version Number: 2.6

Question: I’m building a custom module using the UI framework and we’re kind of new at this. It would be great if you can guide me over with the following things:

  1. How are the controllers linked to the respective view pages(.gsp).
  2. Do we need to explicitly specify about the relation between the controller and the view in some config file?
  3. How do I pass data or parameters from controller to the view? Currently adding it through model attribute, which ain’t working for me.

Trials from my end:

  1. I tried passing hard coded values to the view form controller, but just got " could not find property ‘recentVisitsWithLinks’." error for each and every parameter am trying to send through controller.
  2. Next I hard coded the values for the same params in the view(.gsp) and it works fine. But, this undoubtedly ain’t the right way to display data.
  3. Tried referring to different classes from appframework and coreapps module so as to see the conventional way, but got almost the same code.
  4. I’m able to display messages from other modules using “${ui.message(“coreapps.none”)}”.

Let me know if you need any further details!

@maitreekuria, @eeggert1

@ngoel2 you could create a sample module with the sdk and study the different parts. It’s going to create a controller and a .gsp view, you can study the module and see how things are put together.

Have you seen this I found it very useful when I was learning how to use the UI framework.

1 Like

@ivange94 would that save me the other side of the coin i.e using angular controllers to parse data from and to the another template like .jsp then directly make a rest call to the openmrs API?