0% found this document useful (0 votes)
7 views

Tutorial - 3 - GUI

ضصضص

Uploaded by

homadi.99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Tutorial - 3 - GUI

ضصضص

Uploaded by

homadi.99
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

SOClass Modular version

3 - Graphical User Interface

Subject BasicTutorial
Version ADK 244
Issue date 16/07/2005
Beneficiaries Developers
File Tutorial - 3 - GUI.doc
Status Final
Checked by Asycuda World - Lyon Competence center
Copyrights United Nations Conference on Trade and Development
Developer Guide
Version ADK 244
3 - Graphical User Interface

Table of contents
1. DOM MODIFICATION...................................................................................... 7
2. CLIENT MODIFICATION .............................................................................. 10
2.1. USER FORM ................................................................................................... 11
2.2. PERSONAL INFORMATION FORM .................................................................... 13
2.2.1. Identity page ............................................................................................ 14
2.2.2. Coordinate page ...................................................................................... 15
3. SERVER MODIFICATION ............................................................................. 18
4. PROPERTIES FILES........................................................................................ 18
4.1. TUTORIAL3 PROPERTIES FILES ....................................................................... 18
4.2. XML DATABASE TABLE MANAGEMENT ......................................................... 18
4.3. BINDER AND SHORTCUT DEFINITION.............................................................. 18
4.4. EXPORTING THE DATABASE ........................................................................... 18

United Nations Conference on Trade and Development Page 2 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

Figures
FIGURE1 - THIS IS AN EXAMPLE OF FIGURE........................................................................... 4
FIGURE2 - FIRST PAGE OF THE FORM « PERSONAL INFORMATION »...................................... 5
FIGURE3 - SECOND PAGE OF THE FORM « PERSONAL INFORMATION » ................................. 6
FIGURE4 - PAGE OF THE FORM « USER INFORMATION » ....................................................... 6
FIGURE5 - NEW DOM TO CREATE ........................................................................................ 7
FIGURE6 - THE DIFFERENT TABS OF A DOCUMENT .............................................................. 10
FIGURE7 - XML IMPORT TOOL ............................................................................................ 18

Source code
SOURCE 1 - THIS IS AN EXAMPLE OF SOURCE CODE ................................................................ 4
SOURCE 2 - ADDING DATA MODEL CONSTANTS IN THE C_TUTORIAL3 CLASS ....................... 7
SOURCE 3 - D_TUTORIAL3 CLASS MODIFICATIONS ............................................................... 8
SOURCE 4 - DATA INFORMATION DEFINITION IN THE D_TUTORIAL3 CLASS ........................... 9
SOURCE 5 - ADDING FORMS IN THE VD_TUTORIAL3 CLASS................................................. 10
SOURCE 6 - VF_TUTORIAL3USER NEW FORM ...................................................................... 11
SOURCE 7 - OLD BACKGROUND IN VP_TUTORIAL3USER CLASS........................................... 12
SOURCE 8 - IMAGE BACKGROUND IN VP_TUTORIAL3USER CLASS ...................................... 12
SOURCE 9 - VP_TUTORIAL3USER: A PAGE CONTAINING A PASSWORD FIELD ....................... 12
SOURCE 10 - MODIFICATION OF THE VF_TUTORIAL3 FORM .................................................. 13
SOURCE 11 - VP_TUTORIAL3IDE CLASS MODIFICATIONS ..................................................... 14
SOURCE 12 - VP_TUTORIAL3COO MODIFICATIONS .............................................................. 16
SOURCE 13 - FORMAT DECLARATION IN THE TEXTFORMAT.PROPERTIES FILE ........................ 17
SOURCE 14 - TABLE CONNECTORS DECLARATION IN THE TC_TUTORIAL3 CLASS .................. 18
SOURCE 15 - UN.ASYTUTORIAL.TUTORIAL3.PROPERTIES FILE................................................ 18
SOURCE 16 - UN.ASYTUTORIAL.PROPERTIES .......................................................................... 18
SOURCE 17 - ASYUTORIAL_CREATE.XML MODIFICATIONS ..................................................... 18
SOURCE 18 - ASYTUTORIAL_INSERT.XML MODIFICATIONS .................................................... 18
SOURCE 19 - ADDING BINDER AND SHORTCUT IN THE INSTALL_SRC.XML FILE ...................... 18

