Author: nbelaevski
Date: 2008-04-15 17:34:44 -0400 (Tue, 15 Apr 2008)
New Revision: 7852
Modified:
branches/3.1.x/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js
branches/3.1.x/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
branches/3.1.x/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js
branches/3.1.x/ui/togglePanel/src/main/templates/toggleControl.jspx
Log:
http://jira.jboss.com/jira/browse/RF-3081
http://jira.jboss.com/jira/browse/RF-3068
Modified:
branches/3.1.x/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js
===================================================================
---
branches/3.1.x/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js 2008-04-15
18:38:52 UTC (rev 7851)
+++
branches/3.1.x/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js 2008-04-15
21:34:44 UTC (rev 7852)
@@ -3,8 +3,8 @@
if(!A4J.findForm){
-function _JSFFormSubmit(linkId,formName,target,parameters){
- var form = document.getElementById(formName);
+function _JSFFormSubmit(linkId, formName, target, parameters){
+ var form = (typeof formName == 'string' ? document.getElementById(formName) :
formName);
if(form){
var paramNames = [];
@@ -26,7 +26,21 @@
}
}
}
- form.submit();
+
+ var onsubmitResult;
+ if (form.fireEvent) {
+ onsubmitResult = form.fireEvent("onsubmit");
+ } else {
+ var event = document.createEvent("HTMLEvents");
+ event.initEvent("submit", true, true)
+
+ onsubmitResult = form.dispatchEvent(event);
+ }
+
+ if (onsubmitResult) {
+ form.submit();
+ }
+
_clearJSFFormParameters(formName,target,paramNames);
} else {
@@ -36,7 +50,7 @@
};
function _clearJSFFormParameters(formName,target,fields){
- var form = document.getElementById(formName);
+ var form = (typeof formName == 'string' ? document.getElementById(formName) :
formName);
if(form){
if(target){
form.target = target;
@@ -77,7 +91,7 @@
// setup form to handle 'onclick' events, to detect input element.
A4J.setupForm = function(id){
- var element = window.document.getElementById(id);
+ var element = (typeof id == 'string' ? window.document.getElementById(id) :
id);
var name = "click";
if (element.addEventListener) {
element.addEventListener(name, A4J._observer, false);
Modified:
branches/3.1.x/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
===================================================================
---
branches/3.1.x/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2008-04-15
18:38:52 UTC (rev 7851)
+++
branches/3.1.x/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2008-04-15
21:34:44 UTC (rev 7852)
@@ -69,24 +69,17 @@
var parentForm = A4J.findForm($(clientId + "_header"));
if(!parentForm || !parentForm.appendChild /* findForm returns surrogate form object */)
return;
- var fInput = parentForm[clientId];
- if(!fInput) {
- fInput = document.createElement("input");
- fInput.type = "hidden";
- fInput.name = clientId;
- parentForm.appendChild(fInput);
+ var thePanel = this.panels.get(clientId);
+ if (thePanel.status==0){
+ thePanel.status=1;
+ } else {
+ thePanel.status=0;
}
-
- var thePanel = this.panels.get(clientId);
- if (thePanel.status==0){
- thePanel.status=1;
- }
- else{
- thePanel.status=0;
- }
- fInput.value = thePanel.status;
- parentForm.submit();
+ var params = {};
+ params[clientId] = thePanel.status;
+ _JSFFormSubmit(null, parentForm, null, params);
+
return false;
}
Modified:
branches/3.1.x/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js
===================================================================
---
branches/3.1.x/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js 2008-04-15
18:38:52 UTC (rev 7851)
+++
branches/3.1.x/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js 2008-04-15
21:34:44 UTC (rev 7852)
@@ -43,15 +43,10 @@
var parentForm = document.forms[formId];
if(parentForm == null) return;
- var fInput = parentForm[clientId];
- if(fInput==null) {
- fInput = document.createElement("input");
- fInput.type = "hidden";
- fInput.name = clientId;
- parentForm.appendChild(fInput);
- }
- fInput.value = stateId;
- parentForm.submit();
+ var params = {};
+ params[clientId] = stateId;
+ _JSFFormSubmit(null, parentForm, null, params);
+
return false;
}
Modified: branches/3.1.x/ui/togglePanel/src/main/templates/toggleControl.jspx
===================================================================
--- branches/3.1.x/ui/togglePanel/src/main/templates/toggleControl.jspx 2008-04-15
18:38:52 UTC (rev 7851)
+++ branches/3.1.x/ui/togglePanel/src/main/templates/toggleControl.jspx 2008-04-15
21:34:44 UTC (rev 7852)
@@ -13,6 +13,7 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
new org.ajax4jsf.javascript.AjaxScript(),
+ /org/ajax4jsf/javascript/scripts/form.js,
scripts/togglePanel.js
</h:scripts> <f:clientid var="clientId"/>
<a id="#{clientId}" href="#"