Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
FormAPI not working
buddyholly
Hi, I tried putting in the example from the FormAPI documentation (which really sucks)
<script>
<![CDATA[
alert ("Hello, world!");
]]>
</script>
I put this in my DCT, when I go to make a new DCR I get an error? How do I get it to recognize the script? Also how do I get something to call to an external .js file? Thanks
Find more posts tagged with
Comments
MattP
Where in your DCT did you put it?
Do you have formAPI enabled in your IW.cfg file?
What is the error you received?
<script src="/hello.js"/>
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
StreamserveEventsProcess.png
StreamserveEventsProcess2.png
Jens
Have you enabled FormAPI in iw.cfg ?
[teamsite_templating]
enable_formapi=true
You can call external JS-Script using something like this:
<script location="template-type" src="test.js"/>
buddyholly
I put it in right before the </ruleset> tag. Yes it is enabled in IW.cfg. The error I get is:
Templating Error Page
An internal problem was encountered trying to create a requirements object for type hrdc-drhc/fr_generique.
MattP
attach the DCT.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
buddyholly
Okay here it is. Also maybe you can help in this problem too. As you probably know the <browser /> field does not support validation regex, you'll see our commented regex which works, but only in a regular text field, but we need the browser field to do a regex on the filename to make sure it doesn't have the _f in the file name. Anyway my DCT is attached. Thanks
MattP
I tried your template (copy and paste) and it works fine. I get an alert that says hello world. If you just enabled formAPI in IW.cfg you need to do an iwreset. The template and code are fine.
Once that is working, look at writing a little form api piece that validates the content of the browser element. One step at a time though.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
buddyholly
It still doesn't work, I still get the same error msg.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE datacapture SYSTEM "datacapture5.0.dtd">
<data-capture-requirements type="content">
<ruleset name="fr_generique">
<description>Modèle français de saisie des données</description>
<item name="Titre">
<description>Le titre du présent document (Nota : :Le titre sera affiché dans la barre bleu du navigateur et dans les résultats de la recherche et de la passerelle)</description>
<textarea required="t" cols="68" rows="4" external-editor="visualformat" external-editor-config="/iw/config/title_titre.xml" />
</item>
<item name="Langue">
<description>Langue de ce document</description>
<radio required="t">
<!--option selected="t" label="anglais" value="eng" /-->
<option selected="t" label="français" value="fre" />
</radio>
</item>
<item name="Autre nom de fichier de langue">
<item ref="file" />
<description>Chemin d'accès du fichier désigné</description>
<browser required="t" initial-dir="/templatedata/hrdc-drhc/en_generic/data/docs/en/" ceiling-dir="/templatedata/hrdc-drhc/en_generic/data/docs/en/" size="58" />
</item>
<!--item name="Autre nom de fichier de langue"-->
<!--description>Chemin d'accès du fichier désigné</description-->
<!--text required="t" size="68" validation-regex="^/en/.+/.+/.+\.shtml$"><default>/en/<nom_de_programme>/<sous-répertoire>/nom_de_fichier.shtml</default></text-->
<!--/item-->
<item name="Contenu">
<description>Extraire SEULEMENT les sections de votre contenu en provenance de codage de modèle existant (sans la navigation, les métadonnées, les en-têtes, les bas de page, etc.) des pages courantes et copier dans la zone du contenu.</description>
<textarea required="t" cols="68" rows="33" external-editor="visualformat"/>
</item>
<description>Test</description>
<script location="template-type" src="test.js"/>
<itemref name="test"/>
</ruleset>
Where test.js is my script file which only contains
alert("Hello");
</data-capture-requirements>
buddyholly
Got it working I had a line <item ref= in there that was **** it up, thanks for everyone's help.
MattP
the way you had it before, in-line worked. Did that work in your environment after you did an iwreset?
From the docs
Alternatively, you could save the script in a file called `hello.js' and specify its location using the src attribute. The actual location the src attribute points to may be anywhere on a webserver, in the same directory as the data capture template type definition, or somewhere else on the same TeamSite server. The value of the location attribute controls how the src attribute is interpreted:
`webserver'
The src attribute is simply the URL of the target, for example
http://myserver/mypath/hello.js
. This is the default if the location attribute isn't specified.
`template-type'
In this case, src specifies a location relative to the template type directory. So if `hello.js' lived alongside the DCT in:
`/iwmnt/default/main/WORKAREA/user/templatedata/category/type/hello.js'
then simply specifying `src="hello.js"' would be sufficient.
Note that you can use the webserver location type to access content that is on the same TeamSite server but in a different location than the template type directory by using the `/iw-mount' URL prefix:
<script src="/iw-mount/default/main/SomeBranch/EDITION/SomeEdition/SomeDirectory/hello.js"/>
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
buddyholly
When I did it inline it didn't work for some reason? I just tried it external right now and my hello popped up. I did iwresets several times for the inline so I knew that wasn't the problem. Everytime you change the DTD does that require an iwreset? Or does it refresh when I open a new DCR?
Adam Stoller
The iwreset is only to ensure that TeamSite has enabled the functionality for FormAPI - it should only be needed once.
--fish
(Interwoven Senior Technical Consultant)