Versions Compared

Key

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

This tutorial demonstrates the Live Forms frevvo 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 .

Column
width240px

On This Page:

Table of Contents
maxLevel2
 

...

Installing the Client Libraries and Dependencies

 The Live Forms frevvo Java Client Library has the following dependencies:

...

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 frevvo 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 the .jar files located in the <frevvo-home>\ext\client directory of your  build.

...

  1. Edit the <frevvo-home>\tomcat\webapps\api \apitutorial\doLogin.jsp file. 

    1. On line number 14, replace the default values with your Live Forms frevvo server and port number:

      Code Block
      service = new FormsService("http", "localhost", 8082, null); 
      to 
      service = new FormsService("http", "<your-frevvo-server-host>", <your-frevvo-server-port>, null); 



    2. On line number 20, replace the default values with the admin username, tenant and admin user password previously created for this tutorial: 

      Code Block
      "admin@apitutorial", "admin"  
      to 
      "<your-tenant-admin-user>@<your-tenant>", "< your-tenant-admin-user-password>" 
  2. Save the file and re-start (tomcat).

...

  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 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 Live Forms frevvo using the same user that is logged into your application 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); 

...

Code Block
if (EmpInfoFromName.equals(fte.getTitle().getPlainText())){
           FormTypeEntry employeeInfoForm = fte;

           FormEntryBuilder builder = employeeInfoForm.createInstanceBuilder();

 
           //XML for palette controls
           String xmlFile1=getServletContext().getRealPath("/apitutorial/Resources/TomCat.xml"); 

           InputStream is_xml = new FileInputStream(xmlFile1);
           builder.document("TomCat", is_xml);

           //XML for schema controls
           String xmlFile2=getServletContext().getRealPath("/apitutorial/Resources/TomCatAddress.xml"); 
           InputStream is_xml2 = new FileInputStream(xmlFile2);
           builder.document("TomCatAddress", is_xml2);    

 
           //Attachment File
           String 
           attachmentFile=getServletContext().getRealPath("/apitutorial/Resources/TomCatProfileAttachment.jpg"); 
           InputStream is_attachment = new FileInputStream(attachmentFile);
           builder.attachment("UploadAProfilePicture", "image/jpeg", "TomCatProfileAttachment.jpg", is_attachment);

 
           //Wet Signature File
           String 
           signatureFile=getServletContext().getRealPath("/apitutorial/Resources/TomCatSignature.png"); 
           InputStream is_wetSignature = new FileInputStream(signatureFile);
           builder.wetSignature("_kRnhsUGSEeO6ha2krvWZUA", "TomCatSignature.png", is_wetSignature);

 
           //Form Action
           builder.parameter("_formActionUrl", request.getRequestURL().toString().substring(0, request.getRequestURL().toString().lastIndexOf('/')) + "/index.html");
           builder.parameter("_formActionTarget","top");
           builder.parameter("_cancelUrl", request.getRequestURL().toString().substring(0, request.getRequestURL().toString().lastIndexOf('/')) + "/index.html");

 
           FormEntry fEntry = builder.createInstance();
           String XMLInitializeFormURL = fEntry.getFormUseLink().getHref(); 
}

 


Embed Task List

 On the XML initialized Employee Information form, click the Save button to create a saved task:

Click on the Tasks link from the left menu to open the task list. Clicking on the perform icon of the saved task will load the saved form.

 


 Edit the <frevvo-home>\tomcat\webapps\api\apitutorial\showTaskList.jsp file to see how the task list is embedded using the API. 

...

  1. The logout.jsp will check if the service instance is not null, that is if a user login already exists for the service instance. If yes, then we logout that user from the FormsService session and remove the service instance from the HTTP session:  

    Code Block
    FormsService service = (FormsService) session.getAttribute ( "frevvo.forms.service" );    
    if (service != null) {     
              service.logout(); 
              session.removeAttribute ("frevvo.forms.service");      
    }
  2. Then it will redirect the user to the login.jsp page of the web application:

    Code Block
    response.sendRedirect("login.jsp"); 

 

 

 

 

 

 

 

...

 

 

 

 

 

 

 

 

...

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

...