Versions Compared

Key

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

...

Table of Contents
maxLevel1

How do I login and logout to and from an Oracle Forms server?

See the Java code snippet below:

...

Since there is some overhead associated with logging in and out, you need to keep the FormsService instance around for as long as you need to interact with  before logging out.

How do I get the list of all applications for the current user?

Code Block
    FormsService fs = ...;
    URL appFeedUrl = fs.getFeedURL(ApplicationFeed.class);
    ApplicationFeed appFeed = fs.getFeed(appFeedUrl, ApplicationFeed.class);
    for(ApplicationEntry appEntry: appFeed.getEntries()){
        System.out.println("Application Name: " + appEntry.getTitle().getPlainText());
    }

How do I get the list of all themes for the current user?

Code Block
    FormsService fs = ...;
    URL themeFeedUrl = fs.getFeedURL(ThemeFeed.class);
    ThemeFeed themeFeed = fs.getFeed(themeFeedUrl, ThemeFeed.class);
    for(ThemeEntry themeEntry: themeFeed.getEntries()){
        System.out.println("Theme Name: " + themeEntry.getTitle().getPlainText());
    }

How do I get the list of all forms for the current user?

Code Block
    FormsService fs = ...;
    URL ftFeedUrl = fs.getFeedURL(FormTypeFeed.class);
    FormTypeFeed ftFeed = fs.getFeed(ftFeedUrl, FormTypeFeed.class);
    for(FormTypeEntry ftEntry: ftFeed.getEntries()){
        System.out.println("FormType Name: " + ftEntry.getTitle().getPlainText());
    }

How do I get the list of all forms for a given application?

The code snippet below prints the name of all forms in the appEntry application:

Code Block
    ApplicationEntry appEntry = ...;
    FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
    for(FormTypeEntry ftEntry: ftFeed.getEntries()){
        System.out.println("Form Name: " + ftEntry.getTitle().getPlainText());
    }

How do I get the list of all schemas for the current user?

Code Block
    FormsService fs = ...;
    URL schemaFeedUrl = fs.getFeedURL(SchemaFeed.class);
    SchemaFeed schemaFeed = fs.getFeed(schemaFeedUrl, SchemaFeed.class);
    for(SchemaEntry schemaEntry: schemaFeed.getEntries()){
        System.out.println("Schema Name: " + schemaEntry.getTitle().getPlainText());
    }

How do I get the list of all schemas for a given application?

The code snippet below prints the name of all schemas in the appEntry application:

Code Block
    ApplicationEntry appEntry = ...;
    SchemaFeed themeFeed = appEntry.getSchemaFeed();
    for(SchemaEntry schemaEntry: schemaFeed.getEntries()){
        System.out.println("Schema Name: " + schemaEntry.getTitle().getPlainText());
    }

How do I get the url to a form so it can be embedded in my HTML pages?

First get a hold of the corresponding FormTypeEntry, then get the form url as shown in the snipped below:

...

This will embed the form in your page inside an <iframe/>.

How do I get the url to the form designer so it can be embedded in my HTML pages?

First get a hold of the corresponding FormTypeEntry, then get the form url as shown in the snipped below:

...

This will embed the form designer in your page inside an <iframe/>.

How do I get the url to the form submissions so it can be embedded in my HTML pages?

First get a hold of the corresponding FormTypeEntry, then get the form url as shown in the snipped below:

...

This will embed the submissions view in your page inside an <iframe/>.

How do I get a form entry based on a known id?

This is often needed when you need to relate an  form with another concept your application (e.g. you application has the concept of a report that has an associated  form). In this case you will store the form id somewhere and when needed fetch the form entry to embed it in your page, delete it, etc. Here is how you get the for a form entry (in fact any entry):

...

Code Block
    String formId = ...;
    FormsService fs = ...;
    URL formEntryUrl = fs.getEntryURL(FormTypeEntry.class, formId);
    FormTypeEntry ftEntry = fs.getEntry(formEntryUrl, FormTypeEntry.class);