United Nations Conference on Trade and Development Page 3 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

How to read this document


This symbol indicates advice and recommendations. Information on best
practices and recommended procedures related to the current topic is
contained here.

Keyword Definition

This symbol indicates a warning. Information on common pitfalls or dangers


associated with the current topic is contained here.

This symbol indicates an example to further illustrate the current topic.

Source 1 -
This is an example
of source code Source code.

Phase 1 Phase 2 Phase 3

Figure1 - This is an example of figure

United Nations Conference on Trade and Development Page 4 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

Objective
In this document you will learn
 How to use the different visual components available
 How to declare new formats.
Required element
 Tutorial2 e-Document

The main goal of this tutorial is to present the different kinds of visual components that can be
used to create an e-Document.
The organization of an e-Document will also be presented throughout the use of multiple
forms and pages.

Figure2 - First page of the form « Personal information »

United Nations Conference on Trade and Development Page 5 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

Figure3 - Second page of the form « Personal Information »

Figure4 - Page of the form « User information »

United Nations Conference on Trade and Development Page 6 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

1. DOM Modification
The new DOM has 3 segments and should look like as follow:

IDE
Visual field Data element
FNA First name FNA

LNA Last name LNA


Birth Date BDA
BDA
Picture PIC
PIC
Sex SEX
SEX Address ADR
Postal code CPO
COO City CIT
Telephone TEL
ADR
Login LOG
CPO
Password PWD
CIT
TEL

USR

LOG
PWD

Figure5 - New DOM to create

See the tutorial 2 to learn more about DOM creation.


The first step is to define the constants representing the elements of the DOM. This is done in
the C_Tutorial3.java file.

Source 2 -
Adding Data Model ….
constants in the /**
C_Tutorial3 class * Data Model.
*
*/
//Key

United Nations Conference on Trade and Development Page 7 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

public static final String INSTANCE_ID = "INSTANCE_ID";

// Segment Identity
public static final String IDE = "IDE";
// First name
public static final String FNA = "FNA";
// Last name
public static final String LNA = "LNA";
// Birth date
public static final String BDA = "BDA";
// Picture
public static final String PIC = "PIC";
// Sex
public static final String SEX = "SEX";

// Segment Coordinate
public static final String COO = "COO";
// Address
public static final String ADR = "ADR";
// Postal code
public static final String CPO = "CPO";
// City
public static final String CIT = "CIT";
// Telephone
public static final String TEL = "TEL";

// Segment User
public static final String USR = "USR";
// login name
public static final String LOG = "LOG";
// Password
public static final String PWD = "PWD";
….

Then, the data model is defined in the define_DataModel() function in the


D_Tutorial3 class.

Source 3 -
D_Tutorial3 class …
modifications public void define_DataModel() {

key(INSTANCE_ID); //Key data

// Normal data
DataSet ide = seg(IDE); // Identity
ide.add(FNA); // firstname
ide.add(LNA); //lastname
ide.add(BDA); //birth date
ide.add(PIC); // picture
ide.add(SEX); // sex

DataSet coo = seg(COO); // Coordinate


coo.add(ADR); // Adress
coo.add(CPO); // Postal code
coo.add(CIT); // City
coo.add(TEL); // Telephone

DataSet usr = seg(USR); // User


usr.add(LOG); // login
usr.add(PWD); // password

United Nations Conference on Trade and Development Page 8 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

define_DataInformation();
}

The data information should also be defined in the define_DataInformation() function


in the same file.

