Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
jvx:firstapp_step-by-step [2018/01/30 08:13]
admin
jvx:firstapp_step-by-step [2018/01/30 10:34]
admin
Line 20: Line 20:
       * Client       * Client
       * Server       * Server
-  * [[#workscreen|Creation of a work screen]] +  * [[#create_a_work_screen|Creation of a work screen]] 
-  * [[#hypersql|Use of a HyperSQL database]]+  * [[#create_database|Use of a HyperSQL database]]
  
 == Folder structure == == Folder structure ==
Line 39: Line 39:
 |apps|Contains all available applications. Only one application is contained in this concrete example.| |apps|Contains all available applications. Only one application is contained in this concrete example.|
 |firstapp|Contains the application with project configuration,​ sources, libraries.| |firstapp|Contains the application with project configuration,​ sources, libraries.|
-|help|Contains the client ​(GWT) for the online help and help pages.|+|help|Contains the client for the online help and help pages.|
 |libs|Contains all libraries which are necessary both on the client and the server.| |libs|Contains all libraries which are necessary both on the client and the server.|
 |libs/​client|Contains all libraries which are only necessary for the client.| |libs/​client|Contains all libraries which are only necessary for the client.|
Line 47: Line 47:
 |test|Contains unit tests for the client and server or the libraries.| |test|Contains unit tests for the client and server or the libraries.|
  
-Once the folder structure has been created, copy the library jvxclient.jar to the folder libs/client and the library jvx.jar to the folder libs/​server. Both libraries are contained in the JVx binary package.+Once the folder structure has been created, copy the library ​''​jvxclient.jar'' ​to the folder ​''​libs/client'' ​and the library ​''​jvx.jar'' ​to the folder ​''​libs/server''​. Both libraries are contained in the JVx binary package.
  
 == Project configuration == == Project configuration ==
Line 54: Line 54:
  
   * **File / New / Java Project**   * **File / New / Java Project**
-  * Note that the project has to be set up in the application folder firstapp \\ {{:​jvx:​newproject.png?​nolink|}} +  * Note that the project has to be set up in the application folder ​''​firstapp'' ​\\ {{:​jvx:​newproject.png?​nolink|}} 
-  * **Remove** the src folder from the **Source Folders** \\ **Set** the folders ''​src.client'',​ ''​src.server''​ and ''​test''​ as **Source Folder** \\ {{:​jvx:​newproject_folders.png?​nolink|}}+  * **Remove** the ''​src'' ​folder from the **Source Folders** \\ **Set** the folders ''​src.client'',​ ''​src.server''​ and ''​test''​ as **Source Folder** \\ {{:​jvx:​newproject_folders.png?​nolink|}}
   * **Add** the ''​jvx.jar''​ library, from the project directory ''​JVxFirstApp/​libs/​server''​ \\ {{:​jvx:​newproject_libs.png?​nolink|}}   * **Add** the ''​jvx.jar''​ library, from the project directory ''​JVxFirstApp/​libs/​server''​ \\ {{:​jvx:​newproject_libs.png?​nolink|}}
   * The project can now be created   * The project can now be created
Line 62: Line 62:
  
 {{:​jvx:​project_eclipse.png?​nolink|}} {{:​jvx:​project_eclipse.png?​nolink|}}
 +
 +The ''​src''​ folder can be deleted for consistency,​ as it is not needed in our application.
  
 == Application development == == Application development ==
Line 112: Line 114:
 </​server>​ </​server>​
 </​file>​ </​file>​
-\\  +The server does not need any special parameters for our application. \\ \\ For the client, we now need a class of type ''​javax.rad.application.IApplication''​. A standard implementation of JVx is implemented via ''​com.sibvisions.rad.application.Application''​. We then derive our client from it and thereby create a class, in the directory ​''​src.client''​, with the following source code:
-For the client, we now need a class of type javax.rad.application.IApplication. A standard implementation of JVx is implemented via com.sibvisions.rad.application.Application. We then derive our client from it and thereby create a class, in the directory src.client, with the following source code:+
  
 <file java FirstApplication.java>​ <file java FirstApplication.java>​
Line 173: Line 174:
 ^Method^Description^ ^Method^Description^
 |Constructor|The standard constructor cannot be used, as each application is started with a technology-dependent launcher. This launcher is already passed to the application in the constructor.| |Constructor|The standard constructor cannot be used, as each application is started with a technology-dependent launcher. This launcher is already passed to the application in the constructor.|
-|createConnection|The communication protocol is initialised. A DirectServerConnection is sufficient for our application,​ because both the client and the server are started in the same VM. However, if an application server is in use, a HttpConnection could also be used.| +|createConnection|The communication protocol is initialised. A ''​DirectServerConnection'' ​is sufficient for our application,​ because both the client and the server are started in the same VM. However, if an application server is in use, a ''​HttpConnection'' ​could also be used.| 
-|getApplicationName|Sets the application name. This name is needed for the communication with the server, as the  latter uses the appropriate application configuration depending on the application name. \\ In our case the application name must be firstapp, because the work directory is also called ''​../​JVxFirstApp/​rad/​firstapp/''​. The application name MUST always match the directory name!|+|getApplicationName|Sets the application name. This name is needed for the communication with the server, as the  latter uses the appropriate application configuration depending on the application name. \\ In our case the application name must be ''​firstapp''​, because the work directory is also called ''​../​JVxFirstApp/​rad/​**firstapp**/''​. The application name MUST always match the directory name!|
  
 It is now time for the first start of the application. To do so, we set up a Runtime configuration:​ It is now time for the first start of the application. To do so, we set up a Runtime configuration:​
Line 331: Line 332:
 We now create the client class for our work screen: We now create the client class for our work screen:
  
-  * **File** / **New** / **Class** \\ {{:​jvx:​dbedit_new.png?​nolink|}}+  * **File** / **New** / **Class** ​\\ ''​src.client'',​ ''​apps.firstapp.frames.DBEditFrame''​\\ {{:​jvx:​dbedit_new.png?​nolink|}}
  
 and use the following Source Code: and use the following Source Code:
Line 378: Line 379:
   /**   /**
    * Creates a new instance of DBEditFrame for a specific application.    * Creates a new instance of DBEditFrame for a specific application.
- * <​p/>​ +   * <​p/>​ 
- * @param pApp the application +   ​* @param pApp the application 
- * @throws Throwable if the remote access fails +   ​* @throws Throwable if the remote access fails 
- */ +   ​*/ 
- ​public DBEditFrame(Application pApp) throws Throwable +  public DBEditFrame(Application pApp) throws Throwable 
- { +  
- ​super(pApp.getDesktopPane());​+    super(pApp.getDesktopPane());​
    
- application = pApp;+    ​application = pApp;
    
- initializeModel();​ +    ​initializeModel();​ 
- ​initializeUI();​ +    initializeUI();​ 
- }+  }
    
- /** +  ​/** 
- * Initializes the model. +   ​* Initializes the model. 
- * <​p/>​ +   ​* <​p/>​ 
- * @throws Throwable if the initialization throws an error +   ​* @throws Throwable if the initialization throws an error 
- */ +   ​*/ 
- ​private void initializeModel() throws Throwable +  private void initializeModel() throws Throwable 
- { +  
- //we use a new "​session"​ for the screen +    //we use a new "​session"​ for the screen 
- ​connection = ((MasterConnection)application.getConnection()). +    connection = ((MasterConnection)application.getConnection()). 
- ​createSubConnection("​apps.firstapp.frames.DBEdit"​);​ +    createSubConnection("​apps.firstapp.frames.DBEdit"​);​ 
- ​connection.open();​+    connection.open();​
  
- //data connection +    ​//data connection 
- ​dataSource.setConnection(connection);​ +    dataSource.setConnection(connection);​ 
- ​dataSource.open();​+    dataSource.open();​
    
- //table +    ​//table 
- ​rdbContacts.setDataSource(dataSource);​ +    rdbContacts.setDataSource(dataSource);​ 
- ​rdbContacts.setName("​contacts"​);​ +    rdbContacts.setName("​contacts"​);​ 
- ​rdbContacts.open();​ +    rdbContacts.open();​ 
- }+  }
    
- /** +  ​/** 
- * Initializes the UI. +   ​* Initializes the UI. 
- * <​p/>​ +   ​* <​p/>​ 
- * @throws Exception if the initialization throws an error +   ​* @throws Exception if the initialization throws an error 
- */ +   ​*/ 
- ​private void initializeUI() throws Exception +  private void initializeUI() throws Exception 
- { +  
- ​UIGroupPanel group = new UIGroupPanel();​ +    UIGroupPanel group = new UIGroupPanel();​ 
- ​group.setText("​Available Contacts"​);​+    group.setText("​Available Contacts"​);​
    
- UITable table = new UITable();​ +    ​UITable table = new UITable();​ 
- ​table.setDataBook(rdbContacts);​+    table.setDataBook(rdbContacts);​
    
- group.setLayout(new UIBorderLayout());​ +    ​group.setLayout(new UIBorderLayout());​ 
- ​group.add(table);​+    group.add(table);​
    
- //same behaviour as centered component in BorderLayout  +    ​//same behaviour as centered component in BorderLayout  
- ​setLayout(new UIBorderLayout());​ +    setLayout(new UIBorderLayout());​ 
- ​add(group); ​+    add(group); ​
  
- setTitle("​Contacts"​);​ +    ​setTitle("​Contacts"​);​ 
- ​setSize(new UIDimension(400,​ 500)); +    setSize(new UIDimension(400,​ 500)); 
- ​} ​+  
  
- //​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +  ​//​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
- // Overwritten methods +  // Overwritten methods 
- //​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+  //​~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
- /** +  ​/** 
- * Closes the communication connection and disposes the frame. +   ​* Closes the communication connection and disposes the frame. 
- */ +   ​*/ 
- ​@Override +  @Override 
- ​public void dispose() +  public void dispose() 
- { +  
- try +    try 
- { +    
- ​connection.close();​ +      connection.close();​ 
- } +    
- catch (Throwable th) +    catch (Throwable th) 
- { +    
- //​nothing to be done +      //nothing to be done 
- } +    
- ​finally +    finally 
- { +    
- ​super.dispose();​ +      super.dispose();​ 
- } +    
- }+  }
  
 } // DBEditFrame } // DBEditFrame
