ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Managing external languages / Java
  • Overview
  • Implementation
  • Including the files of the Java interface of WINDEV
  • Loading the WINDEV library (WDL)
  • Running WINDEV codes from the external language
  • 1. Calling a WLanguage code
  • 2. Retrieving the events triggered in the WINDEV windows
  • Ending the application
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
We are going to call the elements developed in WINDEV (project, windows, analysis, ...) from the Java language. The WLanguage code used from the external language will be dynamically compiled and run during its call.
This mode is illustrated in the "City.JAVA" project (Java format), available in the "External Languages\EN\Java" subdirectory of the WINDEV installation directory.
Remark: The Java external language does not support the HFSQL engine. To use the HFSQL engine, perform the necessary processes in WINDEV.
Implementation

Including the files of the Java interface of WINDEV

The following file must be included in your Java code to use WINDEV's Java interface: WINDEV.CLASS (source code available in WINDEV.JAVA)
The following lines must be found in the code of the main ".JAVA" file of your Java code:
public class ville extends WINDEV
{
...
}
These lines allow you to retrieve the minimum declarations required to use the external interface.
Remark: It is also possible to call methods from the WINDEV class by prefixing these methods with the word "WINDEV.". In this case, the previous lines of code are not required.
Loading the WINDEV library (WDL)
The WINDEV library (.WDL extension) contains all the project elements (windows, reports, classes, queries, analysis, ...). Therefore, it must be loaded in memory in order for its components to be called.
Attention: If the library to be loaded contains windows, the code for each of these windows must be integrated into the corresponding ".WDW" file (option "Integrate compiled code" checked, in the "Detail" tab of each window description).
/* Ouverture de la bibliotheque */
/* si WDEntier n'est pas nul, la bibliothèque n'a pas été trouvée! */
APPELWD("BIBLI,Disque,ville.wdl");
/* équivalent à: Windev.APPELWD("BIBLI,Disque,ville.wdl"); */
if (WDEntier() == 0)
/* équivalent à: if (Windev.WDEntier() == 0) */
{
...
else
{
/* Bibliothèque non trouvée */
APPELWD("Erreur, Bibliothèque non trouvée");
/* équivalent à: Windev.APPELWD("Erreur, Bibliothèque non trouvée"); */

}
Running WINDEV codes from the external language

1. Calling a WLanguage code

All the WLanguage functions can be called from the external language. The behavior of these WLanguage functions as well as the returned values are identical whether they are called:
  • from WINDEV or
  • from the interface of external language
To find out the parameters and the return values of a WLanguage function, see the online help or the documentation about WLanguage.
You can use CallWD to call a WLanguage procedure from the external interface. For example:
/* ouverture de la première fenêtre du programme contenant le menu */
APPELWD("Ouvre,menufc.wdw");
/* équivalent à: Windev.APPELWD("Ouvre,menufc.wdw"); */

2. Retrieving the events triggered in the WINDEV windows

The input in the WINDEV windows requires to retrieve the events triggered in these windows.
To retrieve the user events (click on a menu, on a button, ...), you must implement a system based on a loop in your Java program. This loop will remain active as long as the WINDEV window is opened and it will be used to intercept each user action.
To find out the type of action performed by the user, you have the ability to use a character string variable (in WLanguage) named 'WDKey'. This variable will be used in your WLanguage code to signal to the Java program which button was pressed for example.
Example: Java code
/* ouverture de la première fenêtre du programme contenant le menu */
APPELWD("Ouvre,menufc.wdw");
/* le programme boucle jusqu'à ce que le choix Fichier Quitte
soit sélectionné */
boolean bSaisie = true;
while (bSaisie)
{
/* on effectue la saisie du menu */
APPELWD("Ecran,Saisie");
/* le compte-rendu WDTouche vaut *M* lorsque un choix de menu
a été sélectionné */
if (WDTouche().equals("*M*"))
{
...
}
}
APPELWD("FERME");
Code for intercepting the selection of "File..Exit" of the WINDEV "Menu" window:
String szOption = WDTouche();
if (szOption.equals("FQ"))
{
bSaisie = false;
}
When the user clicks "File .. Exit":
  • WDKey will return "*M*".
  • WDString will return the shortcut letters in the order in which the menus are selected. In our example, WDString returns "FE".
Ending the application
To end the use of external interface, type the following lines of code:
/* Terminer... */
WDTermine();
/* équivalent à: Windev.WDTermine(); */
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help