Source 4 -
Data information public void define_DataInformation() {
definition in the
D_Tutorial3 class setHumanName(lng("Tutorial 3"));

//Segment Identity
ds(IDE).setHumanName(lng("Identity"));
ds(IDE).de(FNA).setHumanName(lng("Firstname"));
ds(IDE).de(LNA).setHumanName(lng("Lastname"));
ds(IDE).de(BDA).setHumanName(lng("Birthdate"));
ds(IDE).de(PIC).setHumanName(lng("Picture"));
ds(IDE).de(SEX).setHumanName(lng("Sex"));

// Segment Coordinate
ds(COO).setHumanName(lng("Coordinate"));
ds(COO).de(ADR).setHumanName(lng("Address"));
ds(COO).de(CPO).setHumanName(lng("Postal code"));
ds(COO).de(CIT).setHumanName(lng("City"));
ds(COO).de(TEL).setHumanName(lng("Telephone"));

// Segment User
ds(USR).setHumanName(lng("User"));
ds(USR).de(LOG).setHumanName(lng("Login"));
ds(USR).de(PWD).setHumanName(lng("Password"));

// End of the definition of the Data Information


}

United Nations Conference on Trade and Development Page 9 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

2. Client modification
A visual document can contain different sorts of tabs representing forms and pages. A form
can have multiple pages.

Tabs representing the


pages for the form’s tab
selected

Tabs representing
a form

Figure6 - the different tabs of a document

In this tutorial, the main changes are in the client part. This tutorial has 2 forms:
• One describing the personal information of a person. This form contains 2 pages:
 A page for a short presentation of the person.
 A page for the coordinate of the person.
• One giving information about the user associated to the person.
These forms have to be added to the document in the VD_Tutorial3 class as shown below.

Source 5 -
Adding forms in the package un.asytutorial.tutorial3.client;
VD_Tutorial3 class
import so.kernel.client.*;
import un.asytutorial.tutorial3.C_Tutorial3;

public final class VD_Tutorial3 extends KVisualDocument implements


