/
Module Creator's Cheat Sheet
Module Creator's Cheat Sheet
You should no longer need the config snippets on this page.
The Maven module creation archetype will generate all these configuration snippets for you.
The @Controller, @Component, and @RequestMapping annotations will ensure Spring automatically registers them without config file entries.
Various things you might want to copy-and-paste while creating a module.
config.xml (common values)
<updateURL>https://modules.openmrs.org/modules/download/@MODULE_ID@/update.rdf</updateURL>
<require_modules>
<require_module>org.openmrs.module.htmlformentry</require_module>
</require_modules>
<mappingFiles>
AccountRequest.hbm.xml
</mappingFiles>
<messages>
<lang>en</lang>
<file>messages.properties</file>
</messages>
moduleApplicationContext.xml (minimal with annotation-driven MVC)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd">
<context:component-scan base-package="@MODULE_PACKAGE@" />
</beans>
moduleApplicationContext.xml (minimal with old-style MVC)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!-- Beans to add to the current Application context definition -->
<beans>
<bean id="@MODULE_ID@UrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="order"><value>1</value></property>
<property name="mappings">
<props>
<prop key="module/@MODULE_ID@/something.form">someController</prop>
</props>
</property>
</bean>
<bean id="someController" class="@MODULE_PACKAGE@.web.controller.SomeController">
<property name="sessionForm"><value>false</value></property>
<property name="commandName"><value>command</value></property>
<property name="formView"><value>/module/@MODULE_ID@/someList</value></property>
<property name="successView"><value>someForm.list</value></property>
</bean>
</beans>