You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by pr...@apache.org on 2006/04/14 02:40:11 UTC
svn commit: r393991 - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apache/myfaces/renderkit/html/util/
sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/
sandbox/core/src/main...
Author: prophecy
Date: Thu Apr 13 17:40:08 2006
New Revision: 393991
URL: http://svn.apache.org/viewcvs?rev=393991&view=rev
Log:
Added visual indicator that the components are actually doing something.
Multiple listeners can be used on a single component.
Pulled javascript out into it's js file.
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/inputAjax.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/myFaces_Ajax.css
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/spacer.gif (with props)
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/throbber.gif (with props)
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/HtmlComponentUtils.java
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ExtensionsPhaseListener.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjaxRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjaxRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjaxRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/Listener.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/HtmlOutputText.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputAjax.jsp
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/HtmlComponentUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/HtmlComponentUtils.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/HtmlComponentUtils.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/util/HtmlComponentUtils.java Thu Apr 13 17:40:08 2006
@@ -160,4 +160,6 @@
}
return null;
}
+
+
}
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ExtensionsPhaseListener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ExtensionsPhaseListener.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ExtensionsPhaseListener.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/ExtensionsPhaseListener.java Thu Apr 13 17:40:08 2006
@@ -133,7 +133,7 @@
JavascriptUtils.renderAutoScrollFunction(facesContext, writer);
}
- // also write out listeners
+ // now write out listeners
// todo: change the get entry below to use the static field in Listener if/when the listeners move to Tomahawk from sandbox
try
{
@@ -150,13 +150,19 @@
Map listenerItem = (Map) listeners.get(i);
String listenerId = (String) listenerItem.get("listenerId");
String listenOn = (String) listenerItem.get("listenOn");
+ String action = (String) listenerItem.get("action");
+ String eventType = (String) listenerItem.get("eventType");
// todo: Should use Listener object for more flexibility, but only when it moves to tomahawk
buff.append("var _MyFaces_listenerItem = ").append(mapName).append("['").append(listenOn).append("'];\n");
buff.append("if(!_MyFaces_listenerItem) {\n");
buff.append(" _MyFaces_listenerItem = new Array();\n");
buff.append(" ").append(mapName).append("['").append(listenOn).append("'] = _MyFaces_listenerItem;\n");
buff.append("}\n");
- buff.append("_MyFaces_listenerItem[_MyFaces_listenerItem.length] = '").append(listenerId).append("';\n");
+ buff.append("var _MyFaces_listener = new Object();\n");
+ buff.append("_MyFaces_listener['id'] = '").append(listenerId).append("';\n");
+ buff.append("_MyFaces_listener['action'] = '").append(action).append("';\n");
+ buff.append("_MyFaces_listener['eventType'] = '").append(eventType).append("';\n");
+ buff.append("_MyFaces_listenerItem[_MyFaces_listenerItem.length] = _MyFaces_listener;\n");
}
writer.write(buff.toString());
writer.endElement(HTML.SCRIPT_ELEM);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/api/AjaxDecodePhaseListener.java Thu Apr 13 17:40:08 2006
@@ -216,8 +216,8 @@
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
StringBuffer buff = new StringBuffer();
- buff.append("<?xml version=\"1.0\"?>");
- buff.append("<response>");
+ buff.append("<?xml version=\"1.0\"?>\n");
+ buff.append("<response>\n");
PrintWriter out = response.getWriter();
out.print(buff);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/ajax/util/AjaxRendererUtils.java Thu Apr 13 17:40:08 2006
@@ -27,18 +27,19 @@
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.renderkit.html.util.AddResource;
-import org.apache.myfaces.renderkit.html.util.ExtensionsPhaseListener;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
import org.apache.myfaces.custom.ajax.AjaxCallbacks;
+import org.apache.myfaces.custom.ajax.api.AjaxComponent;
import org.apache.myfaces.custom.prototype.PrototypeResourceLoader;
import org.apache.myfaces.custom.util.ComponentUtils;
import org.apache.myfaces.custom.inputAjax.HtmlInputTextAjax;
+import org.apache.myfaces.custom.inputAjax.HtmlCommandButtonAjax;
import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMessageRendererBase;
import org.apache.myfaces.component.html.ext.HtmlMessages;
@@ -49,6 +50,8 @@
*/
public final class AjaxRendererUtils
{
+ public static final String STYLECLASS_LOADER = "myFacesInputSuggestAjax";
+
/**
* util class.
*/
@@ -63,15 +66,20 @@
public static void addPrototypeScript(FacesContext context, UIComponent component, AddResource addResource)
{
+ // todo: replace with DOJO
+ // todo: this doesn't need to be called from every component, move it into encodeAjax or something
String javascriptLocation = (String) component.getAttributes().get(JSFAttr.JAVASCRIPT_LOCATION);
if (javascriptLocation != null)
{
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/prototype.js");
+ addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, javascriptLocation + "/effects.js");
}
else
{
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, PrototypeResourceLoader.class, "prototype.js");
+ addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN, PrototypeResourceLoader.class, "effects.js");
}
+ addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, AjaxRendererUtils.class, "myFaces_Ajax.css");
}
public static void writeAjaxScript(FacesContext context, ResponseWriter out, AjaxCallbacks component)
@@ -137,252 +145,18 @@
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ out.writeText("var " + jsNameSpace + "ajaxUrl = '" + ajaxURL + "';\n", null);
+ out.writeText("var " + jsNameSpace + "globalErrorsId = '" + ajaxMessagesId + "';\n", null);
// for component specific mappings
-
out.writeText("var " + AJAX_RESPONSE_MAP + " = new Object();\n", null);
- // output global functions
- // utility functions todo: these should be part of a standard js include
- // clear a field
- StringBuffer buff = new StringBuffer();
- buff.append("function ").append(JS_MYFACES_NAMESPACE).append("clearById(elname){\n")
- .append(" var el = document.getElementById(elname);\n")
- .append(" el.value = \"\";\n")
- .append("}\n");
- out.writeText(buff.toString(), null);
-
- buff = new StringBuffer();
- buff.append("\n")
- .append("function ").append(jsNameSpace).append("notifyElement(originalRequest, successful)\n")
- .append("{\n");
- buff.append(" ").append(jsNameSpace).append("clearGlobalMessages();\n");
- //buff.append(" alert(\"originalRequest: \" + originalRequest + \" - \" + successful + \"\\ntext: \" + originalRequest.responseText);\n");
- buff.append(" var errorArray = originalRequest.responseXML.getElementsByTagName(\"response\")[0].getElementsByTagName(\"error\");\n")
- .append(" if(errorArray && errorArray.length > 0){\n")
- .append(" for(ierr = 0; ierr < errorArray.length; ierr++){\n")
- .append(" var myObError = errorArray[ierr];\n")
- .append(" var errorClientId = myObError.getAttribute(\"elname\");\n")
- .append(" var errorSeverity = myObError.getAttribute(\"severity\");\n")
- .append(" var errorSummary = myObError.getAttribute(\"summary\");\n")
- .append(" var errorDetail = null;\n")
- .append(" var errorDetailElements = myObError.getElementsByTagName(\"detail\");\n")
- .append(" if(errorDetailElements) errorDetail = errorDetailElements[0].text;\n")
- .append(" var style = myObError.getAttribute(\"style\");\n")
- .append(" var styleClass = myObError.getAttribute(\"styleClass\");\n")
- .append(" ")
- .append(jsNameSpace).append("displayError(errorClientId, errorSeverity, errorSummary, errorDetail, styleClass, style);\n")
- .append(" }\n"); // end error loop
-
- //also after displaying the error message, onSuccessFunction() should be called
- // TR - Why would success be called on error?
- /* if (component.getOnSuccess() != null)
- buff.append(AJAX_RESPONSE_MAP).append("['elname']""onSuccessFunction(elname, elvalue, originalRequest);\n");*/
-
- buff.append(" }\n")
- .append(" var myObElementArray = originalRequest.responseXML.getElementsByTagName(\"response\")[0].getElementsByTagName(\"elementUpdated\");\n")
- .append(" if(myObElementArray && myObElementArray.length > 0){\n")
- .append(" for(iob = 0; iob < myObElementArray.length; iob++){\n")
- .append(" var myObElement = myObElementArray[iob];\n")
- .append(" var elname = myObElement.getAttribute(\"elname\");\n")
- .append(" var elvalue = myObElement.getAttribute(\"elvalue\");\n")
- //.append(" alert('elname: ' + elname + ' elvalue: ' + elvalue + ' successful: ' + successful);\n")
- .append(" if(elvalue){\n")
- .append(" if (successful){\n");
- if (component.getOnSuccess() != null)
- {
- buff.append(" ").append(AJAX_RESPONSE_MAP).append("['elname']['onSuccessFunction'](elname, elvalue, originalRequest);\n");
- }
-
- buff.append(" ").append(jsNameSpace).append("clearError(elname);\n");
- // and update the component value if it changed
- buff.append(" var elToUpdate = document.getElementById(elname + '_span');\n");
- //buff.append("alert('span: ' + elname + '_span elToUpdate: ' + elToUpdate + ' - ' + elvalue);\n");
- buff.append(" if(elToUpdate) elToUpdate.innerHTML = elvalue;\n"); // todo: need to use ".value" for form elements
- // also check for any listeners
- //buff.append("alert('listenersmap: ' + ").append(ExtensionsPhaseListener.LISTENERS_MAP).append(" + ' getting: ' + elname);\n");
- buff.append(" if(").append(ExtensionsPhaseListener.LISTENERS_MAP).append("){\n")
- .append(" var _MyFaces_listenerArray = ").append(ExtensionsPhaseListener.LISTENERS_MAP).append("[elname];\n")
- // .append("alert('listenerarray: ' + _MyFaces_listenerArray);\n")
- .append(" if(_MyFaces_listenerArray){\n")
- // loop throough listeners in array
- .append(" for(ilaindex = 0; ilaindex < _MyFaces_listenerArray.length; ilaindex++){\n")
- .append(" var _MyFaces_listenerItem = _MyFaces_listenerArray[ilaindex];\n")
- // then call action on listener, just supporting "update" at first
- //.append("alert('listeneritem: ' + _MyFaces_listenerItem);\n")
- .append(" ").append(jsNameSpace).append("updateComponent(_MyFaces_listenerItem);\n")
- .append(" }\n")
- .append(" }\n")
- .append(" }\n");
- buff.append(" }\n");
- buff.append(" }\n");// end if(elvalue)
- if (component.getOnFailure() != null)
- {
- buff.append(" else\n")
- .append(" {\n")
- .append(" ").append(AJAX_RESPONSE_MAP).append("['elname']['onFailureFunction'](elname, elvalue, originalRequest);}\n");
- }
- buff.append(" }\n")
- .append(" }\n")//// end returned successful object loop
- .append("}\n");
-
- // displayError function shows any errors sent back
- buff.append("function ").append(jsNameSpace).append("displayError(elname, severity, summary, detail, styleClass, style){\n")
- .append(" var summaryAndDetail = summary;\n")
- .append(" if(detail) summaryAndDetail += \": \" + detail;\n");
- if (ajaxMessagesId != null)
- {
- buff.append(" var ajaxMessagesSpan = document.getElementById( \"" + ajaxMessagesId + "\");\n")
- .append(" if(ajaxMessagesSpan){\n")
- .append(" ajaxMessagesSpan.innerHTML += summaryAndDetail + '<br/>';\n")
- .append(" }");
- }
- buff.append(" var msgSpan = document.getElementById(elname+\"_msgFor\");\n")
- .append(" if(msgSpan) msgSpan.innerHTML = summaryAndDetail;\n")
- .append(" if(styleClass) msgSpan.className = styleClass;\n");
- //.append(" if(style) msgSpan.style = style;") // guess you can't swap out the entire style like this
-
- if (htmlInputTextAjax != null)
- {
- //styling of the ajax fields
- buff.append("var errorStyleElem = document.getElementById(elname);\n")
- .append("if(errorStyleElem){\n");
- if (htmlInputTextAjax.getErrorStyleClass() != null)
- buff.append("errorStyleElem.className =\"").append(htmlInputTextAjax.getErrorStyleClass()).append("\";\n");
- if (htmlInputTextAjax.getErrorStyle() != null)
- buff.append("errorStyleElem.style.cssText =\"").append(htmlInputTextAjax.getErrorStyle()).append("\";\n");
- buff.append("}\n");
- }
-
- buff.append("}\n");
- // clearError function to remove error display if there was one previously
- buff.append("function ").append(jsNameSpace).append("clearError(elname){\n")
- .append(" var msgSpan = document.getElementById(elname+\"_msgFor\");\n")
- .append(" if(msgSpan){\n")
- .append(" msgSpan.innerHTML = \"\";\n")
- .append(" }\n");
- buff.append(" var errorField = document.getElementById(elname);\n");
- buff.append(" if(errorField){\n");
- if (htmlInputTextAjax != null)
- {
- if (htmlInputTextAjax.getStyleClass() != null)
- buff.append("errorField.className = \"" + htmlInputTextAjax.getStyleClass() + "\";\n");
- else if (htmlInputTextAjax.getStyle() != null)
- {
- buff.append("errorField.style.cssText = \"" + htmlInputTextAjax.getStyle() + "\";\n");
- }
- else
- {
- buff.append("errorField.style.cssText = \"\";\n")
- .append("errorField.className = \"\";\n");
- }
- }
- buff.append("}\n");
- buff.append("}\n");
-
-
- //clearError function; same as above, but also for using the messages comp
- buff.append("function ").append(jsNameSpace).append("clearGlobalMessages(){\n");
- /*.append("try\n")
- .append(" {\n")*/
- //.append(" if(possibleUpdateTag[0].tagName == \"elementUpdated\")\n")
- //.append(" {\n");
- if (ajaxMessagesId != null)
- {
- buff.append(" var errorMessageSpan = document.getElementById(\"" + ajaxMessagesId + "\");\n")
- .append(" errorMessageSpan.innerHTML = \"\";\n");
- }
- //set ajaxinputField to default style or styleclass
-
- //buff.append(" }\n")
- /*.append(" }catch(e)\n")
- .append(" {\n")
- .append(" this.dispatchException(e);\n")
- .append(" }\n")*/
- buff.append(" }\n");
-
- buff.append("function ").append(jsNameSpace)
- .append("notifyElementFailure(originalRequest){\n")
- .append(" ").append(jsNameSpace)
- .append("notifyElement(originalRequest, false);\n" + "}\n");
-
- buff.append("function ").append(jsNameSpace)
- .append("notifyElementSuccess(originalRequest){\n")
- .append(" ").append(jsNameSpace)
- .append("notifyElement(originalRequest, true);\n");
- buff.append("}\n")
- .append("function ").append(jsNameSpace)
- .append("complete(originalRequest){\n")
- // todo: allow for an onComplete attribute
- .append("}\n");
- // a function that takes an element id
- buff.append("function ").append(jsNameSpace).append("ajaxSubmit1(elname){\n")
- .append(" var el = document.getElementById(elname);\n")
- .append(" var elvalue = el.value;\n")
- .append(" ")
- .append(jsNameSpace)
- .append("ajaxSubmit(elname, elvalue, el);\n")
- .append("}\n");
- // a function that can take the actual element for things like HtmlSelectMany
- buff.append("function ").append(jsNameSpace).append("ajaxSubmit2(el, elname){\n")
- .append(" var checked = el.checked;\n")
- .append(" var elvalue = el.value;\n")
- .append(" var extraParams = '&checked=' + checked;\n")
- .append(" ").append(jsNameSpace).append("ajaxSubmit(elname, elvalue, el, extraParams);\n")
- .append("}\n");
-
-/*todo: For forms, the affectedAjaxComponent can be the commandButton, then in AjaxDecodePhaseListener, it can check if it's
- a command button, and if so, find the form (naming container), then update the form and then finally
- call the action method on the button*/
- // function for submitting an entire form
- buff.append("function ").append(jsNameSpace).append("ajaxSubmit3(elname){\n")
- .append(" var el = document.getElementById(elname);\n")
- .append(" var formEl = el.form;\n")
- .append(" var elvalue = 'submit';")
- .append(" ").append(jsNameSpace).append("ajaxSubmit(elname, elvalue, formEl);\n")
- .append("}\n");
-
- // and now the actual function that will send the request
- buff.append("function ").append(jsNameSpace).append("ajaxSubmit(elname, elvalue, el, extraParams, updateOnly){\n");
- if (component.getOnStart() != null)
- buff.append(" ").append(AJAX_RESPONSE_MAP).append("[elname]").append("['onStartFunction'](elname, elvalue);\n");
- buff.append(" var pars = \"affectedAjaxComponent=\" + elname + \"&elname=\" + elname + \"&elvalue=\" + elvalue + \"");
- buff.append("&\" + elname + \"=\" + elvalue + \"");
- if (context.getApplication().getStateManager().isSavingStateInClient(context))
- {
- buff.append("&jsf_tree_64=\"+encodeURIComponent(document.getElementById(\"jsf_tree_64\").value)+\"&jsf_state_64=\"+encodeURIComponent(document.getElementById(\"jsf_state_64\").value)+\"&jsf_viewid=\"+encodeURIComponent(document.getElementById(\"jsf_viewid\").value)+\"");
- }
- buff.append("\";\n"); // end pars
- buff.append(" if(extraParams) pars += extraParams;\n");
- buff.append(" if(updateOnly) pars += '&updateOnly=true';\n");
- buff.append(" if(el) pars += '&' + Form.serialize(el);\n");
- //buff.append(" alert(pars);"); // can be used for debugging
- buff.append(" var " + "_ajaxRequest = new Ajax.Request(\n")
- .append(" '").append(ajaxURL).append("',\n")//.append(AJAX_RESPONSE_MAP).append("[elname]['ajaxUrl'],\n")
- .append(" {method: 'post'" + ", parameters: pars");
- buff.append(", onComplete: ").append(jsNameSpace).append("complete");
- buff.append(", onSuccess: ").append(jsNameSpace).append("notifyElementSuccess");
- buff.append(", onFailure: ").append(jsNameSpace).append("notifyElementFailure");
- buff.append(
- "} \n" +
- " );\n" +
- "}\n"
- );
-
- // updateComponent will request latest value from server, basically just half of what ajaxSubmit does
- buff.append("function ").append(jsNameSpace).append("updateComponent(elname){\n")
- //.append(" alert('updating component: ' + elname);\n")
- .append(" ").append(jsNameSpace).append("ajaxUpdate(elname);\n")
- .append("}\n");
-
- buff.append("function ").append(jsNameSpace).append("ajaxUpdate(elname){\n")
- .append(" ").append(jsNameSpace).append("ajaxSubmit(elname, null, null, null, true);\n")
- .append("}\n");
-
- out.writeText(buff.toString(), null);
-
-
out.endElement(HTML.SCRIPT_ELEM);
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
+ AjaxRendererUtils.class, "inputAjax.js");
+ //"/js/inputAjax.js");
+
context.getExternalContext().getRequestMap().put(JAVASCRIPT_ENCODED, Boolean.TRUE);
}
@@ -390,7 +164,6 @@
out.startElement(HTML.SCRIPT_ELEM, null);
out.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
out.writeText(AJAX_RESPONSE_MAP + "['" + clientId + "'] = new Object();\n", null);
- //out.writeText(AJAX_RESPONSE_MAP + "['" + clientId + "']['ajaxUrl'] = '" + ajaxURL + "';\n", null);
if (component.getOnSuccess() != null)
out.writeText(AJAX_RESPONSE_MAP + "['" + clientId + "']['onSuccessFunction'] = " + component.getOnSuccess() + ";\n", null);
if (component.getOnFailure() != null)
@@ -398,15 +171,6 @@
if (component.getOnStart() != null)
out.writeText(AJAX_RESPONSE_MAP + "['" + clientId + "']['onStartFunction'] = " + component.getOnStart() + ";\n", null);
out.endElement(HTML.SCRIPT_ELEM);
- /*
- new Ajax.Request(form.action, {
- method: form.method,
- parameters: Form.serialize(form),
- onSuccess: updateFunction
- });
- */
-
-
}
@@ -414,7 +178,6 @@
public static void encodeAjax(FacesContext context, UIComponent component)
throws IOException
{
-
encodeAjax(context, component, null);
}
@@ -434,7 +197,7 @@
if (responseOb instanceof HttpServletResponse)
{
HttpServletResponse response = (HttpServletResponse) responseOb;
- HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
+ //HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
StringBuffer buff = new StringBuffer();
// send error messages
@@ -491,8 +254,11 @@
UIOutput uiOutput = (UIOutput) component;
// todo: might have to make sure this value can be serialized like this
// todo: and should probably be in text block, rather than an attribute
- buff.append(" elvalue=\"").append(uiOutput.getValue()).append("\"");
+ buff.append(" elvalue=\"").append(uiOutput.getValue()).append("\"");
+ // this is needed to know how to update the html element, javascript doesn't give the correct info!
+ //buff.append(" eltype=\"output\"");
}
+
if (extraReturnAttributes != null)
{
Iterator iter2 = extraReturnAttributes.keySet().iterator();
@@ -512,5 +278,25 @@
out.print(output);
}
+ }
+
+ /**
+ * Writes an animated image to show that something is happening
+ * @param context
+ * @param comp
+ */
+ public static void writeLoadingImage(FacesContext context, UIComponent comp) throws IOException
+ {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(org.apache.myfaces.shared_impl.renderkit.html.HTML.SPAN_ELEM, null);
+ writer.writeAttribute(HTML.ID_ATTR, comp.getClientId(context) + "_loaderImg", null);
+ writer.writeAttribute(HTML.CLASS_ATTR, AjaxRendererUtils.STYLECLASS_LOADER, null);
+ // could alternatively use a
+ // spacer.gif to stretch the span, but didn't want to have another resource dependency. It would be nice to
+ // have a "common" resource repository with spacer.gif and other common things
+ writer.write("<spacer type=\"block\" width=\"15\" height=\"15\"/>");
+ writer.endElement(org.apache.myfaces.shared_impl.renderkit.html.HTML.SPAN_ELEM);
+
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjaxRenderer.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlCommandButtonAjaxRenderer.java Thu Apr 13 17:40:08 2006
@@ -7,7 +7,6 @@
import org.apache.myfaces.custom.ajax.api.AjaxRenderer;
import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -64,15 +63,22 @@
return;
}
+
+
+
String clientId = component.getClientId(context);
String submitFunctionStart = AjaxRendererUtils.JS_MYFACES_NAMESPACE + "ajaxSubmit3('" + clientId + "');";
HtmlCommandButtonAjax comp = (HtmlCommandButtonAjax) component;
- // then submit on click
- comp.setOnclick(submitFunctionStart);
+ //comp.setOnclick(comp.getOnclick() == null ? submitFunctionStart : comp.getOnclick() + ";" + submitFunctionStart);
+ comp.setOnclick(submitFunctionStart);
+ String loadingStyleClass = AjaxRendererUtils.STYLECLASS_LOADER;
+ //comp.setStyleClass(comp.getStyleClass() == null ? loadingStyleClass : comp.getStyleClass() + ";" + loadingStyleClass);
+ //comp.setStyleClass(loadingStyleClass);
this.encodeJavascript(context, component);
super.encodeEnd(context, component);
-
+ // now write loading image
+ AjaxRendererUtils.writeLoadingImage(context, comp);
}
public void encodeAjax(FacesContext context, UIComponent component) throws IOException
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlInputTextAjaxRenderer.java Thu Apr 13 17:40:08 2006
@@ -83,9 +83,14 @@
String clientId = component.getClientId(context);
String submitFunctionStart = AjaxRendererUtils.JS_MYFACES_NAMESPACE + "ajaxSubmit1('" + clientId + "');";
HtmlInputTextAjax comp = (HtmlInputTextAjax) component;
+ String loadingStyleClass = AjaxRendererUtils.STYLECLASS_LOADER;
+ //comp.setStyleClass(comp.getStyleClass() == null ? loadingStyleClass : comp.getStyleClass() + ";" + loadingStyleClass);
+ comp.setStyleClass(loadingStyleClass);
+
if(!comp.getShowOkButton().booleanValue()){
// then submit on change
- comp.setOnchange(submitFunctionStart);
+ //comp.setOnchange(comp.getOnchange() == null ? submitFunctionStart : comp.getOnchange() + ";" + submitFunctionStart);
+ comp.setOnchange(submitFunctionStart);
}
this.encodeJavascript(context, component);
super.encodeEnd(context, component);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectBooleanCheckboxAjaxRenderer.java Thu Apr 13 17:40:08 2006
@@ -17,6 +17,8 @@
package org.apache.myfaces.custom.inputAjax;
import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -161,6 +163,7 @@
{
super.encodeEnd(context, component);
}
+ AjaxRendererUtils.writeLoadingImage(context, component);
}
public void encodeAjax(FacesContext context, UIComponent component) throws IOException
@@ -168,8 +171,10 @@
log.debug("entering HtmlSelectBooleanCheckboxAjaxRenderer.encodeAjax");
// check for request type (portlet support)
/*HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
+ */
Map extraReturnAttributes = new HashMap();
- extraReturnAttributes.put("checked", request.getParameter("checked"));*/
+ //extraReturnAttributes.put("checked", request.getParameter("checked"));
+ extraReturnAttributes.put("eltype", "checkbox");
AjaxRendererUtils.encodeAjax(context, component, null);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjaxRenderer.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectManyCheckboxAjaxRenderer.java Thu Apr 13 17:40:08 2006
@@ -85,6 +85,7 @@
this.encodeJavascript(context, component);
super.encodeEnd(context, component);
+ AjaxRendererUtils.writeLoadingImage(context, component);
}
@@ -95,6 +96,7 @@
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
Map extraReturnAttributes = new HashMap();
extraReturnAttributes.put("checked", request.getParameter("checked"));
+ extraReturnAttributes.put("eltype", "checkbox");
AjaxRendererUtils.encodeAjax(context, component, extraReturnAttributes);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjaxRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjaxRenderer.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/HtmlSelectOneRadioAjaxRenderer.java Thu Apr 13 17:40:08 2006
@@ -98,6 +98,7 @@
super.encodeEnd(context, component);
+ AjaxRendererUtils.writeLoadingImage(context, component);
}
public void encodeAjax(FacesContext context, UIComponent component) throws IOException
@@ -107,6 +108,7 @@
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
Map extraReturnAttributes = new HashMap();
extraReturnAttributes.put("checked", request.getParameter("checked"));
+ extraReturnAttributes.put("eltype", "radio");
AjaxRendererUtils.encodeAjax(context, component, extraReturnAttributes);
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/Listener.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/Listener.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/Listener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/inputAjax/Listener.java Thu Apr 13 17:40:08 2006
@@ -21,8 +21,8 @@
public static final String LISTENER_MAP_ENTRY = "org.apache.myfaces.Listener";
private String _on;
- private String _eventType;
- private String _action;
+ private String _eventType = "onChange";
+ private String _action = "update";
public Listener()
{
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/HtmlOutputText.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/HtmlOutputText.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/HtmlOutputText.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/HtmlOutputText.java Thu Apr 13 17:40:08 2006
@@ -44,7 +44,7 @@
{
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HTML.SPAN_ELEM, null);
- writer.writeAttribute("id", this.getClientId(facesContext) + "_span", null);
+ writer.writeAttribute("id", this.getClientId(facesContext), null);
super.encodeEnd(facesContext);
writer.endElement(HTML.SPAN_ELEM);
}
@@ -86,7 +86,8 @@
Map listenerItem = new HashMap();
listenerItem.put("listenOn", ajaxComponent.getClientId(context));
listenerItem.put("listenerId", component.getClientId(context));
- listenerItem.put("action", "update");
+ listenerItem.put("action", listener.getAction());
+ listenerItem.put("eventType", listener.getEventType());
listeners.add(listenerItem);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java Thu Apr 13 17:40:08 2006
@@ -113,4 +113,6 @@
return null;
}
+
+
}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/inputAjax.js
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/inputAjax.js?rev=393991&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/inputAjax.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/inputAjax.js Thu Apr 13 17:40:08 2006
@@ -0,0 +1,228 @@
+/**
+ * Extra javascript functions to handle Ajax components.
+ */
+var _MyFaces_inputAjax_ajaxResponseMap = new Object();
+function _MyFaces_inputAjax_clearById(elname)
+{
+ var el = document.getElementById(elname);
+ el.value = "";
+}
+
+function _MyFaces_inputAjax_notifyElement(originalRequest, successful)
+{
+ //_MyFaces_log('req: ' + originalRequest.responseText);
+ _MyFaces_inputAjax_clearGlobalMessages();
+ var errorArray = originalRequest.responseXML.getElementsByTagName("response")[0].getElementsByTagName("error");
+ if (errorArray && errorArray.length > 0)
+ {
+ for (ierr = 0; ierr < errorArray.length; ierr++)
+ {
+ var myObError = errorArray[ierr];
+ var errorClientId = myObError.getAttribute("elname");
+ var errorSeverity = myObError.getAttribute("severity");
+ var errorSummary = myObError.getAttribute("summary");
+ _MyFaces_stopLoader(errorClientId);
+ var errorDetail = null;
+ var errorDetailElements = myObError.getElementsByTagName("detail");
+ if (errorDetailElements) errorDetail = errorDetailElements[0].text;
+ var style = myObError.getAttribute("style");
+ var styleClass = myObError.getAttribute("styleClass");
+ _MyFaces_inputAjax_displayError(errorClientId, errorSeverity, errorSummary, errorDetail, styleClass, style);
+ }
+ }
+ var myObElementArray = originalRequest.responseXML.getElementsByTagName("response")[0].getElementsByTagName("elementUpdated");
+ if (myObElementArray && myObElementArray.length > 0)
+ {
+ for (iob = 0; iob < myObElementArray.length; iob++)
+ {
+ var myObElement = myObElementArray[iob];
+ var elname = myObElement.getAttribute("elname");
+ var elvalue = myObElement.getAttribute("elvalue");
+ var eltype = myObElement.getAttribute("eltype");
+ _MyFaces_log('elname: ' + elname + ' - value: ' + elvalue);
+ _MyFaces_stopLoader(elname);
+ if (elvalue)
+ {
+ if (successful)
+ {
+ _MyFaces_inputAjax_clearError(elname);
+ var elToUpdate = document.getElementById(elname);
+ //_MyFaces_log('elToUpdate: ' + elToUpdate + ' - type: ' + elToUpdate.type);
+ if (elToUpdate.type == 'text'
+ || elToUpdate.type == 'textarea'
+ || elToUpdate.type == 'password')
+ {
+ elToUpdate.value = elvalue;
+ }
+ else
+ {
+ if(eltype){
+ if(eltype == 'output'){
+ elToUpdate.innerHTML = elvalue;
+ } // checkbox, radio, etc
+ } else {
+ // maybe shouldn't handle this case
+ elToUpdate.innerHTML = elvalue;
+ }
+ }
+ if (_MyFaces_inputAjax_listenersMap)
+ {
+ var _MyFaces_listenerArray = _MyFaces_inputAjax_listenersMap[elname];
+ if (_MyFaces_listenerArray)
+ {
+ for (ilaindex = 0; ilaindex < _MyFaces_listenerArray.length; ilaindex++)
+ {
+ var _MyFaces_listener = _MyFaces_listenerArray[ilaindex];
+ //_MyFaces_log('listener on ' + elname + ' -- ' + _MyFaces_listener['id']);
+ var _MyFaces_jsString = 'javascript:';
+ if (_MyFaces_listener['action'].indexOf(_MyFaces_jsString) != -1)
+ {
+ var _func = _MyFaces_listener['action'].substr(_MyFaces_jsString.length);
+ _func = _func.replace(/this/, "document.getElementById(\'" + _MyFaces_listener['id'] + "\')");
+ eval(_func);
+ }
+ else
+ {
+ _MyFaces_inputAjax_updateComponent(_MyFaces_listener['id']);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+function _MyFaces_inputAjax_displayError(elname, severity, summary, detail, styleClass, style)
+{
+ var summaryAndDetail = summary;
+ if (detail) summaryAndDetail += ": " + detail;
+ var ajaxMessagesSpan = document.getElementById("_idJsp1:_idJsp23");
+ if (ajaxMessagesSpan)
+ {
+ ajaxMessagesSpan.innerHTML += summaryAndDetail + '<br/>';
+ }
+ var msgSpan = document.getElementById(elname + "_msgFor");
+ if (msgSpan) msgSpan.innerHTML = summaryAndDetail;
+ if (styleClass) msgSpan.className = styleClass;
+ var errorStyleElem = document.getElementById(elname);
+ if (errorStyleElem)
+ {
+ Element.addClassName(errorStyleElem, "myFaces_error");
+ }
+}
+function _MyFaces_inputAjax_clearError(elname)
+{
+ var msgSpan = document.getElementById(elname + "_msgFor");
+ if (msgSpan)
+ {
+ msgSpan.innerHTML = "";
+ }
+ var errorField = document.getElementById(elname);
+ if (errorField)
+ {
+ // can't do this because clears all styles errorField.style.cssText = "";
+ Element.removeClassName(errorField, "myFaces_error");
+ }
+}
+function _MyFaces_inputAjax_clearGlobalMessages()
+{
+ var errorMessageSpan = document.getElementById(_MyFaces_inputAjax_globalErrorsId);
+ if(errorMessageSpan) errorMessageSpan.innerHTML = "";
+}
+function _MyFaces_startLoader(elname)
+{
+ var myFaces_loaderImg = document.getElementById(elname + '_loaderImg');
+ if (myFaces_loaderImg) Element.addClassName(myFaces_loaderImg, "myFacesInputSuggestAjaxThrobbing");
+ else
+ {
+ var elToUpdate = document.getElementById(elname);
+ if (elToUpdate)Element.addClassName(elToUpdate, "myFacesInputSuggestAjaxThrobbing");
+ }
+
+}
+function _MyFaces_stopLoader(elname)
+{
+ // sleep for eyes sake
+ setTimeout("_MyFaces_stopLoader2('" + elname + "')", 500);
+}
+function _MyFaces_stopLoader2(elname)
+{
+ var myFaces_loaderImg = document.getElementById(elname + '_loaderImg');
+ if (myFaces_loaderImg) Element.removeClassName(myFaces_loaderImg, "myFacesInputSuggestAjaxThrobbing");
+ else
+ {
+ var elToUpdate = document.getElementById(elname);
+ if (elToUpdate)Element.removeClassName(elToUpdate, "myFacesInputSuggestAjaxThrobbing");
+ }
+}
+function _MyFaces_inputAjax_notifyElementFailure(originalRequest)
+{
+ _MyFaces_inputAjax_notifyElement(originalRequest, false);
+}
+function _MyFaces_inputAjax_notifyElementSuccess(originalRequest)
+{
+ _MyFaces_inputAjax_notifyElement(originalRequest, true);
+}
+function _MyFaces_inputAjax_complete(originalRequest)
+{
+}
+function _MyFaces_inputAjax_ajaxSubmit1(elname)
+{
+ var el = document.getElementById(elname);
+ var elvalue = el.value;
+ _MyFaces_inputAjax_ajaxSubmit(elname, elvalue, el);
+}
+function _MyFaces_inputAjax_ajaxSubmit2(el, elname)
+{
+ var checked = el.checked;
+ var elvalue = el.value;
+ var extraParams = '&checked=' + checked;
+ _MyFaces_inputAjax_ajaxSubmit(elname, elvalue, el, extraParams);
+}
+function _MyFaces_inputAjax_ajaxSubmit3(elname)
+{
+ var el = document.getElementById(elname);
+ var formEl = el.form;
+ var elvalue = 'submit';
+ _MyFaces_inputAjax_ajaxSubmit(elname, elvalue, formEl);
+}
+function _MyFaces_inputAjax_ajaxSubmit(elname, elvalue, el, extraParams, updateOnly)
+{
+ _MyFaces_log('SUBMITTING el: ' + el);
+ _MyFaces_startLoader(elname);
+ var pars = "affectedAjaxComponent=" + elname + "&elname=" + elname + "&elvalue=" + elvalue + "&" + elname + "=" + elvalue + "";
+ if (extraParams) pars += extraParams;
+ if (updateOnly) pars += '&updateOnly=true';
+ if (el) pars += '&' + Form.serialize(el);
+ //_MyFaces_log('Parameters: ' + pars);
+ var _ajaxRequest = new Ajax.Request(
+ _MyFaces_inputAjax_ajaxUrl,
+ {method: 'post', parameters: pars, onComplete: _MyFaces_inputAjax_complete, onSuccess: _MyFaces_inputAjax_notifyElementSuccess, onFailure: _MyFaces_inputAjax_notifyElementFailure}
+ );
+}
+function _MyFaces_inputAjax_updateComponent(elname)
+{
+ _MyFaces_inputAjax_ajaxUpdate(elname);
+}
+function _MyFaces_inputAjax_ajaxUpdate(elname)
+{
+ _MyFaces_inputAjax_ajaxSubmit(elname, null, null, null, true);
+}
+function _MyFaces_log(msg)
+{
+ var _myFaces_logDiv = document.getElementById("logDiv");
+ if (_myFaces_logDiv)
+ {
+ _myFaces_logDiv.innerHTML = _myFaces_logDiv.innerHTML + '<br/>' + _MyFaces_escapeHtml(msg);
+ }
+}
+function _MyFaces_escapeHtml(msg)
+{
+ encodedHtml = msg.replace(/</g, "<");
+ encodedHtml = encodedHtml.replace(/>/g, ">");
+ encodedHtml = encodedHtml.replace(/\n/g, "<br/>");
+ //alert('enc: ' + encodedHtml);
+ return encodedHtml;
+
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/myFaces_Ajax.css
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/myFaces_Ajax.css?rev=393991&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/myFaces_Ajax.css (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/myFaces_Ajax.css Thu Apr 13 17:40:08 2006
@@ -0,0 +1,20 @@
+.myFacesInputSuggestAjax{
+ background: url('throbber.gif') no-repeat 100% 2px;
+ background-color: white;
+}
+
+.myFacesInputSuggestAjaxThrobbing{
+ background-position: 100% -18px;
+}
+span.myFacesInputSuggestAjax{
+ width:15px;
+ height:15px;
+ margin-left:10px;
+ margin-right:5px;
+ margin-top:10px;
+ margin-bottom:5px;
+}
+.myFaces_error{
+ border:1px solid red;
+ color:red;
+}
\ No newline at end of file
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/spacer.gif
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/spacer.gif?rev=393991&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/spacer.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/throbber.gif
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/throbber.gif?rev=393991&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/ajax/util/resource/throbber.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/suggestajax/tablesuggestajax/resource/default/table_suggest.css Thu Apr 13 17:40:08 2006
@@ -39,4 +39,4 @@
input.myFacesInputSuggestAjaxThrobbing{
background-position: 100% -18px;
-}
\ No newline at end of file
+}
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/home.jsp Thu Apr 13 17:40:08 2006
@@ -91,6 +91,7 @@
<h:commandLink action="go_scope_shop"><f:verbatim>Scope - saveState without serialisation</f:verbatim></h:commandLink>
<h:outputLink value="effect.jsf" ><f:verbatim>Effect - FAT and script.aculo.us effects</f:verbatim></h:outputLink>
<h:outputLink value="dojo/textareatestjsfonly.jsf"><f:verbatim>Integration of Dojo Toolkit</f:verbatim></h:outputLink>
+ <h:outputLink value="killSession.jsf"><f:verbatim>Kill Session - refreshes state</f:verbatim></h:outputLink>
</h:panelGrid>
</h:panelGrid>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputAjax.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputAjax.jsp?rev=393991&r1=393990&r2=393991&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputAjax.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/inputAjax.jsp Thu Apr 13 17:40:08 2006
@@ -39,6 +39,10 @@
var statusDiv = document.getElementById("statusDiv");
statusDiv.innerHTML = "DOH!";
}
+ function startPulse(el){
+
+ new Effect.Pulsate(el);
+ }
</script>
<style type="text/css">
.bold {
@@ -208,40 +212,45 @@
</t:panelLayout>
<h:panelGrid columns="2">
-<h:form>
- <h:outputText styleClass="standard_bold" value="Form Submit via AJAX"/>
- <h:panelGrid columns="2">
- <h:panelGrid columns="2">
- <t:inputText id="formText1" value="#{inputAjaxBean.formText1}"
- validator="#{inputAjaxBean.validateFormText1}"></t:inputText>
- <t:message for="formText1" forceSpan="true" styleClass="errorMessage"/>
-
- <t:inputText id="formText2" value="#{inputAjaxBean.formText2}"
- validator="#{inputAjaxBean.validateFormText2}"></t:inputText>
- <t:message for="formText2" forceSpan="true" styleClass="errorMessage"/>
-
- <s:commandButtonAjax action="#{inputAjaxBean.ajaxFormSubmit}" value="Submit"/>
- <h:outputText value=" " escape="false"/>
- </h:panelGrid>
- <f:verbatim>This component demonstrates submitting a form through ajax. To see validation errors, put less than five
- characters in first box, and a string with a space in it in the second box.</f:verbatim>
-</h:panelGrid>
-</h:form>
- <%-- Auto updating piece --%>
+ <h:form>
+ <h:panelGrid columns="1">
+ <h:outputText styleClass="standard_bold" value="Form Submit via AJAX"/>
+ <f:verbatim>This component demonstrates submitting a form through ajax. To see validation errors, put less
+ than five characters in first box, and a string with a space in it in the second box.</f:verbatim>
+ <h:panelGrid columns="2">
+ <t:inputText id="formText1" value="#{inputAjaxBean.formText1}"
+ validator="#{inputAjaxBean.validateFormText1}"></t:inputText>
+ <t:message for="formText1" forceSpan="true" styleClass="errorMessage"/>
+
+ <t:inputText id="formText2" value="#{inputAjaxBean.formText2}"
+ validator="#{inputAjaxBean.validateFormText2}"></t:inputText>
+ <t:message for="formText2" forceSpan="true" styleClass="errorMessage"/>
+
+ <s:commandButtonAjax action="#{inputAjaxBean.ajaxFormSubmit}" value="Submit"/>
+ <h:outputText value=" " escape="false"/>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+ <%-- Auto updating piece --%>
<h:panelGrid columns="1">
- <h:outputText styleClass="standard_bold" value="Listener on the first textfield to the left"/>
- <s:outputText value="#{inputAjaxBean.waitingText1}">
- <s:listener on="formText1"/>
- </s:outputText>
- <h:outputText styleClass="standard_bold" value="Listener on the second textfield to the left"/>
- <s:outputText value="#{inputAjaxBean.waitingText2}">
- <s:listener on="formText2"/>
- </s:outputText>
+ <h:outputText styleClass="standard_bold" value="Listening on the first textfield to the left"/>
+ <s:outputText value="#{inputAjaxBean.waitingText1}">
+ <s:listener on="formText1"/>
+ </s:outputText>
+ <h:outputText styleClass="standard_bold" value="Listening on the second textfield to the left with multiple listeners"/>
+ <s:outputText value="#{inputAjaxBean.waitingText2}">
+ <s:listener on="formText2"/>
+ <s:listener on="formText2" action="javascript:startPulse(this);"/>
+ </s:outputText>
+
</h:panelGrid>
</h:panelGrid>
<h:outputLink value="inputAjax.jsf"><h:outputText value="Refresh"></h:outputText></h:outputLink>
+<t:div id="logDiv" forceId="true">
+ <b>Log:</b><br/>
+</t:div>
</f:view>