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)
DCT hangs when Saving using FormAPI
Jumjum
Greetings all,
I have am using the demo from Interwoven using formAPI to set my saving location (i.e the user selects some value and based on those values I use the form values to build the filename. ) I am using IE5.5sp2 on Win2k. In the iw.cfg under templating I have the following:
[teamsite_templating]
# use_java_ui=false
# data_root=templatedata
enable_formapi=true
and in my dct i have the following
<script language="javascript" location="template-type" src="shoescript.js"/>
and the shoescript is on the same level as my datacapture.cfg
Environment:
TS5.5.2 no Sp on Win2k
TST5.5.2 no Sp on Win2k
Has anyone else run into this problem?
Thanks,
Jum
Find more posts tagged with
Comments
Migrateduser
Be sure your function returns true.
Jumjum
Here is the copy of the shoescript that I am trying to invoke:
function init()
{
IWEventRegistry.addFormHandler("onSaveValid", onSave);
IWEventRegistry.addItemHandler("/Type", "onItemChange", onTypeSelected);
//Modified by item should be readonly.
var modifiedByItem = IWDatacapture.getItem("/Modified");
if ( modifiedByItem.getValue() == "")
{
modifiedByItem.setVisible(false);
}
modifiedByItem.setReadOnly(true);
//If this DCR is opened for reading, we need to restore the form
//to a consistent state.
if ( IWDCRInfo.getDCRName() != "" )
{
onTypeSelected( IWDatacapture.getItem("/Type") );
}
}
function onSave()
{
setModifiedBy();
return handleNameDCR();
}
function setModifiedBy()
{
var item = IWDatacapture.getItem("/Modified");
item.setValue(IWDatacapture.getUser());
item.setVisible(true);
IWDatacapture.redraw();
}
function handleNameDCR()
{
//Get the name and model number of this shoe and
//create a dcr name from it.
var shoeName = IWDatacapture.getItem("/Name").getValue();
var modelNumber = IWDatacapture.getItem("/Model Number").getValue();
var dcrName = shoeName + "-" + modelNumber + ".dcr";
IWDCRInfo.setDCRName(dcrName);
//Now return true so that the save continues with this name
return true;
}
//typeToSole provides a mapping of a type of shoe to the type of sole this
//shoe can have.
var typeToSole = new Object();
typeToSole["Tennis"] = "Rubber";
typeToSole["Running"] = "Air Sole";
typeToSole["Basketball"] = "Flubber";
//For "others", there is no restriction.
typeToSole["Others"] = null;
//typeToUppers provides a mapping of a type of shoe to the type of uppers this
//shoe can have.
var typeToUppers = new Object();
typeToUppers["Tennis"] = ["Nylon","Leather"];
typeToUppers["Running"] = ["Nylon","Leather"];
typeToUppers["Basketball"] = ["Faux Leather"];
typeToUppers["Others"] = ["Faux Leather","Nylon","Leather"];
/**
* onTypeSelected is a handler function listening to the type item.
* This function just calls setSoleAndUppersWithType. We break this
* operation into two functions for optimization reasons -- if the form
* is being opened up, a redraw is unnecessary. However, a redraw is
* necessary if the form is already brought up at this point.
*
*/
function onTypeSelected(item)
{
setSole( item );
setUppers( item );
}
function setSole(item)
{
var type = getTypeValue();
if (type == null )
{
return;
}
var sole = typeToSole[type];
setSoleValue(sole);
}
//Sets the value of the sole element given the string value
//to set. The form should be redrawn after calling this function.
function setSoleValue(sole)
{
var soleItem = IWDatacapture.getItem("/Sole");
if ( sole == null )
{
soleItem.setReadOnly(false);
return;
}
var soleOptions = soleItem.getOptions();
var valueIndex = findOptionIndexWithValue(soleOptions,sole);
if ( valueIndex >= 0 )
{
soleItem.setValue(valueIndex);
soleItem.setReadOnly(true);
}
}
function setUppers(item)
{
var type = getTypeValue();
if ( type == null )
{
return;
}
var uppers = typeToUppers[type];
setAvailableUppers( uppers );
}
function setAvailableUppers( uppers )
{
var upperItem = IWDatacapture.getItem("/Upper");
var upperOptions = upperItem.getOptions();
var upperSelectionIndex = upperItem.getValue();
var upperSelection = null;
if ( upperSelectionIndex != null )
{
upperSelection = upperOptions[upperSelectionIndex].value;
}
var optionList = new Array();
for ( var i = 0; i < uppers.length; i++ )
{
optionList
= new Option( uppers
, uppers
, false ,
uppers
== upperSelection );
}
if ( uppers.length == 1 )
{
optionList[0].selected = true;
upperItem.setReadOnly(true);
}
else
{
upperItem.setReadOnly(false);
}
upperItem.setOptions( optionList );
IWDatacapture.redraw();
}
/****
* Helper functions
****/
//This helper function takes a list of option objects and a string value and
//returns the index in the array of the option that has the given value.
function findOptionIndexWithValue(optionList, value)
{
for (var i = 0; i < optionList.length; i++ )
{
var option = optionList
;
if ( option.value == value )
{
return i;
}
}
return -1;
}
//This helper function returns the string value of the selected
//shoe type. This function is helpful because getValue() returns
//the index of the selected radio button, not the actual value itself.
//Maybe this can be a future API enhancement?
function getTypeValue()
{
var typeItem = IWDatacapture.getItem("/Type");
var typeIndex = typeItem.getValue();
var typeOptions = typeItem.getOptions();
return typeOptions[typeIndex].value;
}
init();
Migrateduser
enable_formapi=true
There is no character can exist left of this line.