Adobe® LiveCycle® Data Services ES 2.6 Developer Guide

Building your server-side application

You write the server-side part of a LiveCycle Data Services ES application in Java, and then use the javac compiler to compile it.

Creating a simple Java class to return data to the client

A common reason to create a server-side Java class is to represent data returned to the client. For example, the client-side RemoteObject component lets you access the methods of server-side Java objects to return data to the client.

The Test Drive sample application contains the Accessing Data Using Remoting sample where the client-side code uses the RemoteObject component to access product data on the server. The Product.java class represents that data. After starting the LiveCycle Data Services ES server and the samples database, view this example by opening the following URL in a browser: http://localhost:8400/lcds-samples/testdrive-remoteobject/index.html.

The source code for Product.java is in the install_root\lcds-samples\WEB-INF\src\flex\samples\product directory. For example, if you installed LiveCycle Data Services ES with the integrated Tomcat server on Microsoft Windows, the directory is C:\lcds\tomcat\webapps\lcds-samples\WEB-INF\src\flex\samples\product.

Modify, compile, and deploy Product.java on the lcds-sample server

  1. Start the samples database.
  2. Start LiveCycle Data Services ES.
  3. View the running example by opening the following URL in a browser:

    http://localhost:8400/lcds-samples/testdrive-remoteobject/index.html

  4. Click the Get Data button to download data from the server. Notice that the description column contains product descriptions.
  5. In an editor, open the file C:\lcds\tomcat\webapps\lcds-samples\WEB-INF\src\flex\samples\product\Product.java. Modify this path as necessary for your installation.
  6. Modify the following getDescription() method definition so that it always returns the String "My description" rather than the value from the database:
    public String getDescription() {
        return description;
    }
    
    

    The modified method definition appears as the following:

    public String getDescription() {
        return "My description.";
    }
    
    
  7. Change the directory to lcds-samples.
  8. Compile Product.java by using the following javac command line:
    javac -d WEB-INF/classes/ WEB-INF/src/flex/samples/product/Product.java 
    
    

    This command creates the file Product.class, and deploys it to the WEB-INF\classes\flex\samples\product directory.

  9. View the running example by opening the following URL in a browser:

    http://localhost:8400/lcds-samples/testdrive-remoteobject/index.html

  10. Click the Get Data button.

    Notice that the description column now contains the String "My description" for each product.

Creating a Java class that extends a LiveCycle Data Services ES class

As part of developing your server-side code, you can create a custom assembler class, factory class, or other type of Java class that extends the LiveCycle Data Services ES Java class library. For example, a data adapter is responsible for updating the persistent data store on the server in a manner appropriate to the specific data store type.

You perform many of the same steps to compile a Java class that extends the LiveCycle Data Services ES Java class library as you do for compiling a simple class. The major difference is to ensure that you include the appropriate LiveCycle Data Services ES JAR files in the classpath of your compilation so that the compiler can locate the appropriate files.

The Test Drive sample application contains the Data Management Service sample, in which the server-side code uses a custom assembler represented by the ProductAssembler.java class. To view the sample, start the LiveCycle Data Services ES server and the samples database. Then open the following URL in a browser: http://localhost:8400/lcds-samples/testdrive-dataservice/index.html.

The source code for ProductAssembler.java is in the directory install_root\lcds-samples\WEB-INF\src\flex\samples\product. For example, if you installed LiveCycle Data Services ES with the integrated Tomcat server on Microsoft Windows, the directory is C:\lcds\tomcat\webapps\lcds-samples\WEB-INF\src\flex\samples\product.

Compile and deploy ProductAssembler.java on the lcds-sample server

  1. View the running example by opening the following URL in a browser:

    http://localhost:8400/lcds-samples/testdrive-dataservice/index.html

  2. Click the Get Data button to download data from the server.
  3. In an editor, open the file C:\lcds\tomcat\webapps\lcds-samples\WEB-INF\src\flex\samples\product\
    ProductAssembler.java. Modify this path as necessary for your installation.

    For more information on assemblers, see Standard assemblers.

  4. Change the directory to C:\lcds\tomcat\webapps\lcds-samples\WEB-INF\src.
  5. Compile ProductAssembler.java by using the following javac command line:
    javac  
        -sourcepath . 
        -d ..\classes
        -classpath ..\lib\flex-messaging-common.jar;
            ..\lib\flex-messaging-core.jar;
            ..\lib\flex-messaging-data-req.jar;
            ..\lib\flex-messaging-data.jar;
            ..\lib\flex-messaging-opt.jar;
            ..\lib\flex-messaging-proxy.jar;
            ..\lib\flex-messaging-remoting.jar
        flex\samples\product\ProductAssembler.java
    
    

    Notice that the classpath contains many, but not all, of the JAR files in WEB-INF\lib. If you are compiling other types of classes, you include additional JAR files in the classpath. These JAR files are also shipped in the install_root/resources/lib directory.

    This command creates the file ProductAssembler.class in the same directory as ProductAssembler.java.

  6. View the running example by opening the following URL in a browser:

    http://localhost:8400/lcds-samples/testdrive-dataservice/index.html

  7. Click the Get Data button to make sure that your code is working correctly.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/lcds/build_apps_5.html