C_Tutorial3 {
/** Creates new VD_Tutorial3 */
public VD_Tutorial3() {

United Nations Conference on Trade and Development Page 10 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

super();
setTitle(lng("Document title"));
}

public void initializeForms() {


VF_Tutorial3 form = new VF_Tutorial3( );
VF_Tutorial3User formUser = new VF_Tutorial3User ( );
addForm(form);
addForm(formUser);
setSize(getPreferredSize());
}

/**
* Retrieves a property string in the current working language.
*
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}

At this step, the document contains 2 forms, which is represented by the 2 tabs at the bottom
of the document.

2.1. User form


The user form describes the information concerning the user associated to the person. This
form contains just one page. The description of the visual form is accordingly very simple.

Source 6 -
VF_Tutorial3User package un.asytutorial.tutorial3.client;
new form
import so.kernel.client.VisualForm;

public class VF_Tutorial3User extends VisualForm {

/** Creates new VF_Tutorial3User */


public VF_Tutorial3User() {
super(lng("User information"));
}

public void initializePages() {


VP_Tutorial3User pageUser = new VP_Tutorial3User();
addPage(pageUser);
}

/**
* Retrieves a property string in the current working language.
*
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}

United Nations Conference on Trade and Development Page 11 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

The next step is to define the visual components of the page and the facets associated. In this
page, the only newness is the password field which has the particularity of masking what the
user is typing.
We changed also the background by an image. We have to replace these two lines in
initVisualPage() function:

Source 7 -
old background in …
VP_Tutorial3User setBackgroundFilter(new Color(0, 0, 0, 255), true);
class setBackgroundGradientFilter(200, 200, new Color(255, 255, 255, 255), 0, 0,
new Color(0, 0, 102, 255), 2);

by:

Source 8 -
Image background …
in setBackgroundImage(so.swing.IconResourcer.getIcon("img/aw2t.gif"),KPanel.ST
VP_Tutorial3User RETCH);
class …

You have to modify in all VP_radical the initVisualPage() functions as above.


Don’t forget to create the image directory:
un/asytutorial/client/src/un/asytutorial/tutorial3/client/img, and
copy your background image in. Be careful about the text label field colour used in relation
to the picture.

Source 9 -
VP_Tutorial3User: package un.asytutorial.tutorial3.client;
a page containing a
password field import java.awt.Color;
import java.awt.Font;

import so.kernel.client.KVisualPage;
import so.kernel.client.elf.ElfField;
import so.kernel.client.elf.ElfVisualPage;
import so.kernel.core.client.facets.VisualFacetJTextComponent;
import so.swing.KPanel;
import so.swing.KPasswordField;
import un.asytutorial.tutorial3.C_Tutorial3;

public class VP_Tutorial3User extends ElfVisualPage implements C_Tutorial3 {

// Declare Visual controls


transient private ElfField fld_Login = elfFieldPool.getElfField();
transient private KPasswordField pld_Password = new
KPasswordField();

public VP_Tutorial3User() { ….}

United Nations Conference on Trade and Development Page 12 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

public void initVisualPage() {



setBackgroundImage(so.swing.IconResourcer.getIcon("img/aw2t.gif"),KPanel.
STRETCH);

}

// Initialization: Visual controls


public void initVisualControls() {
// Title stripe
addTitleStripe( 0, 4, 444, 24, lng("User information"));

// Label
// syntax: add( X, Y, Width, Height, lng("label caption"));
add(20,50,80,24,lng("Login"));
add(20,100,80,24,lng("Password"));

// Editable Visual controls


// syntax: add( X, Y, Width, Height, control, lng("control name"));
add(100,50,100,24,fld_Login,lng("Login"));
add(100,100,100,24,pld_Password,lng("Password"));
}

public void initFacets() {


// syntax: addFacetXXX(control, dom element, Format);
addFacetText(fld_Login, ds(USR).de(LOG), "X25");
addVisualFacet(
new VisualFacetJTextComponent(ds(USR).de(PWD), pld_Password) );
}

/**
* Retrieves a property string in the current working language.
*
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}

2.2. Personal information form


The personal information form contains 2 pages (Personal information and coordinate).
These forms have to be added in the corresponding visual form as usual.

Source 10 -
Modification of the package un.asytutorial.tutorial3.client;
VF_Tutorial3 form
import so.kernel.client.VisualForm;

public class VF_Tutorial3 extends VisualForm{


/** Creates new VF_Tutorial3 */
public VF_Tutorial3() {
super(lng("Personal information"));
}

public void initializePages() {


VP_Tutorial3IDE pageIDE = new VP_Tutorial3IDE();
VP_Tutorial3COO pageCOO = new VP_Tutorial3COO();

United Nations Conference on Trade and Development Page 13 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

addPage(pageIDE);
addPage(pageCOO);
}

/**
* Retrieves a property string in the current working language.
*/
public static String lng(String property) {
return so.i18n.IntlObj.createMessage("Tutorial", property);
}
}

The two new pages replace the one of the preceding tutorial: VP_Tutorial3IDE and
VP_Tutorial3COO. The first one is a modification of the VP_Tutorial2 from tutorial 2
and can be thus reused.

2.2.1. Identity page


The page VP_Tutorial3IDE contains new kind of fields:
• Checkbox: 2 checkboxes are used for the sex selection of the person (Male or
Female).
• ButtonGroup: the button group is used to indicate that a person is a male or a
female and can’t be both. The link between the buttongroup and the checkboxes is done
when the checkboxes are added to visual document. In that case, the facet links the
DOM element with the buttongroup, not with the checkboxes. The value affected to the
buttongroup will depend on the checkbox selected.
• Image: images are defined as KImageViewer objects. To link the image control
with the DOM element, the addFacetImage() method is used.

Source 11 -
VP_Tutorial3IDE package un.asytutorial.tutorial3.client;
class modifications
import java.awt.Color;
import java.awt.Font;

import javax.swing.ButtonGroup;
import javax.swing.JCheckBox;

import so.kernel.client.KVisualPage;
import so.kernel.client.elf.ElfField;
import so.kernel.client.elf.ElfVisualPage;
import so.swing.KPanel;
import un.asytutorial.tutorial3.C_Tutorial3;

