summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/base/postback.js
blob: 186495cc84c0129156f33a0aa29e462589f3d892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Prado.doPostBack = function(formID, eventTarget, eventParameter, performValidation, validationGroup, actionUrl, trackFocus, clientSubmit)
{
	if (typeof(performValidation) == 'undefined')
	{
		var performValidation = false;
		var validationGroup = '';
		var actionUrl = null;
		var trackFocus = false;
		var clientSubmit = true;
	}
	var theForm = document.getElementById ? document.getElementById(formID) : document.forms[formID];
	var canSubmit = true;
    if (performValidation)
	{
		//canSubmit = Prado.Validation.validate(validationGroup);
	/*	Prado.Validation.ActiveTarget = theForm;
		Prado.Validation.CurrentTargetGroup = null;
		Prado.Validation.IsGroupValidation = false;
		canSubmit = Prado.Validation.IsValid(theForm);
		Logger.debug(canSubmit);*/
		canSubmit = Prado.Validation.IsValid(theForm);
	}
	if (canSubmit)
	{
		if (actionUrl != null && (actionUrl.length > 0))
		{
			theForm.action = actionUrl;
		}
		if (trackFocus)
		{
			var lastFocus = theForm.elements['PRADO_LASTFOCUS'];
			if ((typeof(lastFocus) != 'undefined') && (lastFocus != null))
			{
				var active = document.activeElement;
				if (typeof(active) == 'undefined')
				{
					lastFocus.value = eventTarget;
				}
				else
				{
					if ((active != null) && (typeof(active.id) != 'undefined'))
					{
						if (active.id.length > 0)
						{
							lastFocus.value = active.id;
						}
						else if (typeof(active.name) != 'undefined')
						{
							lastFocus.value = active.name;
						}
					}
				}
			}
		}
		if (!clientSubmit)
		{
			canSubmit = false;
		}
	}
	if (canSubmit && (!theForm.onsubmit || theForm.onsubmit()))
	{
		theForm.PRADO_POSTBACK_TARGET.value = eventTarget;
		theForm.PRADO_POSTBACK_PARAMETER.value = eventParameter;
		theForm.submit();
	}
}