Dashboard > DHIS Documentation > ... > Developer Documentation > Start a new module
  DHIS Documentation Log In | Sign Up   View a printable version of the current page.  
  Start a new module
Added by margrsto, last edited by Leif Arne Storset on Mar 09, 2008  (view change) show comment
Labels: 
(None)

This page is under construction.

Start a new web module

File structure

  • <module name> - pom.xml
    • src
      • main
        • java
          • org/hisp/dhis/<module name> - folders with the java classes
        • resources - xwork.xml
          • META-INF
            • dhis - beans.xml
          • org/hisp/dhis/<module name> - i18n files
        • webapp - index.html
          • <module name> - velocity and javascript files
          • WEB-INF - web.xml

The files

These files needs to be adjusted to your module.

pom.xml

Change name and finalName, and adjust version (2.0-SNAPSHOT at the time of writing).
Add other dependencies to fit your project.

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  
  <parent>
    <groupId>org.hisp.dhis</groupId>
    <artifactId>dhis-web</artifactId>
    <version>2.0-SNAPSHOT</version>
  </parent>
  
  <artifactId>dhis-web-dataentry</artifactId>
  <packaging>war</packaging>
  <name>DHIS Data Entry</name>
  
  <build>
    <finalName>dhis-web-dataentry</finalName>
  </build>
  
  <dependencies>

    <!-- DHIS -->

    <dependency>
      <groupId>org.hisp.dhis</groupId>
      <artifactId>dhis-web-commons</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hisp.dhis</groupId>
      <artifactId>dhis-web-commons-resources</artifactId>
      <type>war</type>
    </dependency>

    <!-- Web -->

    <dependency>
      <groupId>com.opensymphony</groupId>
      <artifactId>webwork</artifactId>
    </dependency>
    <dependency>
      <groupId>velocity</groupId>
      <artifactId>velocity</artifactId>
    </dependency>

    <!-- Other -->

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hisp.dhis</groupId>
      <artifactId>dhis-support-hibernate</artifactId>
      <scope>runtime</scope>
    </dependency>

  </dependencies>
</project>

xwork.xml

Remember to change package name and namespace.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
  "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
  <include file="dhis-web-commons.xml"/>
  
  <package name="dhis-web-dataentry" extends="dhis-web-commons"
    namespace="/dhis-web-dataentry"> <!-- change this -->

    <action name="index" class=""> <!-- change this -->
      <result name="success" type="velocity">/main.vm</result>
      <param name="page">/<module name>/page.vm</param>
      <param name="menu">/<module name>/menu.vm</param>
      <param name="javascripts"></param>
    </action>

   ....

  </package>
</xwork>

beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
  "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

</beans>
<bean id="" class="">
  <property name="">
    <value></value>
  </property>
</bean>

index.html

A link and redirection to index.action. Remember to change the link to match your module.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <title>DHIS 2.0</title>
    <meta http-equiv="refresh" content="0;url=dhis-web-dataentry/index.action"> <!-- change this -->
  </head>
  <body>
    <div>
      <a href="dhis-web-dataentry/index.action">DHIS 2.0</a> <!-- change this -->
    </div>
  </body>
</html>

web.xml

Change the display-name to match your module name.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <display-name>DHIS Data Entry</display-name> <!-- change this to the name of your module -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/META-INF/dhis/beans.xml</param-value>
  </context-param>
  <filter>
    <filter-name>webwork</filter-name>
    <filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>webwork</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

In the POM, I believe you have to use these dependencies instead of WebWork and HSQLDB:

<dependency>
      <groupId>org.hisp.dhis</groupId>
      <artifactId>dhis-support-hibernate</artifactId>
    </dependency>

    <dependency>
      <groupId>opensymphony</groupId>
      <artifactId>xwork</artifactId>
      <version>1.2.3</version>
    </dependency>

The article has now been corrected.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.6 Build:#812 Aug 06, 2007) - Bug/feature request - Contact Administrators