How do I delete a form (or any other entry)?

By calling the delete method on the FormTypeEnty.

Code Block
    FormTypeEntry ftEntry = ...;
    ftEntry.delete();

How do I create a new form?

First you have to get a hold of the form feed from an existing application. See How do I get the list of all forms for a given application?

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...;
    FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
    FormTypeEntry newEntry = ftFeed.createEntry();
    newEntry.setTitle(new PlainTextConstruct("MyForm"));
    newEntry.setSummary(new PlainTextConstruct("MyForm Description"));
    newEntry = ftFeed.insert(newEntry);
Note

Inserting the original newEntry will not update it, but instead a new entry will be returned.

How do I create a new form using an existing one as a template?

The only difference between creating a new form and creating a new one based on an existing form is that instead of using the entry created by calling 'ftFeed.createEntry()' you will be using an existing form entry. Find an existing form entry, update its name and description and use that entry to insert into a feed. Do not override the entry id otherwise the insert will fail.

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...; // find app entry
    FormTypeEntry ftEntry = ...; // find template form entry 
    ftEntry.setTitle(new PlainTextConstruct("MyForm"));
    ftEntry.setSummary(new PlainTextConstruct("MyForm Description"));
    FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
    FormTypeEntry newEntry = ftFeed.insert(ftEntry);

How do I download an existing form?

It is also possible to download a form using the API similar to the way you can download one from the UI. Consider the following code snippet:

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...; // find app entry
    FormTypeEntry ftEntry = ...; // find template form entry 
    MediaContent mc = (MediaContent) ftEntry.getContent();
    MediaSource ms = getService().getMedia(mc);
    OutputStream formStream = new FileOutputStream("myform_form.zip");
    saveFormToDisk(ms.getInputStream(), formStream);

How do I upload a form into an existing application?

You can also upload a form that was previously downloaded using the following code snippet:

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...; // find app entry
    FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
    InputStream formZipStream = new FileInputStream("myform_form.zip");
    MediaStreamSource formMediaSource = new     MediaStreamSource(formZipStream,"application/zip");
    FormTypeEntry ftEntry = ftFeed.insert(formMediaSource);

How do I use Self-signed Certificates with the API?

One approach is to modify the client code to accept self-signed certificates, but the recommended method is to use the standard Java mechanisms to trust a self-signed certificate; for example, to add the self-signed certificates to the JRE trusted keystore.

  • Use a key tool to create a key
  • Used installcert.java to install the certificate in a trusted keystore
  • Save the keystore in the ''jre-home\lib\security'' directory
  • Restart the server

How do I set a form's Deployment State?

Code Block
FormTypeEntry ftEntry = setUpFormType(appEntry);
try {
System.out.println("Default State: " + ftEntry.getDeployState());
ftEntry.setDeployState(DeployState.PRODUCTION);
ftEntry = ftEntry.update();
ftEntry = ftEntry.getSelf();
assertEquals("Should be PRODUCTION state", ftEntry.getDeployState(), DeployState.PRODUCTION);

ftEntry.setDeployState(DeployState.DEVELOPMENT);
ftEntry = ftEntry.update();
ftEntry = ftEntry.getSelf();
assertEquals("Should be DEVELOPMENT state", ftEntry.getDeployState(), DeployState.DEVELOPMENT);

FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
FormTypeEntry newEntry = ftFeed.createEntry();
newEntry.setTitle(new PlainTextConstruct("MyForm123"));
newEntry.setSummary(new PlainTextConstruct("MyForm123 Description"));
newEntry.setVisibility(Visibility.PUBLICTENANT);
newEntry.setDeployState(DeployState.PRODUCTION);
newEntry = ftFeed.insert(newEntry);
assertNotNull(newEntry.getSelf());
assertEquals("Should be PRODUCTION state", newEntry.getDeployState(), DeployState.PRODUCTION);
newEntry.delete();