if ( StructKeyExists(attributes,"appBeanName") AND LEN(TRIM(attributes.appBeanName)) AND StructKeyExists(attributes,"appParamsVarName") AND LEN(TRIM(attributes.appParamsVarName)) )
{
attributes = application.ADF.utils.appOverrideCSParams(
csParams=attributes,
appName=attributes.appBeanName,
appParamsVarName=attributes.appParamsVarName,
paramsExceptionList="appBeanName,appParamsVarName"
);
}
application.ADF.scripts.loadJQuery();
if ( StructKeyExists(attributes,"themeName") AND LEN(TRIM(attributes.themeName)) )
application.ADF.scripts.loadJQueryUI(themeName=attributes.themeName);
else
application.ADF.scripts.loadJQueryUI();
// Load jquery cookie to remember the last tab visited
application.ADF.scripts.loadJQueryCookie();
// Load ADFlightbox headers
application.ADF.scripts.loadADFLightbox();
// This is the default script Configuration Version
// - FYI: Changing this value will break any existing v1 datasheet configurati
scriptConfigVersion = "1.0";
// Check to see if the attribute 'configVersion' was passed in.
// - This will override the default scriptConfigVersion
// - Only use configVersion=2.0 on new datasheet setups! For a new setups "configVersion=2.0" can be passed via the custom script parameters dialog
if ( StructKeyExists(attributes,"configVersion") AND LEN(TRIM(attributes.configVersion)) )
scriptConfigVersion = attributes.configVersion;
// Check for CS Author Mode
csMode = "";
if ( StructKeyExists(request,"renderstate") AND StructKeyExists(request.renderstate,"rendermode") )
csMode = request.renderstate.rendermode;
// Bean Name for the Add Button
beanName = "Forms_2_0";
// Check to see if the attribute 'formBeanName' was passed in.
// This will override the bean to open for the form
if ( StructKeyExists(attributes,"formBeanName") AND LEN(TRIM(attributes.formBeanName)) )
beanName = attributes.formBeanName;
urlParams = "";
if ( StructKeyExists(attributes,"jsCallback") AND LEN(TRIM(attributes.jsCallback)) )
urlParams = urlParams & "&callback=" & attributes.jsCallback;
// Pass the URLParams to the ADF Datasheet Modules
if ( LEN(TRIM(urlParams)) )
request.adfDSmodule.urlParams = urlParams;
// Set the 'Add Button' display defaults
displayAddButtonDefault = true; // Display the 'Add Button'
secureAddButtons = true; // Only show 'Add Button' if user is logged in
// Set the flag for the locking a secured 'Add Button'
enableAddButton = true;
// Create the struct for the 'Add Button' status
displayAddBtnOptions = StructNew();
displayAddButtonList = "";
// Set the Add Button Defualt Text
addButtonTextDefault = "Add New {{elementName}}";
customAddButtonTextList = "";
tabLabelsList = "";
// Check to see if the attribute 'showAddButtons' was passed in with a list of display option values
// - attributes.showAddButtons=false takes presidence over enableAddButton=true
if ( StructKeyExists(attributes,"showAddButtons") AND LEN(TRIM(attributes.showAddButtons)) )
{
// Set the default if only one showAddButton option is passed in use it as the default for all
if ( ListLen(attributes.showAddButtons) EQ 1 AND IsBoolean(attributes.showAddButtons) )
displayAddButtonDefault = attributes.showAddButtons;
else
displayAddButtonList = attributes.showAddButtons;
}
// Build structure with CEName as the key and the 'Add Button' display option as the value
for ( a=1;a LTE ListLen(attributes.elementName);a=a+1 )
{
ce = TRIM(ListGetAt(attributes.elementName,a));
// Build a structure Key (without spaces) based on the CEName
// to be used to store the Add Button display options for each element passed in
elmt = REREPLACE(ce,"[\s]","","all");
abtn = displayAddButtonDefault;
// set the display value for each 'Add Button' for each element tab
if ( a LTE ListLen(displayAddButtonList) )
abtn = ListGetAt(displayAddButtonList,a);
// Set the elementName key of the struct with the status value
if ( IsBoolean(abtn) )
displayAddBtnOptions[elmt] = abtn;
else
displayAddBtnOptions[elmt] = displayAddButtonDefault;
}
// Check to see if the attribute 'useAddButtonSecurity' was passed in
if ( StructKeyExists(attributes,"useAddButtonSecurity") AND IsBoolean(attributes.useAddButtonSecurity) )
secureAddButtons = attributes.useAddButtonSecurity;
// Security Check for 'Add Button'
// - enableAddButton=false takes presidence over attributes.showAddButtons=true
if ( secureAddButtons AND (LEN(request.user.userid) EQ 0 OR request.user.userid EQ "anonymous") )
enableAddButton = false;
// Check to see if the attribute 'customAddButtonText' was passed in with a list of display values
if ( StructKeyExists(attributes,"customAddButtonText") )
customAddButtonTextList = attributes.customAddButtonText;
// Check to see if the attribute 'customTabLabels' was passed in with a list of display values
if ( StructKeyExists(attributes,"customTabLabels") AND LEN(TRIM(attributes.customTabLabels)) )
tabLabelsList = attributes.customTabLabels;
else
tabLabelsList = attributes.elementName;
// Check the list of elements to see if need the tabs.
// Set flag to render tabs or not
// Set the class name for the surrounding div based on if
// we are rendering tabs or not.
if ( ListLen(attributes.elementName) GT 1 )
{
renderTabFormat = true;
divClass = "tabs";
}
else
{
renderTabFormat = false;
divClass = "no-tabs";
}
// Load the inline CSS as a CSS Resource
application.ADF.scripts.addHeaderCSS(adfGenericElmtMgmtHeaderCSS, "SECONDARY"); // PRIMARY, SECONDARY, TERTIARY
// Load the inline JS as a JS Resource
application.ADF.scripts.addFooterJS(adfGenericElmtMgmtFooterJS, "SECONDARY"); // PRIMARY, SECONDARY, TERTIARY
ceName = TRIM(ListGetAt(attributes.elementName,i));
// Build an 'elementName' based on the CEName without spaces
custEl = REREPLACE(ceName,"[\s]","","all");
custElID = application.ADF.ceData.getFormIDByCEName(CEName=ceName);
if ( ListFirst(scriptConfigVersion,".") LTE 1 )
{
// Use custel for the datasheet "ct-render-named-element.cfm" call
controlSuffix = custEl;
// ^ Using the ceName in the datasheet control name does NOT allow account for the case
// when the Name of the Custom Element changes since changing that will break the existing datasheet configurations
// IMPORTANT -- this will be deprecated in ADF 2.0 ---
}
else
{
// Updated to allow for configuration of the v2 of this script
// Better solution ... will keep the datasheet config even if the element name changes
controlSuffix = custElID;
}
customControlName = "customManagementFor" & controlSuffix;
#application.ADF.UI.buildAddEditLink(linkTitle=addBtnText,
formName=ceName,
dataPageID=0,
refreshparent=true,
urlParams=urlParams,
formBean=beanName,
formMethod="renderAddEditForm",
lbTitle=addBtnText,
linkClass="ui-button ui-state-default ui-corner-all")#
Please LOGIN to add new records.
The custom element specified in the 'elementName=' parameter of this custom script does not exist.
Please add the parameter of 'elementName=My Element Name'. At least one Custom Element name is required for this administration custom script.