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.

...

In order to create your own module's service, the following bean must be used. This is unfortunately a lot of xml code to write, but there isn't a way around it. There are only a few tags at which values need to be manipulated (in bold):

Code Block
<bean parent="serviceContext">
	<property name="moduleService">
		<list>
			<value>*org<value>org.openmrs.module.formentry.FormEntryService*<FormEntryService</value> <!-- Your service's interface class -->
			<bean class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
				<property name="transactionManager"><ref bean="transactionManager"/></property>
				<property name="target">
					<bean class="*org.openmrs.module.formentry.impl.FormEntryServiceImpl*"> <!-- Your service's concrete class -->
						<property name="*formEntryDAO*""> <!-- Name of the DAO property on your ServiceImpl -->
							<bean class="*org.openmrs.module.formentry.db.hibernate.HibernateFormEntryDAO*"> <!-- Your DAO's concrete class -->
								<property name="sessionFactory"><ref bean="sessionFactory"/></property>
							</bean>
						</property>
					</bean>
				</property>
				<property name="preInterceptors">
					<ref bean="serviceInterceptors" />
				</property>
				<property name="transactionAttributeSource">
					<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
				</property>
			</bean>
		</list>
	</property>
</bean>

...

Code Block
<bean id="myModuleMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
 <property name="order"><value>10</value></property>
 <property name="mappings">
   <props>
     <prop key="admin/patients/newPatient.form">myNewPatientFormController</prop>
   </props>
 </property>
</bean>

<bean id="myNewPatientFormController" class="<at:var at:name="MODULE_PACKAGE" />.web.controller.MyNewPatientFormController" />

In your controller, you don't need to (aka "can't") specify the URL or else Spring complains about duplicate url mappings:

...