Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
titlePrerequisite
 JRE 7 needs to installed on machine to run JAR command

Change field name on UI

...

Extract the downloaded plugin into a folder Eg. os-sample-plugin. 

Code Block
languagebash
$ jar -xf os-sample-plugin.jar

...

Introduction

This document describes the steps to create a plugin to change the UI labels and API error messages. This guide is intended for developers or technical IT staff.

Download plugin

Download or clone the sample plugin from git. Henceforth the exploded plugin directory (i.e: custom-resources) is referred as $PLUGIN_HOME.

Resources files

All labels and messages are stored in locale based resource files. There are two resource files:

  1. en.js: The default English resource file for user interface labels and messages (e.g. fields displayed in a page).
  2. messages.properties: The default English resource file for messages generated by the backend (e.g. an unique constraint violation error).

Changing UI labels

You can create your own en.js file in your plugin and override the resources you need to change. 

To do that, follow below steps 

  1. Open the file $PLUGIN_HOME/src/main/webapp/app/i18n/en.js
  2. Suppose we want to change below labels 
    1. "Collection Protocols" to "Studies"
    2. "Create Collection Protocol" to "Create Study"
    3. "Title" to "Study Name"

 Add below JSON in en.js file. To know what key values to be overridden, please search en.js of core app by UI labels. 

Code Block
languagejs
{
	"

...

cp": {
      "list": "Studies",
 

...

     "

...

create_cp_title": "Create Study",
      "title": "

...

Study 

...

Name"
  }
}

...

Change the field name in the backend

To change the field name in the backend, user has to be update the message.properties file.

Follow below steps to update the message.properties file:

  1. Edit os-sample-plugin/os-plugin-jar/errors/message.properties to change the value of field in backend. Search for the field name that needs to be changed. Eg. Change the field name 'Short Title' to 'Request ID' of Distribution protocol BO template.
Code Block
languagebash
dp_short_title = Short Title 

Replace Short Title with Request ID.

Code Block
languagebash
dp_short_title = Request ID

...

Create new plugin using given command:  

Code Block
languagebash
$jar -cf os-sample-plugin.jar META-INF/ pluginContext.xml errors/ pluginApiContext.xml pluginContext.xml

...


Change API error messages

  1. Open the file $PLUGIN_HOME/src/main/resources/errors/messages.properties
  2. Suppose we want to change below error message 
    1. "Collection Protocol with same title {0} already exists." to "Study with same title {0} already exists."

Add below property in messages.properties file. To know what key values to be overridden, please search messages.properties of core app by messages. 

Code Block
cp_dup_title=Study with same title {0} already exists.

Creating the plugin

  1. To create the plugin JAR, execute the below commands from $PLUGIN_HOME directory :
    gradle clean; gradle build
  2. The plugin JAR will get created at ${PLUGIN_HOME}/build/libs/os-messages-1.0.0.jar
  3. Copy the plugin JAR to OS plugins directory.
  4. Restart the Tomcat app server.