public class VP_Tutorial3IDE extends ElfVisualPage implements C_Tutorial3 {

// Declare Visual controls


transient private ButtonGroup grp_Sex = new ButtonGroup();
transient private JCheckBox cbx_SexMale = new JCheckBox();
transient private JCheckBox cbx_SexFemale = new JCheckBox();
transient private ElfField fld_FirstName = elfFieldPool.getKTextField();
transient private ElfField fld_LastName = elfFieldPool.getKTextField();
transient private ElfField fdt_BirthDate = elfFieldPool.getKPopupBox();

United Nations Conference on Trade and Development Page 14 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

transient private ElfField img_Picture = elfFieldPool.getElfField();

public VP_Tutorial3IDE() { …. }

public void initVisualPage() {


….
setBackgroundImage(so.swing.IconResourcer.getIcon("img/aw2t.gif"),KPanel.
STRETCH);
…..
}

// Initialization: Visual controls


public void initVisualControls() {
// Title stripe
addTitleStripe( 0, 4, 444, 24, lng("Personal Identity"));

// Label
// syntax: add( X, Y, Width, Height, lng("label caption"));
add(20,50,200,20,lng("Sex"));
add(20,100,80,24,lng("First name"));
add(20,150,80,24,lng("Last name"));
add(20,200,80,24,lng("Birth date"));
add(20,250,80,24,lng("Piture"));

// Editable Visual controls


add(100,50,100,20, cbx_SexMale,grp_Sex,lng("Male"));
add(200,50,100,20, cbx_SexFemale,grp_Sex,lng("Female"));
add(100,100,100,24,fld_FirstName,lng("First name"));
add(100,150,100,24,fld_LastName,lng("Last name"));
add(100,200,100,24,fdt_BirthDate,lng("Birth date"));
add(100,250,200,200,img_Picture,lng("Picture"));
}

public void initFacets() {


// syntax: addFacetXXX(control, dom element, Format);
addFacet(grp_Sex, ds(IDE).de(SEX));
addFacetText(fld_FirstName, ds(IDE).de(FNA), "X35");
addFacetText(fld_LastName, ds(IDE).de(LNA), "X35");
addFacetDate(fdt_BirthDate, ds(IDE).de(BDA), "Date");
addFacetImage(img_Picture, ds(IDE).de(PIC));
}
…..
}

2.2.2. Coordinate page


The coordinate page underscores a new kind of field, new facets and different formats:
• TextAreaScroll: a multiple lines text field. The corresponding facet is the
addFacetMemo() method.
• addFacetTextHistory(): this facet creation method is useful for repeating
fields like city or zip code. All the values already entered in the field by the user are
saved to make the field be easier to fill for the user.
• addFacetNumeric() : this facet allows only numeric characters.
• Formats: different formats are used in the addFacetXXX() methods below.

United Nations Conference on Trade and Development Page 15 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

The “ZIP”, “City” formats are defined in:


\aw\server\etc\config\format\
This directory contains files defining the different types of format:
 TextFormat.properties
 DateFormat.properties
 NumericFormat.properties
 LookupFormat.properties
It is possible to create specific format in a module that will be added to this files
during the installation of the module. To do so, the same files have to be created in the
our_module\Server\som\format directory of the module.
As an example, the address format is an additional one created in the module tutorial,
in the TextFormat.properties file.

