Feature core functionality on core URL's from LegacyUI module

Hello Developers :smiley: CC: @wyclif @burke

I have been working on the LegacyUI module. Views have been shifted to the module, however the index pages, say “admin index” “patients index” etc, come on the module URL like: For admin index: openmrs/module/legacyui/admin/index.htm For patients index: openmrs/module/legacyui/admin/patients/index.htm

Apparently as these indexes don’t have controllers to manage them, what could be the better way to display core URL’s for these indexes?

  1. Introduce controllers for each index separately and introduce beans or @RequestMapping (This will work, but more code and less effiency, so Wyclif suggested the 2nd option)
  2. Extend the InternalResourceViewResolver class from springframework and modify the prefix and suffix to show it as the core URL instead of module URL Extending the InternalResourceViewResolver I created a class LegacyUiViewResolver, want some guidance on how to proceed with index URL’s specifically.

Can I add some logic to say "if(jsp related to view being displayed from module=/index.jsp)" then {redirect: openmrs/admin//index.jsp}

Can we look to make it apply to all indexes or seperate controllers should do the work? or is there a better way to proceed with this?

Looking forward to live examples if any in any of the module’s (functioning already).

Open to all suggestions and feedback, Please correct me if I am wrong in any way :smile:

I thought we discussed this the last time we talked and i recall saying you definitely need to introduce controllers for those pages or use a custom subclass of the view resolver class that transforms the views to match the new URLs in your module

Hey @wyclif :smile:

Yes, we have discussed this before and concluded the resolver is a good option to go ahead with, so now my question is to how to get the controller working for various indexes at different locations.

When you looking for index then call the view resolver and it resolves the views and places the views in core locations

if URL says openmrs/admin//index.jsp then look for the view at openmrs/module/legacyui/admin//index.jsp

Can we map all of the indexes this way by * as the locations are different?

(Any ideas of how to do the resolving view part of it as it is only for indexes and not all jsp’s, and at different locations?)

I guess writing a Request Filter in the module’s config.xml could also help. We could append /module/legacyui to the incoming requests that need to be directed to legacyui module. Filters defined in modules have no limitations of any sort and you can intercept any url-pattern. I think @wyclif could tell more if this approach is any good :slight_smile:

All a view resolver does is prepend and append the prefix and suffix regardless of what the view name is except for module URLs, may be i am not understanding what you are saying.

I still think the view resolver approach is the cleaner and proper way to do it because what you are dealing with are the view names returned from spring controllers and not really URLs for incoming request. If you use a Filter then you are going to end up in a situation where you have to remap all controllers to the new URLs you will be redirecting/forward to in your filter which wouldn’t be any different from the task of changing returned view names in controllers and adding new controllers where they didn’t exist.

1 Like