Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...


Section


Column

So you've decided to use the Data frevvo Data Java client library to have a deeper integration between your application and frevvo. Our aim with this tutorial is to quickly get you started in using the Java client library by guiding you through the implementation of a simple application.

We will first help you configure your development environment and then jump straight into the Java code. This tutorial assumes that you have already installed a recent version of the Java JDK (5.0 or 6.0) and that you have already downloaded Tomcat frevvo Tomcat bundle from LiveForms web site. The Tomcat bundle contains all the required Java Client jars.

Note

In v9.1 and later frevvo's "Applications" are known as "Projects." The API objects and methods still use the word Application.



Column
width30%

On this page:

Table of Contents
maxLevel1
 


...

We are going to build a simple contacts project using  and frevvo and the Data API Java Client Library.

This project will be composed on a single contact form that will be used to add new contacts, view and edit existing ones. For the sake of simplicity and the focus on the APIs, the application will be provided as an interactive command-line executable and contacts will be stored in frevvo's internal submission repository. The command-line executable will automatically open forms using the system's browser (e.g. when editing, viewing or creating a new contact).

...

  • Login/logout and session management
  • Upload a sample project into into frevvo
  • List the existing submissions for a sample form
  • Create a new submission
  • View a submission
  • Edit a submission
  • Query submissions & pagination
  • Delete a submission

Installing the Client Library and Dependencies

The  Java frevvo Java Client Library has the following dependencies:

...

Note

The actual jar versions may be different depending on the version of being frevvo being used.

Contacts application

...

The Contacts application described here is comprised of a single .jar file that contains all the required dependencies including the Contacts  project frevvo project .zip (more details about this below).

...

Assuming that you have an installation of  up of frevvo up and running (e.g. http://localhost:8082) and a user account (e.g. designer) in a given tenant (e.g. tutorial), you can run the command-line app here, replacing 'forms-cli.jar' with the current jar filename.

...

Once you are logged in to frevvo, create a project named Contacts and then create a Contact form with a set of contact controls such as first name, last name, address, zip code, etc.

...

Authentication & Session Management

When interacting with frevvo, the Contacts application will first need to establish a session using the Data API. This is done by using the com.frevvo.forms.client.FormsService class and by providing proper credentials to authenticate.

...

When this command-line program is terminating we make sure that we properly logout from frevvo. This ensures that  will frevvo will release any unneeded resources and the user count will be decremented (licensing).

LoginAs

 supports frevvo supports an additional way of logging into  using frevvo using the Data API: the loginAs() method. This new method allows you to login to  as frevvo as any of the existing tenant users provided you can pass in the tenant's admin user and password. This is quite convenient when you want login to  using frevvo using the same user that is logged into your project without having to know their password.

...

When your tenant was configured with the DelegatingSecurityManager, you can use the overloaded loginAs() method to automatically create virtual users in frevvo. For instance:

Code Block
    ...
    String tenantAdmin = getUsername() + '@' + getTenant();
    String tenantAdminPwd = getPassword();
    String username = getAsUsername();

    FormsService s = new FormsService(getProtocol(), getHost(), getPort(), null);
    s.loginAs(username, tenantAdmin, tenantAdminPwd, true, null, null, null, null, null);
    ...

This will automatically create a new, non-designer user (i.e. will be able to participate in workflows but not create forms/workflows), if it doesnt yet exist. If you want  to frevvo to auto create a new virtual user that is also a designer you need to pass in the frevvo.Designer role when calling loginAs(). For instance:

...

As described earlier, we have downloaded the frevvo Contacts application .zip file and embedded it in the command-line .jar. This .zip file is available from the JVM Classpath and will be automatically uploaded if it cannot be found in the frevvo server, i.e. usually the first time you connect to a frevvo/tenant install.

The following code snippet shows how we do this. We first try to find the Contact Form form by ID (as we described earlier) and if we cant find it, we will upload the project.zip file.

...

Now that we are logged in to  and frevvo and have the Contact project uploaded, let's list the current contacts we have in the submission's repository. This is done by entering the list command:

...

Note that editing a contact here is nothing more than rendering a form and initializing it with the XML document(s) stored in frevvo's submission repository. Since this repository is embedded in frevvo, we have automated some of the work of instantiating a form and initializing it from an XML document(s). However, what if you are integrating  with frevvo with your own application and have your own database of contacts? Not a problem. You can use the API to instantiate the form passing in a list of XML documents.

...