Source 12 -
VP_Tutorial3COO …….
modifications public class VP_Tutorial3COO extends ElfVisualPage implements C_Tutorial3 {

// Declare Visual controls


transient private ElfField ftx_Address = elfFieldPool.getElfField();
transient private ElfField fld_PostalCode = elfFieldPool.getElfField();
transient private ElfField fld_City = elfFieldPool.getElfField();
transient private ElfField fld_Telephone = elfFieldPool.getElfField();

public VP_Tutorial3COO() { … }

public void initVisualPage() {


….

setBackgroundImage(so.swing.IconResourcer.getIcon("img/aw2t.gif"),KPan
el. STRETCH);
…..
}

// Initialization: Visual controls


public void initVisualControls() {
// Title stripe
addTitleStripe( 0, 4, 444, 24, lng("Coordinates"));

// Label
// syntax: add( X, Y, Width, Height, lng("label caption"));
add(20,50,200,20,lng("Address"));
add(20,150,80,24,lng("Zip code"));
add(20,200,80,24,lng("City"));
add(20,250,80,24,lng("Phone"));

// Editable Visual controls


// syntax: add( X, Y, Width, Height, control, lng("control name"));
add(100,50,200,72,ftx_Address,lng("Address"));
add(100,150,100,24,fld_PostalCode,lng("Zip code"));
add(100,200,150,24,fld_City,lng("City"));
add(100,250,80,24,fld_Telephone,lng("Phone"));
}

public void initFacets() {


addFacetMemo(ftx_Address, ds(COO).de(ADR), "Address");

United Nations Conference on Trade and Development Page 16 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

addFacetTextHistory(fld_PostalCode, ds(COO).de(CPO), "ZIP",


"ZIP");
addFacetTextHistory(fld_City, ds(COO).de(CIT), "City", "CITY");
addFacetNumeric(fld_Telephone, ds(COO).de(TEL),"INT");
}
…..
}

We use predefined format City and ZIP.


Address is our new format. We have to create its definition in a file named
TextFormat.properties stores under
un\asytutorial\Server\som\format directory. In this file, we specify the
format of our address format definition.

Source 13 -
format declaration Address=X50
in the Address.name=Address
TextFormat.propert
ies file

About formats, when using facets in the SOClass system, four types of facets are
available: text, numeric, date and lookup. However, the lookup format does not
specify a data type, but is a source of layout information.
Although the system makes the predefined formats directly accessible, customised
formats can be defined within properties files.
Using predefined formats consists in using the formats presented in these tables:
Text formats:

Code Description
X<number> This pattern allows upper and lower case letters, numbers and the
next characters: + ~ " * ç % & / ( ) = ? ` ¦ @ # ° § ¬ | ¢ ´ ~ >\ [ ] } { ,
.;:-_ .

U<number> This pattern allows only upper case letters

UN<number> This pattern allows only upper case letters, numbers and the next
characters: " * Ç & / ( ) # \.

A<number> This pattern allows upper case and lower case letters and next
marks: " * ç & / ( ) # \.

AN<number> This pattern allows upper and lower case letters, numbers and
next characters: " * ç & / ( ) \.

N<number> This pattern allows only numbers.

United Nations Conference on Trade and Development Page 17 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

Where <number> represents the upper limit of characters that can be inserted.

Numeric formats:
However, using numeric formats is slightly more complex and requires that a strict
syntax be followed:

Value Pattern Output Explanation


