Author: nbelaevski
Date: 2008-04-16 19:00:41 -0400 (Wed, 16 Apr 2008)
New Revision: 7885
Modified:
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
trunk/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js
trunk/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: trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js
===================================================================
---
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js 2008-04-16
17:06:59 UTC (rev 7884)
+++
trunk/framework/impl/src/main/resources/org/ajax4jsf/javascript/scripts/form.js 2008-04-16
23:00:41 UTC (rev 7885)
@@ -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 hiddenField = form.elements[formName+":_idcl"];
if(hiddenField){
@@ -37,7 +37,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 {
@@ -47,7 +61,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;
@@ -88,7 +102,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:
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js
===================================================================
---
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2008-04-16
17:06:59 UTC (rev 7884)
+++
trunk/ui/simpleTogglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/simpleTogglePanel.js 2008-04-16
23:00:41 UTC (rev 7885)
@@ -112,29 +112,21 @@
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 == "true") {
if (thePanel.invokeEvent("collapse",event,"true",fInput)) {
thePanel.status="false";
}
-
} else {
if (thePanel.invokeEvent("expand",event,"false",fInput)) {
thePanel.status="true";
}
}
- fInput.value = thePanel.status;
- parentForm.submit();
+ var params = {};
+ params[clientId] = thePanel.status;
+ _JSFFormSubmit(null, parentForm, null, params);
+
return false;
}
Modified:
trunk/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js
===================================================================
---
trunk/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js 2008-04-16
17:06:59 UTC (rev 7884)
+++
trunk/ui/togglePanel/src/main/resources/org/richfaces/renderkit/html/scripts/togglePanel.js 2008-04-16
23:00:41 UTC (rev 7885)
@@ -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: trunk/ui/togglePanel/src/main/templates/toggleControl.jspx
===================================================================
--- trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2008-04-16 17:06:59 UTC
(rev 7884)
+++ trunk/ui/togglePanel/src/main/templates/toggleControl.jspx 2008-04-16 23:00:41 UTC
(rev 7885)
@@ -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="#"