Changes for page Alternative Technologies-Ruby on Rails
Last modified by Pascal Robert on 2007/09/03 20:53
From version 5.1
edited by Quinton Dolan
on 2007/08/28 18:02
on 2007/08/28 18:02
Change comment:
Minor formatting changes
To version 8.1
edited by Marc Guenther
on 2007/08/28 08:59
on 2007/08/28 08:59
Change comment:
small reformat to make more readable
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. qdolan1 +XWiki.marc - Content
-
... ... @@ -22,12 +22,12 @@ 22 22 23 23 {{code}} 24 24 25 -textarea: WOText 26 -{ 27 - id='wysiwyg'; 28 - name='wysiwyg'; 29 - value=textValue; 30 -} 25 + textarea: WOText 26 + { 27 + id='wysiwyg'; 28 + name='wysiwyg'; 29 + value=textValue; 30 + } 31 31 32 32 {{/code}} 33 33 ... ... @@ -41,11 +41,11 @@ 41 41 42 42 We haven't used a lot of JavaScript at www.marketocracy.com, for a very simple reason: We don't have the testing staff to fire up 10 different browser variations to test the site. And lets face it, programming in JavaScript sucks. 43 43 44 -Since someone invented that cool acronym though, that's changing. You would think it shouldn't matter that something has a name, but it does. I remember when the GoF Design Patterns book came out. There was nothing in there I hadn't figured out on my own, but now they had a name! 44 +Since someone invented that cool acronym though, that's changing. You would think it shouldn't matter that something has a name, but it does. I remember when the GoF Design Patterns book came out. There was nothing in there I hadn't figured out on my own, but now they had a name!//I//could//say//"Singleton"//to//my//co-workers//and//they//would//know//what//I//was//talking//about.//I//could//buy//a//junior//engineer//the//book,//and//he//would//soon//be//programming//at//a//much//higher//level.// 45 45 46 -So 46 +So//having//a//name//helped,//and//the//result//is//that//there//are//a//lot//of//cool//toolkits//out//there.//Since//someone//else//wrote//the//JavaScript,//that//means//I//don't//need//to//test//10//different//browser//variations.// 47 47 48 -Which 48 +Which//means//I//can//make//the//site//much//easier//to//use//and//more//interactive.//Huzzah! 49 49 50 50 ==== Research ==== 51 51 ... ... @@ -53,22 +53,22 @@ 53 53 54 54 It's not that Rails rocks with Ajax, its that the Prototype Javascript library rocks. The documentation makes a big deal about doing Ajax with one line of code. 55 55 56 -{{code value="xml"}}56 +{{code}} 57 57 58 -<div id='<= posting.id'> 59 - <%= link_to_remote [div to update] [link options] -> %> 60 -</div> 58 + <div id='<= posting.id'> 59 + <%= link_to_remote [div to update] [link options] -> %> 60 + </div> 61 61 62 62 {{/code}} 63 63 64 64 The reality is that all Rails is doing is writing one line of JavaScript. From the Ajaxy "rating" code I've been adding to my app, look at the following: 65 65 66 -{{code value="xml"}}66 +{{code}} 67 67 68 -<div id='<WEBOBJECT name=postingID></WEBBOBJECT>'> 69 - <a href="#" onclick="new Ajax.Updater('<WEBOBJECT name=postingID></WEBBOBJECT>', 70 - '<WEBOBJECT name=ratePosting></WEBOBJECT>', {asynchronous:true, evalScripts:true}); return false;">1</a> 71 -</div> 68 + <div id='<WEBOBJECT name=postingID></WEBBOBJECT>'> 69 + <a href="#" onclick="new Ajax.Updater('<WEBOBJECT name=postingID></WEBBOBJECT>', 70 + '<WEBOBJECT name=ratePosting></WEBOBJECT>', {asynchronous:true, evalScripts:true}); return false;">1</a> 71 + </div> 72 72 73 73 {{/code}} 74 74 ... ... @@ -80,7 +80,7 @@ 80 80 81 81 {{code}} 82 82 83 -new Ajax.Updater( elementid, url, options) 83 + new Ajax.Updater( elementid, url, options) 84 84 85 85 {{/code}} 86 86 ... ... @@ -90,8 +90,8 @@ 90 90 91 91 {{code}} 92 92 93 -postingID: WOString { currentPosting.primaryKeyString; } 94 -ratePosting: WOActionURL { see discussion } 93 + postingID: WOString { currentPosting.primaryKeyString; } 94 + ratePosting: WOActionURL { see discussion } 95 95 96 96 {{/code}} 97 97 ... ... @@ -99,21 +99,21 @@ 99 99 100 100 {{code}} 101 101 102 -ratePosting :WOActionURL 103 -{ 104 - directActionName="PostingRater"; 105 - ?pkey=currentPosting.primaryKey; 106 - ?rating=cRating; 107 - ?wosid=NO; 108 -} 102 + ratePosting :WOActionURL 103 + { 104 + directActionName="PostingRater"; 105 + ?pkey=currentPosting.primaryKey; 106 + ?rating=cRating; 107 + ?wosid=NO; 108 + } 109 109 110 110 {{/code}} 111 111 112 112 This produces a result similar to Rails, because in rails you have to define an action for each class of link. In my case I tie directactions to pages/components, so my "PostingRater" page would return component-level HTML (minus any HEAD/BODY tags) that matched the existing <div> definition. Since we're using WebObjects, that turns out to be trivially easy if we build the enclosing <div> tag with a component PostingRater can just look like: 113 113 114 -{{code value="xml"}}114 +{{code}} 115 115 116 -<WEBOBJECT name=RatingDiv></WEBOBJECT> 116 + <WEBOBJECT name=RatingDiv></WEBOBJECT> 117 117 118 118 {{/code}} 119 119 ... ... @@ -121,7 +121,7 @@ 121 121 122 122 {{code}} 123 123 124 -ratePosting: WOActionURL { action=ratePosting;} 124 + ratePosting: WOActionURL { action=ratePosting;} 125 125 126 126 {{/code}} 127 127 ... ... @@ -129,14 +129,14 @@ 129 129 130 130 {{code}} 131 131 132 -public WOReponse ratePosting 133 -{ 134 - currentPosting.ratePosting(currentRating); 135 - return self; // since this is called from JavaScript 136 - // return just myself, not self.page 137 - // this will tell WO to render only 138 - // this as a result. 139 -} 132 + public WOReponse ratePosting 133 + { 134 + currentPosting.ratePosting(currentRating); 135 + return self; // since this is called from JavaScript 136 + // return just myself, not self.page 137 + // this will tell WO to render only 138 + // this as a result. 139 + } 140 140 141 141 {{/code}} 142 142