Versions Compared

Key

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

This tutorial demonstrates the Live Forms Data API Java Client library features using a web application and a JSP. The web application is created using JSP (Java Server Pages).  We will refer to several Java Server Page files to explain the API features. You will see these delimiters in the files:

  • <% … %> delimiters in the JSP pages enclose Java code fragments.
  • <%= ... %> delimiters are used for expressions.

 <frevvo-home> in the file paths refers to the frevvo subdirectory that was created when you installed .

Note

In v9.1 and later 's "Applications" are known as "Projects." Where the documentation below refers to  Applications it corresponds to  v9.1+ ProjectsThe API objects and methods still use the word Application.

Column
width30%

On This Page:

Table of Contents
maxLevel2
 

...

  1. LoginAs and session management using API.
  2. Upload of a sample Tutorial Application Project into a designer account. 
  3. FormTypeFeed:Initialization of a form with XML data, Attachment and Wet Signature 

    1. List Projects, Forms and Workflows 
    2. Raw and Pop-Up links to use Forms/Workflows 
    3. Edit link to edit Forms/Workflows in design mode 
    4. View Submissions link to list all Form/Workflow Submissions
  4. TaskFeed: embed task list
  5. SubmissionFeed: Logout of user account using API
    1. List of all Form/Workflow submissions
    2. Link to Edit each submission 
    3. Links to submission XMLs 
    4. Link to submission print PDF 
    5. Links to wet signatures in each submission
    6. Links to uploaded attachments in each submission

...

These client libraries are already added in <frevvo-home>\tomcat\webapps\api\WEB-INF\lib directory of the web application that we are using. However, the actual jar versions may be different depending on the version of Live Forms being used. To ensure that you have the latest versions of these files, it is recommended that you replace the client libraries that come with the Java API Tutorial Application with Project with the .jar files located in the <frevvo-home>\ext\client directory of your  build.

...

  1. In the doLogin.jsp page, we create a FormService instance:

    Code Block
    FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" ); 
  2. If the service instance is not null, that is if a user login already exists for the service instance, we logout that user from the FormsService session and remove the service instance from the HTTP session:

    Code Block
    if (service != null) { 
              service.logout();  
              session.removeAttribute ("frevvo.forms.service"); 
    } else {  
              service = new FormsService("http", "localhost", 8082, null); 
    } 
  3. Then we use the LoginAs method to login to the account whose username was entered on the login.jsp page. This method allows you to login to Live Forms 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 Live Forms using the same user that is logged into your application project without having to know their password.

    The request.getParameter( "username" ) gets the username value which was passed from the login.jsp page.

    The LoginAs method also returns the logged in user information in AutoLoginUserInfo object.

    Code Block
    Map<String, String> customParams = new HashMap<String, String>(1); 
    customParams.put("autoLogin", "true"); 
    customParams.put("checkUserCount", "false"); 
    AutoLoginUserInfo alui = service.loginAs (request.getParameter( "username" ), 
           admin@apitutorial, "admin", true, null,  
           request.getParameter( "firstname" ),  
           request.getParameter( "lastname" ),   
           request.getParameter( "email" ),  
           customParams); 
  4. Then we add the service instance to the HTTP session: 

    Code Block
    session.setAttribute ("frevvo.forms.service", service); 
  5. We also save the user information returned in AutoLoginUserInfo object alui to the HTTP session: 

    Code Block
    session.setAttribute ("user.info", alui); 
  6. Lastly we redirect user to the next JSP page of the web application based on the targeturl parameter: 

    Code Block
    String url = request.getParameter("targeturl"); 
    response.sendRedirect(url); 

On your web applications login page, enter your designer user name and click Submit. You will see the formtypes.jsp page shown in the image:

 

Uploading the Tutorial

...

Project

Now that you have displayed the formtypes.jsp page, let's look at the formtypes.jsp file to see how this is implemented:  

