# Supporting "old" UI and "new" UI (uiframework) in the same module

**URL:** <https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271>\
**Category:** Development\
**Created:** [June 26, 2015, 10:36am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271 "2015-06-26T10:36:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mario](https://talk.openmrs.org/letter_avatar/mario/32/5_5575768a8748004e209b776fc1b2916d.png) [@mario](https://talk.openmrs.org/u/mario)\
**Post date:** [June 26, 2015, 10:36am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/1 "2015-06-26T10:36:33Z")

</div>

As OpenHMIS team we thought that it would be a good idea to support both types of UIs as they are currently used together in one module rather than creating a separate UI module for the new UI.

Basically what we did to be able to run our module with both types of UIs (“old” one using OpenMRS 1.9.9 and new one using OpenMRS 2.2 (with 1.11.3)) is the following steps:

1. Getting rid of the uiframework bean definition in webModuleApplicationContext.xml. Instead we defined a configuration class that would only create the bean if the uiframework module is loaded.

2. adding `@OpenmrsProfile(modules = { "uiframework:*.*" })` to our controllers for the new UI to make sure the controller actions are only applied if the uiframework module is present. As our controllers at this stage are pretty basic that looks like this:

My question now is if this approach is a good way to go, or if we are violating any rules (if there are any…) concerning best practice to provide the new UI to our modules. As far as I can see pretty much everything concerning the new UI is done in separate modules and I wonder if I might miss something important if I don’t follow that pattern.

Opinions please 🙂 Good idea?/bad idea?/missing something important?

Edit: I forgot to mention (as Rafal is pointing out) that we are having the following lines in our config.xml:

```
<aware_of_module version="3.3.1">org.openmrs.module.uiframework</aware_of_module>
<aware_of_module version="2.3">org.openmrs.module.appframework</aware_of_module>
<aware_of_module version="2.2">org.openmrs.module.providermanagement</aware_of_module>
<aware_of_module version="1.6">org.openmrs.module.uicommons</aware_of_module>

```

P.S. Here’s a link to the commit that I made to achive running both UI types in one module. Just in case people are interested in details…

> <https://github.com/OpenHMIS/openmrs-module-openhmis.inventory/commit/0d8485f7e0de39c6f67a046a06184a7dce0aa1d4>

---

<div class="post-metadata">

**Author:** ![raff](https://talk.openmrs.org/user_avatar/talk.openmrs.org/raff/32/11894_2.png) [@raff](https://talk.openmrs.org/u/raff)\
**Post date:** [June 26, 2015, 11:17am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/2 "2015-06-26T11:17:51Z")

</div>

I like what you did!

I don’t see it in your commit, but you also added dependencies to appframework, uicommons and configured [uiframework, appframework, uicommons](https://github.com/OpenHMIS/openmrs-module-openhmis.inventory/blob/develop/omod/src/main/resources/config.xml#L18) as aware of dependencies in config.xml, which is needed for this to work.

I would love to see your approach being documented as one of possibilities on a wiki. Maybe somewhere close to [https://wiki.openmrs.org/x/K46UAw](https://wiki.openmrs.org/x/K46UAw) (child or sibling page?)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [June 26, 2015, 12:00pm UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/3 "2015-06-26T12:00:53Z")

</div>

I personally cannot think of a better way of doing it other than what you have, if the OpenMRS versions you are supporting have the OpenmrsProfile class implemented (1.7.5, 1.8.5, 1.9.8, 1.10, and later) And i also like maintaining one module to support both the legacy and refapp UIs.

My scenario was a bit tricky as i still had to support a good number of implementations using the xforms module on 1.6, which does not have the OpenmrsProfile class. So i ended up doing this commit:

> <https://github.com/openmrs/openmrs-module-xforms/commit/c3bab8636b9b76c563293cb6b15657d55e8e81ec>

In summary, i created a bean, which i registered in my webModuleApplicationContext.xml as: This bean registers the org.openmrs.ui.framework.StandardModuleUiConfiguration at runtime, if the module is running under the reference application.

---

<div class="post-metadata">

**Author:** ![mario](https://talk.openmrs.org/letter_avatar/mario/32/5_5575768a8748004e209b776fc1b2916d.png) [@mario](https://talk.openmrs.org/u/mario)\
**Post date:** [June 29, 2015, 8:59am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/4 "2015-06-29T08:59:54Z")

</div>

Thanks @raff and @dkayiwa four your input.

I created a page in the wiki for that.

[https://wiki.openmrs.org/display/docs/Support+old+and+new+UI+in+one+module](https://wiki.openmrs.org/display/docs/Support+old+and+new+UI+in+one+module)

I’m not sure if this is the right spot for it, so everybody feel free to move it somewhere else or so. Also feel free to add and/or edit…

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [June 29, 2015, 10:16am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/5 "2015-06-29T10:16:24Z")

</div>

@mario, thank you so much for setting up the documentation and the good spirit of sharing. Please keep it up! 🙂

---

<div class="post-metadata">

**Author:** ![sharif](https://talk.openmrs.org/user_avatar/talk.openmrs.org/sharif/32/11982_2.png) [@sharif](https://talk.openmrs.org/u/sharif)\
**Post date:** [February 11, 2020, 4:58am UTC](https://talk.openmrs.org/t/supporting-old-ui-and-new-ui-uiframework-in-the-same-module/2271/6 "2020-02-11T04:58:13Z")

</div>

> [@dkayiwa](#):
>
> org.openmrs.ui.framework.StandardModuleUiConfiguration at runtime

As fur am time curious about UI framework this class org.openmrs.ui.framework.StandardModuleUiConfiguration configured as bean in webApplicationContext.xml file loads the fragmentControllers to the legacyui homepage in the referenceApplication, am trying to learn uiframework in details, is it the case .cc.@dkayiwa @mozzy