123456.789 ###,###.### 123,456.789 The pound sign (#) denotes a digit, the
comma is a placeholder for the grouping
separator, and the period is a placeholder for
the decimal separator.
123456.789 ###.## 123456.79 The value has three digits to the right of the
decimal point, but the pattern has only two.
The format method handles this by rounding
up.
123.78 000000.000 000123.780 The pattern specifies leading and trailing
zeros, because the 0 character is used
instead of the pound sign (#).

12345.67 $###,###.### $12,345.67 The first character in the pattern is the dollar
sign ($). Note that it immediately precedes the
leftmost digit in the formatted output.

12345.67 \u00A5###,###.# ¥12,345.67 The pattern specifies the currency sign for
## Japanese yen (¥) with the Unicode value
00A5.

Where the pattern’s symbols are:

Symbol Description
0 a digit
# a digit, zero shows as absent
. placeholder for decimal separator
, placeholder for grouping separator
E separates mantissa and exponent for exponential formats
; separates formats
- default negative prefix
% multiply by 100 and show as percentage
? multiply by 1000 and show as per thousand
currency sign; replaced by currency symbol; if doubled,
replaced by international currency symbol; if present in a
pattern, the monetary decimal separator is used instead of the
decimal separator
X any other characters can be used in the prefix or suffix
' used to quote special characters in a prefix or suffix

United Nations Conference on Trade and Development Page 18 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

Date formats:

Symbol Meaning Presentation Example


G era designator Text AD
y Year Number 1996
M month in year Text & Number July & 07
d day in month Number 10
h hour in am/pm (1-12) Number 12
H hour in day (0-23) Number 0
m minute in hour Number 30
s second in minute Number 55
S millisecond Number 978
E day in week Text Tuesday
D day in year Number 189
F day of week in month Number 2 (2nd Wed in July)
w week in year Number 27
W week in month Number 2
a am/pm marker Text PM
k hour in day (1-24) Number 24
K hour in am/pm (0-11) Number 0
z time zone Text Pacific Standard
Time
' escape for text Delimiter (none)
' single quote Literal '

Characters that are not letters are treated as quoted text. In other words, they will
appear in the formatted text even if they are not enclosed within single quotes.
The number of symbol letters specified also determines the format. For example, if the
"zz" pattern results in "PDT," then the "zzzz" pattern generates "Pacific Daylight
Time." The following table summarizes these rules:

Presentation Number of symbols Result


Text 1-3 abbreviated form, if one
exists
Text >= 4 full form
Number minimum number of digits is shorter numbers are
required padded with zeros (for a
year, if the count of 'y' is 2,
then the year is truncated
to 2 digits)
Text & 1-2 text form
Number
Text & 3 number form
Number

United Nations Conference on Trade and Development Page 19 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

3. Server modification
The modification required on the server concerns the table connector. The only things to do
are defining the connectors between DOM elements and table columns.

Source 14 -
Table connectors package un.asytutorial.tutorial3.server;
declaration in the
TC_Tutorial3 class import un.asytutorial.tutorial3.C_Tutorial3;
import java.sql.Types;
import so.kernel.server.ConnectionManager;
import so.kernel.server.GCFServerBinder;
import so.kernel.server.GCFTableConnector;
import so.kernel.server.ServerBinder;

public class TC_Tutorial3 extends GCFTableConnector implements C_Tutorial3 {

public TC_Tutorial3(GCFServerBinder serverBinder,ConnectionManager


connectionManager){

super(serverBinder,connectionManager,S_Tutorial3.getPERSON_TAB());
serverBinder.setInstanceIdField(this,INSTANCE_ID,INSTANCE_ID);

ServerBinder.DataSegment ide = ds(IDE);


add( ide.de(FNA), "IDE_FNA", Types.CHAR);
add( ide.de(LNA), "IDE_LNA", Types.CHAR);
add( ide.de(BDA), "IDE_BDA", Types.DATE);
add( ide.de(PIC), "IDE_PIC", Types.LONGVARBINARY);
add( ide.de(SEX), "IDE_SEX", Types.INTEGER);

ServerBinder.DataSegment coo = ds(COO);


add( coo.de(ADR), "COO_ADR", Types.CHAR);
add( coo.de(CPO), "COO_CPO", Types.CHAR);
add( coo.de(CIT), "COO_CIT", Types.CHAR);
add( coo.de(TEL), "COO_TEL", Types.INTEGER);

ServerBinder.DataSegment usr = ds(USR);


add( usr.de(LOG), "USR_LOG", Types.CHAR);
add( usr.de(PWD), "USR_PWD", Types.CHAR);
}
}

United Nations Conference on Trade and Development Page 20 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

4. Properties files
In this chapter you will learn

 Prepare properties files for deployment.

Properties files that will be modified


un.asytutorial.tutorial3.properties \server\som\config
un.asytutorial.properties \server\som\config
asytutorial_create.xml \server\som\db
asytutorial_insert.xml \server\som\db
install_src.xml \server\som

4.1. Tutorial3 properties files


Define the aliases for the database connection of the module in a new file:
un.asytutorial.tutorial3.properties.
These aliases will be used in the database.properties file. These files are situated in:
un\asytutorial\server\som\config

Source 15 -
Un.asytutorial.tutor un.asytutorial.tutorial3.server.S_Tutorial3#TUTORIAL_PERSON_DataBaseURL=$[un.asytut
ial3.properties file orial_URL]
un.asytutorial.tutorial3.server.S_Tutorial3#TUTORIAL_PERSON_DataBaseUser=$[un.asytu
torial_User]
un.asytutorial.tutorial3.server.S_Tutorial3#TUTORIAL_PERSON_DataBasePassword=$[un.
asytutorial_Password]

