Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MooTools added MTAjaxInPlace based on the original AjaxInPlace. Also …

…added an example of it's usage to the example project.
  • Loading branch information...
commit e1c6e22995c8dbb3010183d81e88208c3a37f454 1 parent 4ae898c
@johnnykahalawai johnnykahalawai authored pascalrobert committed
View
89 Examples/Ajax/MooToolsExample/Components/MTAjaxInPlaceTestPage.wo/MTAjaxInPlaceTestPage.html
@@ -0,0 +1,89 @@
+<wo:Main pageTitle = "Ajax In Place Port">
+ <h2>Ajax In Place...</h2>
+ <hr />
+ <p>
+ AjaxInPlace provides support for arbitrarily complex view and edit components.
+ </p>
+ <hr/>
+ <h3>Simple AjaxInPlace</h3>
+ <hr/>
+ <webobject name = "ExampleInPlace">
+ <webobject name = "View">View: <webobject name = "Value" /></webobject>
+ <webobject name = "Edit"><label>Edit:</label><webobject name = "ValueField" /></webobject>
+ </webobject>
+ <hr/>
+ <h3>Simple AjaxInPlace with Manual Controls</h3>
+ <hr/>
+ <webobject name = "ExampleInPlaceManual">
+ <webobject name = "ViewManual">
+ View: <webobject name = "ManualValue"/>
+ <br/>
+ <webobject name = "ClickToEdit">click to edit</webobject>
+ </webobject>
+ <webobject name = "EditManual">
+ Edit: <webobject name = "ManualValueField"/>
+ <br/>
+ <webobject name = "ClickToSave">click to save</webobject>
+ <webobject name = "ClickToCancel">click to cancel</webobject>
+ </webobject>
+ </webobject>
+ <hr/>
+ <h3>Fancier AjaxInPlace</h3>
+ <hr/>
+ <webobject name = "FancyInPlace">
+ <webobject name = "FancyView">
+ <div id = "fancyView">
+ <h2>Personal Information</h2>
+ <table class = "table table-striped">
+ <tr>
+ <th>First Name</th>
+ <td><webobject name = "FirstName"/></td>
+ </tr>
+
+ <tr>
+ <th>Last Name</th>
+ <td><webobject name = "LastName"/></td>
+ </tr>
+
+ <tr>
+ <th>Phone Number</th>
+ <td><webobject name = "PhoneNumber"/></td>
+ </tr>
+ </table>
+ <span class = "label label-info">click anywhere to edit</span>
+ </div>
+ </webobject>
+ <webobject name = "FancyEdit">
+ <div id = "fancyEdit">
+ <fieldset>
+ <legend>Edit Personal Information</legend>
+ <div class="control-group">
+ <label class="control-label" for="firstName">First Name</label>
+ <div class="controls">
+ <webobject name = "FirstNameField"/>
+ <p class="help-block">Enter your first name here.</p>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="lastName">Last Name</label>
+ <div class="controls">
+ <webobject name = "LastNameField"/>
+ <p class="help-block">Enter your last name here.</p>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="phoneNumber">Phone Number</label>
+ <div class="controls">
+ <webobject name = "PhoneNumberField"/>
+ <p class="help-block">Enter your phone number here.</p>
+ </div>
+ </div>
+ <div class = "form-actions">
+ <webobject name = "FancySave">save</webobject> or
+ <webobject name = "FancyCancel">cancel</webobject>
+ </div>
+ </fieldset>
+ </div>
+ </webobject>
+ </webobject>
+</wo:Main>
View
123 Examples/Ajax/MooToolsExample/Components/MTAjaxInPlaceTestPage.wo/MTAjaxInPlaceTestPage.wod
@@ -0,0 +1,123 @@
+ClickToCancel : WOHyperlink {
+ class = "btn";
+ href = "javascript:void(0)";
+ onclick = "ExampleInPlaceManualCancel()";
+}
+
+ClickToEdit : WOHyperlink {
+ class = "btn";
+ href = "javascript:void(0)";
+ onclick = "ExampleInPlaceManualEdit()";
+}
+
+ClickToSave : WOHyperlink {
+ class = "btn btn-primary";
+ href = "javascript:void(0)";
+ onclick = "ExampleInPlaceManualSave()";
+}
+
+Edit : ERXWOTemplate {
+ templateName = "edit";
+}
+
+EditManual : ERXWOTemplate {
+ templateName = "edit";
+}
+
+ExampleInPlace : MTAjaxInPlace {
+ cancelAction = valueCancelled;
+ cancelClass = "btn btn-inverse";
+ formClass = "well form-inline";
+ saveClass = "btn btn-primary";
+ saveAction = valueSaved;
+}
+
+ExampleInPlaceManual : MTAjaxInPlace {
+ cancelAction = valueCancelled;
+ id = "ExampleInPlaceManual";
+ manualControl = true;
+ saveAction = valueSaved;
+}
+
+FancyCancel : AjaxFunctionLink {
+ class = "btn";
+ onclick = "fancyCancel()";
+}
+
+FancyEdit : ERXWOTemplate {
+ templateName = "edit";
+}
+
+FancyInPlace : MTAjaxInPlace {
+ formClass = "well";
+ id = "fancy";
+ manualEditControl = true;
+}
+
+FancySave : MTAjaxSubmitButton {
+ class = "btn btn-primary";
+ onClick = "fancySave()";
+ value = "save";
+}
+
+FancyView : ERXWOTemplate {
+ templateName = "view";
+}
+
+FirstName : WOString {
+ value = firstName;
+}
+
+FirstNameField : WOTextField {
+ class = "span3";
+ id = "firstName";
+ value = firstName;
+}
+
+LastName : WOString {
+ value = lastName;
+}
+
+LastNameField : WOTextField {
+ class = "span3";
+ id = "lastName";
+ value = lastName;
+}
+
+ManualValue : WOString {
+ value = manualValue;
+}
+
+ManualValueField : WOTextField {
+ value = manualValue;
+ size = "30";
+}
+
+PhoneNumber : WOString {
+ value = phoneNumber;
+}
+
+PhoneNumberField : WOTextField {
+ class = "span3";
+ id = "phoneNumber";
+ value = phoneNumber;
+}
+
+Value : WOString {
+ value = value;
+}
+
+ValueField : WOTextField {
+ id = "valueField";
+ onEnter = "alert('You hit enter and I am showing you an onEnter handler now.')";
+ selectAll = true;
+ value = value;
+}
+
+View : ERXWOTemplate {
+ templateName = "view";
+}
+
+ViewManual : ERXWOTemplate {
+ templateName = "view";
+}
View
4 Examples/Ajax/MooToolsExample/Components/MTAjaxInPlaceTestPage.wo/MTAjaxInPlaceTestPage.woo
@@ -0,0 +1,4 @@
+{
+ "WebObjects Release" = "WebObjects 5.0";
+ encoding = "UTF-8";
+}
View
9 Examples/Ajax/MooToolsExample/Components/Main.wo/Main.html
@@ -70,6 +70,15 @@
<i class="icon-refresh"></i>
Ajax Ping
</wo:link></li>
+ <li><wo:link directActionName = "PageAction/MTMediaBoxTestPage">
+ <i class="icon-picture"></i>
+ Media Box
+ </wo:link></li>
+ <li><wo:link directActionName = "PageAction/MTAjaxInPlaceTestPage">
+ <i class="icon-edit"></i>
+ Ajax In Place
+ </wo:link></li>
+
</ul>
</div>
<div class = "span9">
View
33 ...ax/MooToolsExample/Sources/er/ajax/mootools/example/components/MTAjaxInPlaceTestPage.java
@@ -0,0 +1,33 @@
+package er.ajax.mootools.example.components;
+
+import com.webobjects.appserver.WOActionResults;
+import com.webobjects.appserver.WOContext;
+
+public class MTAjaxInPlaceTestPage extends Main {
+
+ public String _manualValue;
+ public String _value;
+ public String _firstName;
+ public String _lastName;
+ public String _phoneNumber;
+
+ public MTAjaxInPlaceTestPage(WOContext context) {
+ super(context);
+ _value = "ExampleInPlace Value";
+ _manualValue = "ExampleInPlaceManual Value";
+ _firstName = "Johnny";
+ _lastName = "Ajax";
+ _phoneNumber = "800-555-1212";
+ }
+
+ public WOActionResults valueSaved() {
+ System.out.println("InPlaceExample.valueSaved: saved!");
+ return null;
+ }
+
+ public WOActionResults valueCancelled() {
+ System.out.println("InPlaceExample.valueCancelled: cancelled!");
+ return null;
+ }
+
+}
View
44 Frameworks/Ajax/MooTools/Components/MTAjaxInPlace.api
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<wodefinitions>
+ <wo class="MTAjaxInPlace" wocomponentcontent="true"> <binding name="button"/>
+ <binding name="cancelAction"/>
+ <binding name="cancelClass"/>
+ <binding name="cancelLabel"/>
+ <binding name="canEdit"/>
+ <binding name="cancelUpdateContainerID"/>
+ <binding name="canSave"/>
+ <binding name="class"/>
+ <binding name="disabled"/>
+ <binding name="editAction"/>
+ <binding name="editClass"/>
+ <binding name="editing"/>
+ <binding name="editOnly"/>
+ <binding name="elementName"/>
+ <binding name="formSerializer"/>
+ <binding name="id"/>
+ <binding name="manualControl"/>
+ <binding name="manualEditControl"/>
+ <binding name="manualViewControl"/>
+ <binding name="onCancelClick"/>
+ <binding name="onCancelFailure"/>
+ <binding name="onCancelling"/>
+ <binding name="onCancelSuccess"/>
+ <binding name="onEditClick"/>
+ <binding name="onEditFailure"/>
+ <binding name="onEditing"/>
+ <binding name="onEditSuccess"/>
+ <binding name="onRefreshComplete"/>
+ <binding name="onSaveClick"/>
+ <binding name="onSaveFailure"/>
+ <binding name="onSaveSuccess"/>
+ <binding name="onSaving"/>
+ <binding name="onSubmit"/>
+ <binding name="saveAction"/>
+ <binding name="saveClass"/>
+ <binding name="saveLabel"/>
+ <binding name="saveUpdateContainerID"/>
+ <binding name="style"/>
+ <binding name="submitOnSave"/>
+ <binding name="formClass"/>
+ </wo>
+</wodefinitions>
View
46 Frameworks/Ajax/MooTools/Components/MTAjaxInPlace.wo/MTAjaxInPlace.html
@@ -0,0 +1,46 @@
+<webobject name = "UpdateContainer">
+ <webobject name = "IsNotEditingConditional">
+ <webobject name = "IsChangingToViewConditional">
+ <webobject name = "ScriptContainer">
+ MTAIP.cleanupEdit('<webobject name = "ID" />');
+ </webobject>
+ </webobject>
+ <webobject name = "EditFunction"></webobject>
+ <webobject name = "ManualViewControlConditional">
+ <webobject name = "ViewComponent"></webobject>
+ </webobject>
+ <webobject name = "NotManualViewControlConditional">
+ <webobject name = "EditAction"><webobject name = "ViewComponent" /></webobject>
+ </webobject>
+ </webobject>
+ <webobject name = "IsEditingConditional">
+ <webobject name = "EditForm">
+ <webobject name = "EditComponent" />
+ <webobject name = "IsChangingToEditConditional">
+ <webobject name = "ScriptContainer">
+ MTAIP.cleanupView('<webobject name = "ID"></webobject>');
+ </webobject>
+ </webobject>
+ <webobject name = "SubmitOnSaveConditional">
+ <webobject name = "SaveSubmitFunction"></webobject>
+ </webobject>
+ <webobject name = "LinkOnSaveConditional">
+ <webobject name = "SaveLinkFunction"></webobject>
+ </webobject>
+ <webobject name = "CancelFunction"></webobject>
+ <webobject name = "NotManualEditControlConditional">
+ <webobject name = "ButtonConditional">
+ <webobject name = "SaveButtonAction"></webobject>
+ </webobject>
+ <webobject name = "LinkConditional">
+ <webobject name = "SaveLinkAction">
+ <webobject name = "SaveLabel" />
+ </webobject>
+ </webobject>
+ <webobject name = "CancelAction">
+ <webobject name = "CancelLabel"/>
+ </webobject>
+ </webobject>
+ </webobject>
+ </webobject>
+</webobject>
View
171 Frameworks/Ajax/MooTools/Components/MTAjaxInPlace.wo/MTAjaxInPlace.wod
@@ -0,0 +1,171 @@
+ButtonConditional : WOConditional {
+ condition = button;
+}
+
+CancelAction : WOGenericContainer {
+ elementName = "a";
+ href = "javascript:void(0)";
+ onclick = cancelFunctionCall;
+ class = ^cancelClass;
+}
+
+CancelFunction : MTAjaxUpdateLink {
+ action = cancel;
+ evalScripts = true;
+ functionName = cancelFunctionName;
+ onClick = ^onCancelClick;
+ onClickBefore = ^onCancelClickBefore;
+ onFailure = ^onCancelFailure;
+ onLoading = ^onCancelling;
+ onSuccess = ^onCancelSuccess;
+ updateContainerID = cancelUpdateContainerID;
+}
+
+CancelLabel : WOString {
+ value = ^cancelLabel;
+ valueWhenEmpty = "cancel";
+}
+
+EditAction : WOGenericContainer {
+ class = ^editClass;
+ elementName = "div";
+ onClick = editFunctionCall;
+}
+
+EditComponent : ERXWOComponentContent {
+ templateName = "edit";
+}
+
+EditForm : WOForm {
+ class = ^formClass;
+ disabled = disableForm;
+ multipleSubmit = true;
+ name = id;
+ onSubmit = ^onSubmit;
+}
+
+EditFunction : MTAjaxUpdateLink {
+ action = startEditing;
+ disabled = ^disabled;
+ evalScripts = true;
+ functionName = editFunctionName;
+ onClick = ^onEditClick;
+ onClickBefore = ^onEditClickBefore;
+ onFailure = ^onEditFailure;
+ onRequest = ^onEditing;
+ onSuccess = ^onEditSuccess;
+ updateContainerID = id;
+}
+
+ID : WOString {
+ value = id;
+}
+
+IsChangingToEditConditional : WOConditional {
+ condition = changingToEdit;
+}
+
+IsChangingToViewConditional : WOConditional {
+ condition = changingToView;
+}
+
+IsEditingConditional : WOConditional {
+ condition = editing;
+}
+
+IsNotEditingConditional : WOConditional {
+ condition = editing;
+ negate = true;
+}
+
+LinkConditional : WOConditional {
+ condition = button;
+ negate = true;
+}
+
+LinkOnSaveConditional : WOConditional {
+ condition = linkOnSave;
+}
+
+ManualViewControlConditional : WOConditional {
+ condition = manualViewControl;
+}
+
+NotManualEditControlConditional : WOConditional {
+ condition = manualEditControl;
+ negate = true;
+}
+
+NotManualViewControlConditional : WOConditional {
+ condition = manualControl;
+ negate = true;
+}
+
+SaveButtonAction : WOGenericContainer {
+ class = ^saveClass;
+ elementName = "input";
+ onClick = saveFunctionCall;
+ type = "button";
+ value = saveLabel;
+}
+
+SaveLabel : WOString {
+ value = saveLabel;
+}
+
+SaveLinkAction : WOGenericContainer {
+ elementName = "a";
+ href = "javascript:void(0)";
+ onclick = saveFunctionCall;
+ class = ^saveClass;
+}
+
+SaveLinkFunction : MTAjaxUpdateLink {
+ accesskey = save;
+ evalScripts = true;
+ formName = formName;
+ functionName = saveFunctionName;
+ onClick = ^onSaveClick;
+ onClickBefore = ^onSaveClickBefore;
+ onFailure = ^onSaveFailure;
+ onRequest = ^onSaving;
+ onSuccess = ^onSaveSuccess;
+ updateContainerID = saveUpdateContainerID;
+}
+
+SaveSubmitFunction : MTAjaxSubmitButton {
+ action = save;
+ button = false;
+ evalScripts = true;
+ formName = formName;
+ formSerializer = ^formSerializer;
+ functionName = saveFunctionName;
+ onClick = ^onSaveClick;
+ onClickBefore = ^onSaveClickBefore;
+ onFailure = ^onSaveFailure;
+ onRequest = ^onSaving;
+ onSuccess = ^onSaveSuccess;
+ updateContainerID = saveUpdateContainerID;
+}
+
+ScriptContainer : WOGenericContainer {
+ elementName = "script";
+}
+
+SubmitOnSaveConditional : WOConditional {
+ condition = submitOnSave;
+}
+
+UpdateContainer : MTAjaxUpdateContainer {
+ id = id;
+ class = ^class;
+ elementName = elementName;
+ evalScripts = true;
+ onRequest = ^onRequest;
+ onComplete = ^onComplete;
+ style = ^style;
+}
+
+ViewComponent : ERXWOComponentContent {
+ templateName = "view";
+}
View
4 Frameworks/Ajax/MooTools/Components/MTAjaxInPlace.wo/MTAjaxInPlace.woo
@@ -0,0 +1,4 @@
+{
+ "WebObjects Release" = "WebObjects 5.0";
+ encoding = "UTF-8";
+}
View
2  Frameworks/Ajax/MooTools/Sources/er/ajax/mootools/MTAjaxUpdateContainer.java
@@ -111,7 +111,7 @@ public NSDictionary createAjaxOptions(WOComponent component) {
options.setObjectForKey("'get'", "method");
if (options.objectForKey("evalScripts") == null) {
options.setObjectForKey("true", "evalScripts");
- }
+ }
AjaxUpdateContainer.expandInsertionFromOptions(options, this, component);
View
35 Frameworks/Ajax/MooTools/WebServerResources/scripts/core/MTWonder.js
@@ -24,6 +24,37 @@
});
+var MTAjaxInPlace = {
+
+ saveFunctionName: function(id) {
+ return "window." + id + "Save";
+ },
+
+ cancelFunctionName: function(id) {
+ return "window." + id + "Cancel";
+ },
+
+ editFunctionName: function(id) {
+ return "window." + id + "Edit";
+ },
+
+ cleanupEdit: function(id) {
+ var saveFunctionName = this.saveFunctionName(id);
+ var cancelFunctionName = this.cancelFunctionName(id);
+ if (typeof eval(saveFunctionName) != 'undefined') { eval(saveFunctionName + " = null"); }
+ if (typeof eval(cancelFunctionName) != 'undefined') { eval(cancelFunctionName + " = null"); }
+ },
+
+ cleanupView: function(id) {
+ var editFunctionName = this.editFunctionName(id);
+ if (typeof eval(editFunctionName) != 'undefined') { eval(editFunctionName + " = null"); }
+ }
+
+};
+
+var MTAIP = MTAjaxInPlace;
+
+
var MTAjaxOptions = {
defaultOptions: function(additionalOptions) {
@@ -116,7 +147,7 @@ var MTAjaxUpdateLink = {
if(elementID) {
actionUrl = actionUrl.replace(/[^\/]+$/, elementID);
}
-
+
options.url = actionUrl;
options.update = $(id);
options.__updateID = id;
@@ -251,7 +282,7 @@ var MTAjaxSubmitButton = {
request : function(form, queryParams, options) {
- var finalUrl = MTAjaxSubmitButton.generateActionUrl(id, form, queryParams);
+ var finalUrl = MTAjaxSubmitButton.generateActionUrl(null, form, queryParams);
var finalOptions = MTAjaxSubmitButton.processOptions(form, options);
new Request.HTML(Object.merge({
View
3  Frameworks/Ajax/MooTools/WebServerResources/scripts/core/mootools-core-1.4.4.js
@@ -5498,7 +5498,8 @@ Request.HTML = new Class({
if (options.filter) response.tree = response.elements;
if (options.update){
- var update = document.id(options.update).empty();
+ var update = document.id(options.update);
+ update.empty();
if (options.filter) update.adopt(response.elements);
else update.set('html', response.html);
} else if (options.append){
Please sign in to comment.
Something went wrong with that request. Please try again.