...
Then using the formUrl above you can generate the following script tag in your html page:
Code Block |
---|
<script type="text/javascript" src="{formUrl}"></script> |
...
Then using the designerUrl above you can generate the following script tag in your html page:
Code Block |
---|
<script type="text/javascript" src="{designerUrl}"></script> |
...
Then using the formSubmissionsUrl above you can generate the following script tag in your html page:
Code Block |
---|
<script type="text/javascript" src="{formSubmissionsUrl}"></script> |
...
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.<pre>
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:<pre>
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 an form into an existing application?
...
You can also upload a form that was previously downloaded using the following code snippet:<pre>
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(); |
...