Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Documentation

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed collapse from code blocks

...

Code Block
languagejava
titleSample Fragment Request Mapper
linenumberstrue
collapsetrue
@Component
public class DemoHeaderFragmentRequestMapper implements FragmentRequestMapper {

   protected final Log log = LogFactory.getLog(getClass());

   /**
    * Implementations should call {@link FragmentRequest#setProviderNameOverride(String)} and
    * {@link FragmentRequest#setFragmentIdOverride(String)}, and return true if they want to remap a request,
    * or return false if they didn't remap it.
    *
    * @param request may have its providerNameOverride and pageNameOverride set
    * @return true if this page was mapped (by overriding the provider and/or page), false otherwise
    */
   public boolean mapRequest(FragmentRequest request) {
      log.info(request.toString());
      if (request.getProviderName().equals("appui")) {
         if (request.getFragmentId().equals("header")) {
            // change to the custom login provided by the module
            request.setProviderNameOverride("mapperoverridedemo");
            request.setFragmentIdOverride("demoHeader"); // no need to specify this if the name of the fragment is the same as the one being over
            log.info(request.toString());
         }
      }
      return true;
   }

}

...

Code Block
languagejava
titleSample Page Request Mapper
linenumberstruecollapsetrue
@Component
public class DemoLoginPageRequestMapper implements PageRequestMapper {

   protected final Log log = LogFactory.getLog(getClass());

   /**
    * Implementations should call {@link PageRequest#setProviderNameOverride(String)} and
    * {@link PageRequest#setPageNameOverride(String)}, and return true if they want to remap a request,
    * or return false if they didn't remap it.
    *
    * @param request may have its providerNameOverride and pageNameOverride set
    * @return true if this page was mapped (by overriding the provider and/or page), false otherwise
    */
   public boolean mapRequest(PageRequest request) {
      if (request.getProviderName().equals("referenceapplication")) {
         if (request.getPageName().equals("login")) {
            // change to the custom login provided by the module
            request.setProviderNameOverride("mapperoverridedemo");
            request.setPageNameOverride("demoLogin");

            log.info(request.toString());
         }
      }
      return true;
   }

}

...