Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

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

Documentation

Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

The OpenMRS UI Framework is packaged in a module which provides the framework. To use it, you need to create a module of your own that depends on it and uses it.

Depending on the UI Framework module

Its recommended that you use a mavenized module and that you generate it with the Module Maven Archetype.

To refer to the UI Framework in your module, you just need a standard module dependency on uiframework module:

  1. In your module's root pom.xml you need something like this: (you want to get the latest released version number from http://mavenrepo.openmrs.org/nexus/index.html#nexus-search;quick~uiframework-api )

    <dependencyManagement>
    	<dependencies>
    		<!-- Depends on uiframework module -->
    		<dependency>
    			<groupId>org.openmrs.module</groupId>
    			<artifactId>uiframework-api</artifactId>
    			<version>3.2.2</version>
    			<type>jar</type>
    			<scope>provided</scope>
    		</dependency>
    		...
    	</dependencies>
    </dependencyManagement>
    
  2. In your module's omod/pom.xml you need something like this:

    <dependency>
    	<groupId>org.openmrs.module</groupId>
    	<artifactId>uiframework-api</artifactId>
    </dependency>
    
  3. And your module's omod/src/main/resources/config.xml needs something like this:

    <require_modules>
    	<require_module>
    		org.openmrs.module.uiframework
    	</require_module>
    </require_modules>
    

Of course any administrator who installs your module will also have install the UI Framework module, just like with any other module dependency.

Beans in webModuleApplicationContext.xml

99% of of the time you'll want to have your module use the standard conventional configuration, by defining a single bean in webModuleApplicationContext.xml

<bean class="org.openmrs.ui.framework.StandardModuleUiConfiguration">
		<property name="moduleId" value="yourmoduleid"/>
	</bean>

The standard configuration looks for:

  • Java page controllers in org.openmrs.module.yourmoduleid.page.controller
  • Groovy page views in your omod's web/module/pages
  • Java fragment controllers in org.openmrs.module.yourmoduleid.fragment.controller
  • Groovy fragment views in your omod's web/module/fragments

Folders and Packages

In the 99% case where you're using this standard configuration, you should create the folders:

  • (yourmodule)/omod/src/main/webapp/pages
  • (yourmodule)/omod/src/main/webapp/fragments
  • (yourmodule)/omod/src/main/webapp/resources

And you should create your page and fragment controller packages like:

  • org.openmrs.module.(yourmoduleid).page.controller at (yourmodule)/omod/src/main/java/org/openmrs/module/(yourmoduleid)/page/controller
  • org.openmrs.module.(yourmoduleid).fragment.controller at (yourmodule)/omod/src/main/java/org/openmrs/module/(yourmoduleid)/fragment/controller

Development mode

The UI Framework supports a "development mode" that helps you iterate rapidly on web-layer functionality, by automatically recompiling controllers as you edit them, and automatically reloading views.

To enable development mode for a particular module, you need to set a VM argument on the JRE you are running OpenMRS in. (In Eclipse you can do this from the JRE tab of your jetty:run Run Configuration.)

If you set the following VM argument, it will be picked up by the view and controller providers configured by the StandardModuleUiConfiguration bean for yourmoduleid.

-DuiFramework.development.yourmoduleid="/path/to/root/of/mavenized/yourmoduleid"

The VM argument, above, can be provided in Netbeans by adding it to the jetty:run custom goal. In detail, download/open the OpenMRS core source in Netbeans, then open the openmrs-webapps subproject. Right click on the webapps subproject, select Custom/Goals... This will bring up the Run Maven popup. Type jetty:run in the Goals and the VM argument line in the Properties text area of the goal by typing the following: uiFramework.development.yourmoduleid=/path/to/root/of/mavenized/yourmoduleid

Note, you should not include "-D", nor the quotes around the path.

Note, -D should be included, but not the quotes in the eclipse environment.

Note that development mode only automatically recompiles controllers (for pages or fragments), not other classes. But you should be iterating on your module's domain objects and service layer using the unit testing framework anyway. :-)

Troubleshooting: It is reported that in unix you may need to delete " from the path and escape whitespaces with \ if any.

  • No labels