in trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js [1718:2019]
function submitForm(
form,
doValidate,
parameters,
isPartial,
event
)
{
// If we've delayed any sort of event submission, we won't want to do it at
// all now that the form is getting submitted. Blow away the saved data. Any
// timeout handler will cancel the event submission if the data no longer
// exists.
var pending = true;
if (_agent.isIEGroup)
{
pending = false;
// keep track of whether there was a pending event
for (var key in _delayedEventParams)
{
pending = true;
break;
}
}
if (pending)
{
_delayedEventParams = new Object();
_delayedEventParams["reset"] = true;
}
// if the form was passed as a form name, get the form object
if ((typeof form) == "string")
{
form = document[form];
}
// if the form was passed as a form index, get the form object
else if ((typeof form) == "number")
{
form = document.forms[form];
}
// we had better have a form now
if (!form)
return false;
// Check to see if submitForm is called before the form
// has been rendered completely. If so, save the parameters
// and return. At the end of the form, we always call _submitFormCheck
// which will re-call submitForm if it had been rejected.
// This is for bug 2752257.
// Bug #3058770: In LovInput, we have to hack up a form for NLS. It's not
// validated, so there is no real validator, we've just hacked one. The
// submit always sets doValidate to false. Just make sure that you never use
// this validator if doValidate is false (it might just be the value '1').
var formComplete = window["_"+ _getJavascriptId(_getFormName(form)) + "Validator"];
if (formComplete == (void 0))
{
_saveFormForLaterSubmit(form, doValidate, parameters);
// Do not submit the form,
// since the form hasn't been rendered completely yet.
return false;
}
// Bug 1789483: ignore a second form submission that happens
// less than 0.5 seconds after the first one
var newDate = new Date();
if (_recentSubmit(newDate))
{
// However if we're allowing the first click through... we queue up this
// submit.
if (_pprFirstClickPass && _pprBlocking)
{
_saveFormForLaterSubmit(form, doValidate, parameters);
}
return;
}
// just in case, clear it the delayed submit flags
_submitRejected = false;
_inPartialSubmit = false;
_lastDateSubmitted = newDate;
// default value for doValidate is true
if (doValidate == (void 0))
doValidate = true;
// assume that we should submit the form
var doSubmit = true;
// validate the form if necessary, and don't submit the
// form if validation fails
var paramSource;
if (parameters != null)
paramSource = parameters.source;
else
paramSource = "";
if (doValidate && !_validateForm(form, paramSource))
doSubmit = false;
//
// If we have an onSubmit handler, call it
//
var onSubmit = window["_" + _getJavascriptId(_getFormName(form)) + "_Submit"];
if (typeof onSubmit != "undefined" && doSubmit)
{
// create function so that "return" is handled correctly,
var func = new Function("doValidate", onSubmit);
var handlerResult;
// WindowsMobile 5 doesn't support installing Funtion object
// to "this", so just invoke the Function object instead.
if (_agent.isPIE)
{
handlerResult = func(event);
}
else
{
// install the function on the object so that "this" is
// handled correctly
form._tempFunc = func;
// call the submit handler with the doValidate flag,
handlerResult = form._tempFunc(doValidate);
// uninstall the temporary function
form._tempFunc = (void 0);
}
// if we're validating and the handler returns false,
// don't submit the form
if (doValidate && (handlerResult == false))
{
doSubmit = false;
}
}
if (doSubmit)
{
// reset any hidden form values before submitting
TrPage.getInstance()._resetHiddenValues(form);
// While WM6 can support PPR, WM5 and PPC lacks enough support
// for DOM and/or HMLHTTP. Disable partial form post for PPC and
// WM5.
if (isPartial && _supportsPPR())
{
// In the case of Windows-mobile(WM) browsers, during rendering,
// Trinidad stores the value of the request-header field, UA-pixels,
// into a hidden-parameter's value attribute. WM browsers' PPRs don't
// contain UA-pixels in their request-headers. So during a WM browser's
// PPR, we need to manually set the field, UA-pixels, into the
// request-header with the hidden parameter's value.
if (_agent.isPIE || _agent.isWindowsMobile6)
{
var header = new Array(1);
header['UA-pixels'] = form.elements['uapixels'].value;
TrPage.getInstance().sendPartialFormPost(form, parameters, header);
}
else
{
TrPage.getInstance().sendPartialFormPost(form, parameters, null, event);
}
}
else
{
//
// assign any dynamic values before submitting
//
var isDOM = _supportsDOM();
var tempParams = new Object();
if (parameters)
{
for (var paramName in parameters)
{
var paramValue = parameters[paramName];
if (paramValue != (void 0))
{
// do not try to get properties from the form element directly.
// Some code somewhere was setting an htmlInputElement as
// a property on the formElement, but not as a child.
// This was causing bug 4536656.
// I can't yet figure out who is setting the htmlInputElement as
// a property (instead of a child).
// As a workaround get them from the elements array instead.
// In any case it is always safe to get the element from the
// elements array.
//var hiddenField = form[paramName];
var hiddenField = form.elements[paramName];
if (_agent.isPIE)
{
hiddenField.value = paramValue;
}
else
{
var hiddenFieldCreated = false;
// See if the hidden field exists. And, because
// of some rather strange IE behavior w/regards to
// form.elements['id'], make sure we haven't accidentally
// grabbed a string
if (hiddenField && (typeof(hiddenField) != "string"))
{
// This condition was added to support enter key
// on forms for hcommandButton
if (hiddenField.type == 'submit' || hiddenField.type == 'button')
{
var tmpField = document.createElement("input");
tmpField.type = "hidden";
tmpField.name = paramName;
tmpField.value = parameters[paramName];
form.appendChild(tmpField);
tempParams[paramName] = tmpField;
hiddenFieldCreated = true;
}
else
{
hiddenField.value = paramValue;
}
}
//VAC- added so that PDA's do not enter this flow. Since no PDA currently
//supports createElement function on the document. Furthermore, if the
//hidden field exists there should be no reason to create a new hidden field
//with the same name and attach it to the form.
else
{
if (isDOM)
{
if (! hiddenFieldCreated)
{
// as a convenience to the client, build a hidden field to hold
// this parameter.
var tmpField = document.createElement("input");
tmpField.type = "hidden";
tmpField.name = paramName;
tmpField.value = parameters[paramName];
form.appendChild(tmpField);
tempParams[paramName] = tmpField;
}
}
}
}
}
}
}
// IE BUG, see TRINIDAD-704
if(_agent.isIE)
_autoCompleteForm(form);
try
{
form.submit();
}
catch (e)
{
if (TrPage.getInstance().getRequestQueue()._isMultipartForm(form))
{
// IE will fail on an input file submission of a file that does not exist
var facesMessage = _createFacesMessage(
'org.apache.myfaces.trinidad.component.core.input.CoreInputFile.INPUT_FILE_ERROR');
// if there's nowhere to display the message in either
// summary or detail, then pop an alert to warn the page developer
if (!TrMessageBox.isPresent())
alert(facesMessage.getDetail());
else
// Add the message to the MessageBox
TrMessageBox.addMessage(null, null, facesMessage);
}
else
{
throw e;
}
}
if (_blockOnEverySubmit)
_pprStartBlocking(window);
// Remove any dynamically added form parameters. We do this for two
// reasons:
// 1. IE6 does not return dynamically-added form elements in the form map,
// so we end up re-adding the same form elements again.
// 2. If we don't remove them, then subsequent form submits behave like
// they are PPR requests (because the dynamically added "partial" and
// "partialTargets" parameters will be on the request).
// (Bug #3623890. This seems to break on a few Apps pages with bad form
// setups)
if (isDOM)
{
for (var paramName in tempParams)
form.removeChild(tempParams[paramName]);
}
}
}
return doSubmit;
}