un.asytutorial.tutorial3.server.S_Tutorial3#TUTORIAL_PERSON_TAB=TUTORIAL3_PERS
ON_TAB

Also add the following line in the un.asytutorial.properties to take into account
the property file created:

Source 16 -
Un.asytutorial.prop @include un.asytutorial.tutorial2.properties
erties @include un.asytutorial.tutorial3.properties
….

United Nations Conference on Trade and Development Page 21 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

4.2. XML database table management


The next step is to modify the xml file that manages the automatic creation of the database
during the module installation.
Two files need to be modified:
• asytutorial_create.xml for the automatic creation of the tables in the
database
• asytutorial_insert.xml for the automatic insertion of records in the tables.
These files are located in: un\asytutorial\server\som\db

Source 17 -
Asyutorial_create.x …….
ml modifications <create>
……
<table name="TUTORIAL3_PERSON_TAB">
<column name= "INSTANCE_ID" type="INTEGER" null="false"/>
<column name= "IDE_FNA" type="VARCHAR" size="35"/>
<column name= "IDE_LNA" type="VARCHAR" size="35"/>
<column name= "IDE_BDA" type="TIMESTAMP"/>
<column name= "IDE_PIC" type="LONGVARBINARY"/>
<column name= "IDE_SEX" type="INTEGER"/>
<column name= "COO_ADR" type="VARCHAR" size="50"/>
<column name= "COO_CPO" type="VARCHAR" size="6"/>
<column name= "COO_TEL" type="VARCHAR" size="20"/>
<column name= "COO_CIT" type="VARCHAR" size="25"/>
<column name= "USR_LOG" type="VARCHAR" size="25"/>
<column name= "USR_PWD" type="VARCHAR" size="20"/>
<primary_key>
<column name= "INSTANCE_ID"/>
</primary_key>
</table>
</create>

Source 18 -
Asytutorial_insert.x <insert>
ml modifications <table name="TUTORIAL2_PERSON_TAB">
</table>
<table name="TUTORIAL3_PERSON_TAB">
</table>
</insert>

United Nations Conference on Trade and Development Page 22 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

4.3. Binder and shortcut definition


A binder and a shortcut have to be declared too.

Source 19 -
Adding binder and …….
shortcut in the <BU name="BUasytutorial">asytutorial BU</BU>
install_src.xml file ……
<binder name="B_TUTORIAL_3" status="">
<field name="server" value="un.asytutorial.tutorial3.server.S_Tutorial3"/>
<field name="dom" value="un.asytutorial.tutorial3.D_Tutorial3"/>
<field name="client" value="un.asytutorial.tutorial3.client.DC_Tutorial3"/>
<access bu="BUasytutorial">
<full/>
</access>
</binder>

<DL>
<folder name="Tutorial" icon="">
……..
<item name="Tutorial 3: Graphic User Interface" icon="">
<field name="binder" value="B_TUTORIAL_3"/>
<field name="skin" value="un.asytutorial.tutorial3.client.VD_Tutorial3"/>
<access bu="BUasytutorial">
<full/>
</access>
</item>
</folder>
</DL>

Now you can compile and deploy your module with Ant tools.

United Nations Conference on Trade and Development Page 23 of 24


Developer Guide
Version ADK 244
3 - Graphical User Interface

4.4. Exporting the database


Once you have installed your module, it is possible that you have to modify the structure of
the database. It is possible to export the changes to the existing database. This is done by
using the xmlimport tool (adk\bin\xmlimport.jar).
When the tool is opened, indicate the xml files (either just one or both) and the database to
modify. The checkbox at the bottom of the window has to be checked in the case of a
structure modification.

Figure7 - Xml import tool

United Nations Conference on Trade and Development Page 24 of 24

You might also like