Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
TS 6.1 FormAPI
awgolk
I am trying to use the getChildren to get the nodes of a replicant. But everytime I try to access the replicant, I am getting a null object returned. I can't see what I am doing wrong, below is the DCR along with the code.
Any help would be appreciated.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE datacapture SYSTEM "datacapture5.0.dtd">
<data-capture-requirements name="test" type="metadata">
<ruleset name="navigation">
<description>
Template for Contibution of Breadcrumb and Main Window Content associated with products
</description>
<item name="REPLICANTPROCEDURE">
<replicant min="1" max="50" combination="and" hide-name="t">
<item name="PROCEDURECODE">
<label>Procedure Codes:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="t" wrap="physical"/>
</item>
<item name="COLUMNDATA">
<label>Column Data:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="f" wrap="physical"/>
</item>
</replicant>
</item>
<item name="COLUMNHEADING">
<label>Column Heading:</label>
<description>The name of the content item.</description>
<text maxlength="50" size="50" required="f" />
</item>
<script>
<![CDATA[
IWEventRegistry.addFormHandler("onFormInit", init());
function init() {
IWEventRegistry.addItemHandler("/REPLICANTPROCEDURE/COLUMNDATA","onItemChange",columnHeading);
}
function columnHeading() {
var replicant = new Array();
var replicant = IWDatacapture.getItem("/REPLICANTPROCEDURE/");
replicantContent = replicant.getChildren();
}//end columnHeading
]]>
</script>
<!-- End of Main Window Content Fields -->
</ruleset>
</data-capture-requirements>
Find more posts tagged with
Comments
Migrateduser
The first thing that jumped out at me was your use of the <replicant> entity, which I believe was deprecated after v5.5.2. Should this be "container"? Also, I believe the hide-name syntax is also different now. I may be wrong, but I think your syntax is older than the version of TeamSite you're using. At least, I haven't used that syntax in at least a couple of years.
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
Adam Stoller
Is this FormsPublisher DCT or Metadata Capture DCT?
To the best of my knowledge FormAPI is [currently] only supported in the former and not the latter - so I'm kind of surprised it would run at all if, as your DCT code seems to suggest, you are using it in a metadata capture DCT.
If you are talking about a FormsPublisher DCT - then I believe elements of type 'replicant' should be changed to 'container' (which now supports min/max parameters)- look at datacapture6.0.dtd rather than datacapture5.0.dtd
If you're talking about Metadata Capture DCT - then it's still 'replicant' - but you want to look at the metadatacapture6.0.dtd not datacapture5.0.dtd.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
awgolk
This was is the FormsPublisher DCT. I have updated the code to utilize the container object, but the call is still returining null. Is it required to have a root-container?
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE datacapture SYSTEM "datacapture5.0.dtd">
<data-capture-requirements name="test" type="metadata">
<ruleset name="navigation">
<description>
Template for Contibution of Breadcrumb and Main Window Content associated with products
</description>
<container min="1" max="50" name="REPLICANTPROCEDURE">
<item name="PROCEDURECODE">
<label>Procedure Codes:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="t" wrap="physical"/>
</item>
<item name="COLUMNDATA">
<label>Column Data:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="f" wrap="physical"/>
</item>
</container>
<item name="COLUMNHEADING">
<label>Column Heading:</label>
<description>The name of the content item.</description>
<text maxlength="50" size="50" required="f" />
</item>
<script>
<![CDATA[
IWEventRegistry.addFormHandler("onFormInit", init());
function init() {
IWEventRegistry.addItemHandler("/REPLICANTPROCEDURE/COLUMNDATA","onItemChange",columnHeading);
}
function columnHeading() {
var replicant = new Array();
var replicant = IWDatacapture.getItem("/REPLICANTPROCEDURE/");
replicantContent = replicant.getChildren();
}//end columnHeading
]]>
</script>
<!-- End of Main Window Content Fields -->
</ruleset>
</data-capture-requirements>
Migrateduser
Yes, it is required. Check out p. 31 of the TS 6.0 Dev guide. There's an outline of each element and what it's there for. Examples are also provided.
Current Environment(s):
(1) TS 6.1 SP2 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 6.1 SP2 on Win2K
Adam Stoller
If it's a FormsPublisher DCT - shouldn't you change:
<data-capture-requirements name="test" type="
metadata
">
to:
<data-capture-requirements name="test" type="
content
">
?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
awgolk
Yes, thanks for pointing that out. Still have the issue when I alert out (alert(IWDatacapture.getItem("/REPLICANTPROCEDURE/COLUMNDATA"))
I am getting a return of null, even though the replicant has one item with values in both fields.
Adam Stoller
Try changing:
var replicant =
IWDatacapture.getItem("/REPLICANTPROCEDURE
/
");
replicantContent = replicant.getChildren();
To:
var replicant = IWDatacapture.getItem("/REPLICANTPROCEDURE");
replicantContent = replicant.getChildren();
If that still doesn't work - I suggest you re-post your current code.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
kellyrmilligan
I work on the same box as the other developer, and thought I would try this out as well. I changed the dtd reference to be 6.0 dtd. This is the current code, and I get null as well. what would be an alert or something that I can test getting the value from ?
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE datacapture SYSTEM "datacapture6.0.dtd">
<data-capture-requirements name="test" type="content">
<ruleset name="navigation">
<description>
Template for Contibution of Breadcrumb and Main Window Content associated with products
</description>
<container min="1" max="50" name="REPLICANTPROCEDURE" combination="and">
<item name="PROCEDURECODE" pathid="PROCEDURECODE">
<label>Procedure Codes:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="t" wrap="physical"/>
</item>
<item name="COLUMNDATA" pathid="COLUMNDATA">
<label>Column Data:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="f" wrap="physical"/>
</item>
</container>
<item name="COLUMNHEADING">
<label>Column Heading:</label>
<description>The name of the content item.</description>
<text maxlength="50" size="50" required="f" />
</item>
<script>
<![CDATA[
IWEventRegistry.addFormHandler("onFormInit", init());
function init() {
IWEventRegistry.addItemHandler("/REPLICANTPROCEDURE/COLUMNDATA","onItemChange",columnHeading);
}
function columnHeading() {
var replicant = IWDatacapture.getItem("/REPLICANTPROCEDURE");
replicantContent = replicant.getChildren();
alert(replicant);
}
]]>
</script>
<!-- End of Main Window Content Fields -->
</ruleset>
</data-capture-requirements>
Migrateduser
Hi,
replicant.getChildren(); returns an array.
Try this:
var replicantArray = replicant.getChildren();
var numberOfItems = replicantArray.length;
for (i = 0; i < numberOfItems; i++) {
alert(replicantArray
.getName());
alert(replicantArray
.getType())
alert(replicantArray
.getValue());;
}
For some reason, squarebrackets are removed on the site - they are placed after arrray with an "i" between.
Staffe
Edited by staffe on 01/25/05 02:11 AM (server time).
Adam Stoller
If you don't want
to be interpreted as meaning the beginning of an italics section in your post - change the "
Make post
" setting to either "
Using HTML
" or "
Without Markup/HTML
" when composing your post *or* put spaces around the letter like so:
[ i ]
and that will prevent the interpretation. Personally, I tend to make most of my posts "
Using HTML
" - in which case you need to make sure that any less-than signs you want to keep are followed by a dummy-tag - which is similar to the problem above - but instead you would put
<<x>sometag>
.
It's awkward, but I've gotten used to it.
I
believe
the following is an accurate representation of the previous code sample:
var replicantArray = replicant.getChildren();
var numberOfItems = replicantArray.length;
for (i = 0; i < numberOfItems; i++) {
alert(replicantArray
.getName());
alert(replicantArray
.getType())
alert(replicantArray
.getValue());;
}
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
kellyrmilligan
Thanks for the suggestion, here is the code I have now:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE datacapture SYSTEM "datacapture6.0.dtd">
<data-capture-requirements name="test" type="content">
<ruleset name="navigation">
<description>
Template for Contibution of Breadcrumb and Main Window Content associated with products
</description>
<container min="1" max="50" name="REPLICANTPROCEDURE" combination="and">
<item name="PROCEDURECODE" pathid="PROCEDURECODE">
<label>Procedure Codes:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="t" wrap="physical"/>
</item>
<item name="COLUMNDATA" pathid="COLUMNDATA">
<label>Column Data:</label>
<description>The name of the content item.</description>
<textarea rows="15" cols="50" rtf="t" external-editor="visualformat" required="f" wrap="physical"/>
</item>
</container>
<item name="COLUMNHEADING">
<label>Column Heading:</label>
<description>The name of the content item.</description>
<text maxlength="50" size="50" required="f" />
</item>
<script>
<![CDATA[
IWEventRegistry.addFormHandler("onFormInit", init());
function init() {
IWEventRegistry.addItemHandler("/REPLICANTPROCEDURE/COLUMNDATA","onItemChange",columnHeading);
}
function columnHeading() {
var replicant = IWDatacapture.getItem("/REPLICANTPROCEDURE");
var replicantArray = replicant.getChildren();
var numberOfItems = replicantArray.length;
for (i = 0; i < numberOfItems; i++) {
alert(replicantArray
.getName());
alert(replicantArray
.getType())
alert(replicantArray
.getValue());;
}
}
]]>
</script>
<!-- End of Main Window Content Fields -->
</ruleset>
</data-capture-requirements>
I believe that this should work, and prior to our 6.1 install, we were doing this sort of thing already, this seems more like a bug of some sort.
I am getting error message : null is null or not an object. it is basically failing to get the item object.
koteshb
Look at the code below datacapture.cfg, home_dct.js. In the home_dct.js I'm getting the child nodes.
DATACAPTURE.CFG
------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datacapture SYSTEM "datacapture6.0.dtd">
<data-capture-requirements type="content" name="Home Page">
<!-- data-capture-requirements elements contain area elements -->
<ruleset name="Home Page">
<description>Enter Home Page FCA Information.</description>
<root-container name="topcontainer" location="topcontainer">
<!-- file elements contain item elements -->
<container name="FCA Content" location="top_container" min="0" max="6">
<item name="FCA Type">
<label>FCA Type</label>
<description>Select FCA Type - Graphic or Flash</description>
<radio required="t">
<option value="Graphic" label="Graphic" />
<option value="Flash" label="Flash" />
</radio>
</item>
<!-- If Graphic Items -->
<item name="GFile Location">
<label>File Location</label>
<description>Enter Location of File</description>
<browser size="80" required="f" />
</item>
<item name="Alt tag">
<label>Alt tag</label>
<description>Enter Alt tag Text</description>
<text required="f" size="80" maxlength="300" />
</item>
<item name="Image Map">
<label>Image Map</label>
<description>Enter HTML for Image Map</description>
<textarea required = "f" rows="10" cols="70" scrollbars="t" />
</item>
<item name="Link URL">
<label>Link URL</label>
<description>Enter Destination URL</description>
<browser size="80" required="f" />
</item>
<item name="Window Type">
<label>Window Type</label>
<description>Select Window Type</description>
<select required="f">
<option value="Current Window" label="Current Window" />
<option value="New Window" label="New Window" />
</select>
</item>
<!-- If Graphic Items Ends -->
<!-- If Flash Items -->
<item name="FFile Location">
<label>File Location</label>
<description>Enter Location of File</description>
<browser size="80" required="f" />
</item>
<item name="Width">
<label>Width</label>
<description>Enter Width</description>
<text required ="f" size="20" maxlength="50" />
</item>
<item name="Height">
<label>Height</label>
<description>Enter Height</description>
<text required ="f" size="20" maxlength="50" />
</item>
<item name="BG Color">
<label>BG Color</label>
<description>Enter BG Color</description>
<text required="f" size="20" maxlength="50" />
</item>
<!-- If Flash Items Ends-->
</container>
<container name="Metadata" location="Metadata">
<!-- Metadata -->
<item name="Keywords">
<label>Keywords</label>
<description>Enter Keywords for Search Engines</description>
<textarea required = "t" rows="10" cols="70" scrollbars="t" />
</item>
<item name="Description">
<label>Description</label>
<description>Enter Description</description>
<textarea required = "t" rows="10" cols="70" scrollbars="t" />
</item>
<!-- Metadata Ends-->
</container>
</root-container>
<script language="javascript" location="template-type" src="home_dct.js"/>
</ruleset>
</data-capture-requirements>
HOME_DCT.JS
-----------------
-------------------
function init()
{
hideAllFCAItemsInitially();
IWEventRegistry.addItemHandler("/topcontainer/FCA Content/FCA Type", "onItemChange", showSelectedItems);
parent.IWDCEventRegistry.addListener( 'onItemAdded', handleItemAdded );
// alert(IWDatacapture.getItem("/topcontainer/FCA Content[1]/FCA Type").getOptions()[IWDatacapture.getItem("/topcontainer/FCA Content[1]/FCA Type").getValue()].value);
}
function hideNewDCRFCAItems(i)
{
//alert("function hideNewDCRItems");
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/GFile Location").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Alt tag").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Image Map").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Link URL").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Window Type").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FFile Location").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Width").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Height").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/BG Color").setVisible(false);
}
function hideReplicantFCAItems(i)
{
//alert("function hideReplicantFCAItems");
var selectedItem = IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FCA Type").getOptions()[IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FCA Type").getValue()].value;
//alert(selectedItem);
if(selectedItem == "None")
{
hideNewDCRFCAItems(i);
}
if(selectedItem == "Graphic")
{
//alert("Graphic");
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/GFile Location").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Alt tag").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Image Map").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Link URL").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Window Type").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FFile Location").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Width").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Height").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/BG Color").setVisible(false);
//set Graphic fields to Required
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/GFile Location").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Alt tag").setRequired(true);
//IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Image Map").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Link URL").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Window Type").setRequired(true);
//set Flash fields to Not Required
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FFile Location").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Width").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Height").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/BG Color").setRequired(false);
}
if(selectedItem == "Flash")
{
//alert("Flash");
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/GFile Location").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Alt tag").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Image Map").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Link URL").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Window Type").setVisible(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FFile Location").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Width").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Height").setVisible(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/BG Color").setVisible(true);
//set Flash fields to Required
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/FFile Location").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Width").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Height").setRequired(true);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/BG Color").setRequired(true);
//set Graphic fields to Not Required
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/GFile Location").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Alt tag").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Image Map").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Link URL").setRequired(false);
IWDatacapture.getItem("/topcontainer/FCA Content[" + i + "]/Window Type").setRequired(false);
}
}
function hideAllFCAItemsInitially()
{
//alert("hideAllFCAItemsInitially");
var children = IWDatacapture.getItem("/topcontainer/FCA Content").getChildren();
//alert (children);
var max = children.length;
//alert(max);
for (var i=1; i<=max; i++)
{
var dcrName = IWDCRInfo.getDCRName();
if (dcrName == "")
{
//alert("New DCR");
hideNewDCRFCAItems(i);
}
else
{
//alert("Old DCR");
hideReplicantFCAItems(i);
}
}
IWDatacapture.redraw();
}
function hideAllFCAItemsForReplicants(xpath)
{
//alert("in hideAllFCAItemsForReplicants");
IWDatacapture.getItem(xpath + "/GFile Location").setVisible(false);
IWDatacapture.getItem(xpath + "/Alt tag").setVisible(false);
IWDatacapture.getItem(xpath + "/Image Map").setVisible(false);
IWDatacapture.getItem(xpath + "/Link URL").setVisible(false);
IWDatacapture.getItem(xpath + "/Window Type").setVisible(false);
IWDatacapture.getItem(xpath + "/FFile Location").setVisible(false);
IWDatacapture.getItem(xpath + "/Width").setVisible(false);
IWDatacapture.getItem(xpath + "/Height").setVisible(false);
IWDatacapture.getItem(xpath + "/BG Color").setVisible(false);
IWDatacapture.redraw();
}
function showSelectedItems()
{
var children = IWDatacapture.getItem("/topcontainer/FCA Content").getChildren();
//alert (children);
var max = children.length;
//alert(max);
//var max = ( children == null) ? 0 : children.length();
for (var i=1; i<=max; i++)
{
hideReplicantFCAItems(i);
}
IWDatacapture.redraw();
}
function replicantFCAItems(xpath)
{
//alert("replicantFCAItems");
//alert(xpath);
//alert(IWDatacapture.getItem(xpath + "/FCA Type").getOptions()[IWDatacapture.getItem(xpath + "/FCA Type").getValue()].value);
}
function setVisibility(xpath)
{
//alert("setVisibilty");
hideAllFCAItemsForReplicants(xpath);
IWEventRegistry.addItemHandler(xpath + "/FCA Type", "onItemChange", replicantFCAItems(xpath));
//IWEventRegistry.addFormHandler("onFormInit", init);
}
function handleItemAdded(item)
{
//alert("handleItemAdded");
var xpath = getXPath( item );
if ( xpath.match( '^/topcontainer/FCA Content\\[\\d+\\]$'))
{
//alert("in if handleItemAdded");
setVisibility(xpath);
}
}
function getXPath( item )
{
//alert("in getXPath");
var xpath = null;
if ( typeof( item.getXPath ) != 'undefined' )
{
//alert("in if xpath");
xpath = item.getXPath();
}
else
{
//alert("in else");
xpath = item.getName();
}
//alert(xpath);
return( xpath );
}
init();
This code should help you to find the child replicants.
Thanks
Kotesh.
kaush1k
I think installing the latest service pack will solve this problem.
Go to the page -
https://support.interwoven.com/library/manuals/teamsite/html/610/TS.610sp2.rn/index.html
You will find the following -
--------------------------------------------------------------------
TeamSite 6.1.0 Service Pack 1
The following issues were fixed in TeamSite 6.1.0 Service Pack 1. The Interwoven bug database number is included for each listing:
....
....
52641 FormAPI getItem() doesn't resolve Replicant Instance Containers.
-------------------------------------------------------------------
-
Kaushik
kellyrmilligan
Thanks, we thought we were going crazy, it wasn't so much a coding issue, although everyone else thought it was.