I built a mechanism that could handle this into the UI Framework long ago. I don’t know if it has ever been used, but it should work.
In your module, you would implement this interface a @Component:
There is no equivalent mechanism for overriding fragment requests, but I think it would be straightforward for you to add this to the uiframework module following the pattern that is there for page request mapper.
On successfully overidding the mapping the exception I ran into is having two controllers mapped to the same url in this case login.htm for both the Ref App Login page controller and my controller see gist:
This is a Spring-related error, i.e. Spring won’t allow you to bind two controllers to the same address (/login.htm).
If your module is an add-on on top of the reference application, then you don’t need to use @Controller to map that url, but rather let the reference application module map that url to /referenceapplication/login.page, and then use the override mechanism to override that page with one of your own.
If you need your module to capture this url either with our without the reference application module loaded, then you’ll have to add something new to cover that case.
I am working on adding support for overriding fragments using a FragmentRequestMapper via
however I need help on where to add the RequestMapper to the FragmentFactory or PageFactory as I have very little knowledge of the internal mechanics of the framework and I am not yet well setup to walk through an OpenMRS request using a debugger
@darius I have run into an interesting challenge, I have two different page request mappers in 2 custom modules - however it seems that only one of the mappers is active at any time.
It looks like the request mapper definitions are being overwritten across modules unlike what is expected by the core spring functionality which collects all beans of a specific interface. Any ideas on how to deal with this?
@wyclif different Request mappers for different pages. Thanks to @dkayiwa who found that I have both request mappers returning true all the time so only one was executing in the chain. I will update the wiki documentation to reflect this gotcha