Line 509: Line 510:
 The client implementation is now finished. Before we can use the application,​ we must create the missing server classes. We create the following classes: The client implementation is now finished. Before we can use the application,​ we must create the missing server classes. We create the following classes:
  
-  * {{:​jvx:​lco_application.png?​nolink|}}+  * **File** / **New** / **Class** \\ ''​src.server'',​ ''​apps.firstapp.Application''​\\ ​{{:​jvx:​lco_application.png?​nolink|}}
  
 <file java Application.java>​ <file java Application.java>​
Line 530: Line 531:
 |The class represents the lifecycle object for an application. There is exactly one instance of this class for each application,​ thereby enabling the use of session-wide objects.| |The class represents the lifecycle object for an application. There is exactly one instance of this class for each application,​ thereby enabling the use of session-wide objects.|
  
-  * {{:​jvx:​lco_session.png?​nolink|}}+  * **File** / **New** / **Class** \\ ''​src.server'',​ ''​apps.firstapp.Session''​ \\ {{:​jvx:​lco_session.png?​nolink|}}
  
 <file java Session.java>​ <file java Session.java>​
Line 583: Line 584:
 |getDBAccess|Opens a new connection to a HyperSQL database, if this has not already happened. \\ \\ The Exception Handling is taken over by the server.| |getDBAccess|Opens a new connection to a HyperSQL database, if this has not already happened. \\ \\ The Exception Handling is taken over by the server.|
  
-  * {{:​jvx:​lco_dbedit.png?​nolink|}}+  * **File** / **New** / **Class** \\ ''​src.server'',​ ''​apps.firstapp.frames.DBEdit''​ \\ {{:​jvx:​lco_dbedit.png?​nolink|}}
  
 <file java DBEdit.java>​ <file java DBEdit.java>​
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information