...

  1. The formtypes.jsp checks if the HTTP session contains a FormService instance with a valid user login. If not, then it redirects to the login.jsp page to create a valid user login:

    Code Block
    FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" );
    if (service == null) {
              response.sendRedirect("login.jsp");
              return;
    }   
  2. It also gets the user information stored in the user.info attribute of the HTTP session. The ApplicationFeed and FormTypeFeed are available only for designer user logins. We will not retrieve the applications projects and forms if the current logged in user is not a designer, i.e. alui.designer is false:

    Code Block
    AutoLoginUserInfo alui = (AutoLoginUserInfo) session.getAttribute ( "user.info" );
       if(!(alui.designer)){
                 ...
  3. Next it gets the ApplicationFeed for the current logged in user:

    Code Block
    ApplicationFeed af = service.getFeed(service.getFeedURL(ApplicationFeed.class), 
    ApplicationFeed.class);
  4. Now it will check if the Tutorial Application exists Project exists in the current logged in designer user account:

    Code Block
    ApplicationEntry TutorialApp = null;
        String TutorialAppName = "Tutorial Application"; 
     
    for (ApplicationEntry appEntry :af.getEntries()) {    
         if (TutorialAppName.equals(appEntry.getTitle().getPlainText())){ 
                  TutorialApp = appEntry;
                  break;        
         } else {
          continue;
         }
    }       
  5. If the Tutorial Application Project does not exist then it will upload the application project to the designer user account. The application The project zip file that we are uploading is <frevvo-home>\tomcat\webapps\api\apitutorial\Resources\TutorialApplication_v52_app.zip.

    Code Block
    String EmpInfoFromName = "Employee Information";
    if(TutorialApp == null){
         String 
    filepath=getServletContext().getRealPath("/apitutorial/Resources/TutorialApplication_v52_app.zip");     
         InputStream appZipStream = new FileInputStream(filepath);
     
         MediaStreamSource appMediaSource = new 
    MediaStreamSource(appZipStream,"application/zip");      
         ApplicationEntry appEntry = af.insert(appMediaSource); 
  6. The default deployment state of the Employee Information form in this uploaded application is project is DEVELOPMENT. We changed the deploy state of the form to PRODUCTION with the code shown below:

    Code Block
         FormTypeFeed ftFeed = appEntry.getFormTypeFeed(); 
         for (FormTypeEntry empform : ftFeed.getEntries()) { 
              if (EmpInfoFromName.equals(empform.getTitle().getPlainText())){ 
                      empform.setDeployState(DeployState.PRODUCTION); 
                      empform = empform.update(); 
                      empform = empform.getSelf(); 
                      break; 
              } else { 
                      continue; 
              } 
         } 
    }  

     

List

...

Projects / Forms and Workflows

Once the application project is uploaded we now list all the ApplicationsProjects/Forms/Workflows in this user account.

  1. We get the updated ApplicationFeed after the Tutorial Application Project is uploaded. The application feed contains all the applications projects in this user account: 

    Code Block
    af = service.getFeed(service.getFeedURL(ApplicationFeed.class), ApplicationFeed.class); 
  2. Then we iterate over each ApplicationEntry in the ApplicationFeed and from each ApplicationEntry we get the FormTypeFeed which contains the forms and workflows in that applicationproject:

    Code Block
    String[] types = {"FORM", "FLOW"}; 
    for (ApplicationEntry ae : af.getEntries()) { 
     FormTypeFeed ftf = ae.getFormTypeFeed();  
     … 
  3. We iterate over each FormTypeEntry in the FormTypeFeed twice using the types iterator defined above. Once to collect all the forms and the second time to collect all the workflows in that applicationproject:

    Code Block
    for (String mytype : types){
             for (FormTypeEntry fte : ftf.getEntries()) { 
             if(fte.getKind().contentEquals(mytype)){
             … 
  4. Then we get the Raw Link, Popup Link and Edit link for the forms/workflows from the FormTypeEntry:

    Code Block
    //Get Raw Link
    String RawLink = fte.getFormTypeLink(null).getHref() + formAction;
    //Get Popup Link
    String PopUpLink = fte.getFormTypePopupLink(null).getHref() + formAction;
    //Get Form Edit Link to edit the form in design mode
    String EditorLink = fte.getFormTypeEditorLink(null).getHref() + formAction;
  5. Next we check if there are any submissions associated with the form/workflow. If yes, then we get the FormTypeID for the form. Then this FormTypeID is appended as the URL parameter to the showSubmissions.jsp page link. The showSubmission.jsp page will use this FormTypeID to list all the form submissions (See SubmissionFeed):

    Code Block
    if(fte.getSubmissionFeed().getEntries().size() > 0) {  
             String formtypeid = fte.getId().split("!")[0];  
             String SubmissionsLink = "showSubmissions.jsp?formtypeId=" + formtypeid;
             ...

       

...