From: Anjo K. <an...@us...> - 2006-08-24 11:51:58
|
Update of /cvsroot/wonder/Wonder/Ajax/Ajax/Sources/er/ajax In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv21052/Ajax/Ajax/Sources/er/ajax Modified Files: AjaxUpdateLink.java Log Message: added 'disabled', 'insertion' and 'string', now allows effects to render the updated component. See the last link in the example Index: AjaxUpdateLink.java =================================================================== RCS file: /cvsroot/wonder/Wonder/Ajax/Ajax/Sources/er/ajax/AjaxUpdateLink.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AjaxUpdateLink.java 12 Aug 2006 05:09:12 -0000 1.8 --- AjaxUpdateLink.java 24 Aug 2006 11:51:55 -0000 1.9 *************** *** 10,14 **** import com.webobjects.foundation.NSMutableArray; import com.webobjects.foundation.NSMutableDictionary; ! public class AjaxUpdateLink extends AjaxDynamicElement { --- 10,31 ---- import com.webobjects.foundation.NSMutableArray; import com.webobjects.foundation.NSMutableDictionary; ! /** ! * Updates a region on the screen by creating a request to an action, then returning a script that in turn ! * creates an Ajax.Updater for the area. ! * @binding onComplete JavaScript function to evaluate when the request has finished. ! * @binding onSuccess JavaScript function to evaluate when the request was successful. ! * @binding onFailure JavaScript function to evaluate when the request has failed. ! * @binding onException JavaScript function to evaluate when the request had errors. ! * @binding evalScripts boolean defining if the container update is expected to be a script. ! * @binding insertion JavaScript function to evaluate when the update takes place. ! * @binding ignoreActionResponse boolean defining if the action's response should be thrown away ! * (useful when the same action has both Ajax and plain links) ! * @binding title title of the link ! * @binding style css style of the link ! * @binding class css class of the link ! * @binding id id of the link ! * @binding disabled boolean defining if the link renders the tag ! * @binding string string to get preprended to the contained elements ! */ public class AjaxUpdateLink extends AjaxDynamicElement { *************** *** 41,45 **** ajaxOptionsArray.addObject(new AjaxOption("onFailure", AjaxOption.SCRIPT)); ajaxOptionsArray.addObject(new AjaxOption("onException", AjaxOption.SCRIPT)); - ajaxOptionsArray.addObject(new AjaxOption("insertion", AjaxOption.STRING)); ajaxOptionsArray.addObject(new AjaxOption("evalScripts", AjaxOption.BOOLEAN)); NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, component, associations()); --- 58,61 ---- *************** *** 52,67 **** public void appendToResponse(WOResponse response, WOContext context) { WOComponent component = context.component(); ! ! response.appendContentString("<a "); ! appendTagAttributeToResponse(response, "href", "javascript:void(0)"); ! appendTagAttributeToResponse(response, "title", valueForBinding("title", component )); ! appendTagAttributeToResponse(response, "value", valueForBinding("value", component )); ! appendTagAttributeToResponse(response, "class", valueForBinding("class", component )); ! appendTagAttributeToResponse(response, "style", valueForBinding("style", component )); ! appendTagAttributeToResponse(response, "id", valueForBinding("id", component )); ! appendTagAttributeToResponse(response, "onClick", onClick(context)); ! response.appendContentString(">"); appendChildrenToResponse(response, context); ! response.appendContentString("</a>"); super.appendToResponse(response, context); } --- 68,91 ---- public void appendToResponse(WOResponse response, WOContext context) { WOComponent component = context.component(); ! boolean disabled = booleanValueForBinding("disabled", false, component); ! Object stringValue = valueForBinding("string", component); ! if(!disabled) { ! response.appendContentString("<a "); ! appendTagAttributeToResponse(response, "href", "javascript:" + onClick(context) + "; void(0);"); ! appendTagAttributeToResponse(response, "title", valueForBinding("title", component )); ! appendTagAttributeToResponse(response, "value", valueForBinding("value", component )); ! appendTagAttributeToResponse(response, "class", valueForBinding("class", component )); ! appendTagAttributeToResponse(response, "style", valueForBinding("style", component )); ! appendTagAttributeToResponse(response, "id", valueForBinding("id", component )); ! // appendTagAttributeToResponse(response, "onclick", onClick(context)); ! response.appendContentString(">"); ! } ! if(stringValue != null) { ! response.appendContentHTMLString(stringValue.toString()); ! } appendChildrenToResponse(response, context); ! if(!disabled) { ! response.appendContentString("</a>"); ! } super.appendToResponse(response, context); } *************** *** 75,86 **** WOComponent component = context.component(); WOActionResults results = (WOActionResults) valueForBinding("action", component); ! if (results == null) { String updateContainerID = (String) valueForBinding("updateContainerID", component); if(updateContainerID != null) { WOResponse response = AjaxUtils.createResponse(context); response.setHeader("text/javascript", "content-type"); ! response.setContent("new Ajax.Updater('"+updateContainerID+"', $('"+updateContainerID+"').getAttribute('updateUrl'), {evalScripts: " + ! valueForBinding("evalScripts", "false", context.component()) + ! "})"); results = response; } --- 99,111 ---- WOComponent component = context.component(); WOActionResults results = (WOActionResults) valueForBinding("action", component); ! if (results == null || booleanValueForBinding("ignoreActionResponse", false, component)) { String updateContainerID = (String) valueForBinding("updateContainerID", component); if(updateContainerID != null) { WOResponse response = AjaxUtils.createResponse(context); response.setHeader("text/javascript", "content-type"); ! response.setContent("new Ajax.Updater('"+updateContainerID+"', $('"+updateContainerID+"').getAttribute('updateUrl'), {"+ ! " evalScripts: " + valueForBinding("evalScripts", "false", context.component()) + ", " + ! " insertion: " + valueForBinding("insertion", "function(receiver, response) {Element.update(receiver, response);}}); }", context.component()) + " " + ! "})"); results = response; } |