Defining and Using Application Parameters

Documents for the development of and with JVx.

Defining and Using Application Parameters

Postby Development@SIB » Sun Oct 03, 2010 11:40 am

It is not uncommon to pass various parameters at the launch of an application, so that they can be considered during initialization. For example, such parameters could be the log level, the look and feel, a username, etc.

There are various different ways to define application parameters, depending on the technology that is used:

  • Command line parameters (for desktop applications)
  • URL parameters (for RIA und web Applications)
  • HTML file with special TAGs (for RIA und web applications)
  • Deployment descriptor (for web applications)
  • XML file with parameters

Regardless of how the application parameters are defined, existing parameters are always accessed uniformly via the launcher. The following methods are defined for this purpose:

Code: Select all
public String getParameter(String pName);
public void setParameter(String pName, String pValue);

The method for setting a parameter only changes the parameter within the application. When the application is closed, the change is lost.


Command Line Parameters

A command line parameter is either defined in the IDE at the launch of the application, or is passed directly during the manual call. The parameter should be defined as follows:

name=value or "name=value"


URL Parameters

If the application is launched as an RIA or web application, parameters can be attached to the URL in the usual manner:

Code: Select all
http://hostname/index.html?param=value&param2=value2


HTML File

In the case of an RIA application we have to consider the Java Plugin´s conventions:

Code: Select all
<APPLET ...>
  <PARAM NAME = "param" VALUE = "value" />
</APPLET>

oder

Code: Select all
<EMBED ... param = "value" />


If the application is launched using the WebUI, the parameters have to be defined as follows:

Code: Select all
<head>
  <meta name="gwt:property" content="param=value" />
</head>

If the HTML file is used in combination with URL parameters, the HTML file´s parameters overwrite URL parameters with the same name.


Deployment Descriptor

Parameters for a web application can be defined via the Deployment Descriptor (web.xml):

Code: Select all
...
<servlet>
  <servlet-name>WebLauncherServiceImpl</servlet-name>
  <servlet-class>com.sibvisions.rad.ui.gwt.server.WebLauncherServiceImpl</servlet-class>
   
  <init-param>
    <param-name>param</param-name>
    <param-value>value</param-value>
  </init-param>     
</servlet>

The deployment descriptor´s parameters overwrite URL or HTML file parameters with the same name.


XML File

At the start of the application, the launcher detects (optional) parameters from an XML configuration. If not defined otherwise, the file application.xml is read. The file should have the following structure:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

<application>
  ...
  <param>value</param> 
  <param2>value2</param2> 
</application>

The file should be found in the same path as the application implementation (directory, jar, URL). However, it can also be defined by the developer, either as command line parameter (second parameter) or by setting the parameter config, e.g.: config=/package/app.xml in the URL or HTML file.

If the XML configuration is used in combination with command line, URL or HTML parameters, the XML file parameters overwrite parameters with the same names.
User avatar
Development@SIB
 
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation