You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2008/12/05 12:25:59 UTC
svn commit: r723712 -
/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js
Author: werpu
Date: Fri Dec 5 03:25:55 2008
New Revision: 723712
URL: http://svn.apache.org/viewvc?rev=723712&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2112
https://issues.apache.org/jira/browse/MYFACES-2114
Modified:
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js?rev=723712&r1=723711&r2=723712&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js Fri Dec 5 03:25:55 2008
@@ -15,6 +15,10 @@
/**
*MyFaces core javascripting libraries
+ *
+ * Those are the central public functions in the JSF2
+ * Ajax API! They handle the entire form submit and ajax send
+ * and resolve cycle!
*/
/**
@@ -37,17 +41,73 @@
* collect and encode data for a given form element (must be of type form)
* find the javax.faces.ViewState element and encode its value as well!
* return a concatenated string of the encoded values!
+ *
+ * @throws an exception in case of the given element not being of type form!
*/
javax.faces.Ajax.viewState = function(formElement) {
- //Do typechecking here!
- if(formElement.nodeValue != "form") {
- throw Exception("javax.faces.Ajax.viewState: param value not of type form!!!");
+ /**
+ * typecheck assert!, we opt for strong typing here
+ * because it makes it easier to detect bugs
+ */
+
+ if( 'undefined' == typeof(formElement)
+ || null == formElement
+ ||'undefined' == typeof(formElement.nodeValue)
+ || null == formElement.nodeValue
+ || formElement.nodeValue != "form") {
+
+ throw Exception("javax.faces.Ajax.viewState: param value not of type form!");
+
}
- /*
+/*
* TODO #60
* https://issues.apache.org/jira/browse/MYFACES-2110
*/
-}
+};
+
+/**
+ * this function has to send the ajax requests
+ *
+ * following request conditions must be met:
+ * <ul>
+ * <li> the request must be sent asynchronously! </li>
+ * <li> the request must be a POST!!! request </li>
+ * <li> the request url must be the form action attribute </li>
+ * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
+ * </ul>
+ *
+ * @param element: any dom element no matter being it html or jsf, from which the event is emitted
+ * @param event: any javascript event supported by that object
+ * @param options : map of options being pushed into the ajax cycle
+ */
+javax.faces.Ajax.ajaxRequest = function(/*Dom*/ element,/*|EVENT|*/ event,/*{|OPTIONS|}*/ options) {
+ //condition asserts!
+ if('undefined' == typeof(element) || null == element) {
+ throw Exception("javax.faces.Ajax.ajaxRequest: element cannot be null or undefined!");
+ }
+ if('undefined' == typeof(options) || null == options) {
+ throw Exception("javax.faces.Ajax.ajaxRequest: options cannot be null or undefined! it must be at least an empty map!");
+ }
+
+ /*
+ * TODO #61
+ * https://issues.apache.org/jira/browse/MYFACES-2112
+ */
+};
+
+/**
+ * processes the ajax response if the ajax request completes successfully
+ * @param request the ajax request!
+ */
+javax.faces.Ajax.ajaxResponse = function(request) {
+ if('undefined' == typeof(request) || null == request) {
+ throw Exception("javax.faces.Ajax.ajaxResponse: The response cannot be null or empty!");
+ }
+ /**
+ * TODO #62
+ * https://issues.apache.org/jira/browse/MYFACES-2114
+ */
+};