{"id":71,"date":"2006-11-13T10:05:49","date_gmt":"2006-11-13T09:05:49","guid":{"rendered":"http:\/\/www.paullynch.org\/blog\/?p=71"},"modified":"2006-11-13T10:05:49","modified_gmt":"2006-11-13T09:05:49","slug":"simple-ajax-for-webobjects-without-project-wonder","status":"publish","type":"post","link":"http:\/\/www.paullynch.org\/blog\/?p=71","title":{"rendered":"Simple AJAX for WebObjects &#8211; without Project Wonder"},"content":{"rendered":"<p>Probably the simplest Ajax effect that I can think of that is desirable to add to web applications is to cause login boxes to &#8220;shake&#8221;, just like real computer login panels do, on a failed login.  This is one of the few situations where a simple animation effect (too simple to qualify for Ajax, really) has a significant value.  I&#8217;ve been doing this in projects for quite a while now.<\/p>\n<p>The first stage is to find and install some suitable javascripts to implement Ajax.  A popular set is the Scriptaculous and Prototype libraries.  First find and install them from: http:\/\/script.aculo.us\/.  Take a look at the &#8220;effects engine&#8221; demo page to see what we are getting into.<\/p>\n<p>Assuming that you have a reasonably standard page set up, the process for adding this shake effect is simple.  What is going to happen is that a script will execute when your page is loaded after the failed login attempt.  For this, just drop a script onto the page with the content that will invoke the effect; it will execute on load.<\/p>\n<p>To make this happen, you need to make some minor changes to your java component for the page.  Add the following few lines:<\/p>\n<p><code>protected String onload;<\/code><\/p>\n<p><code> <\/code><\/p>\n<p><code>public void awake() {<br \/>\nonload = \"\";<br \/>\n}<\/code><\/p>\n<p>Then you need to set this string appropriately when your login fails:<\/p>\n<p><code>onload = \"new Effect.Shake(loginbox)\";<\/code><\/p>\n<p>Time to update the component wo to activate the effect:<\/p>\n<p>Add to the wod file:<\/p>\n<p><code>Onload: WOString {<br \/>\nvalue = onload;<br \/>\n}<\/code><\/p>\n<p>And in the html file, you will want to add your Ajax libraries.  In &lt;head&gt;\u00c2\u00a0insert:<\/p>\n<p><code>&lt;script src=\"\/javascripts\/prototype.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt; &lt;script src=\"\/javascripts\/scriptaculous.js\" type=\"text\/javascript\"&gt;&lt;\/script&gt;<\/code><\/p>\n<p>The hardest part is going to be to isolate the part of the page that you want to shake.  Luckily, most old login panels consist of a table in the middle of the page; add an extra attribute to the table: id =&#8221;loginbox&#8221;.  If you don&#8217;t have a table for this, you can add a div with the id set, but not all html elements will shake.<\/p>\n<p>Finally, add in anywhere in the body:<\/p>\n<p><code>&lt;script type=\"text\/javascript\"&gt;&lt;!-- &lt;webobjects name=\"Onload\"&gt;&lt;\/webobjects&gt; \/\/ --&gt;&lt;\/script&gt;<\/code><\/p>\n<p>I normally add this at the end.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Probably the simplest Ajax effect that I can think of that is desirable to add to web applications is to cause login boxes to &#8220;shake&#8221;, just like real computer login panels do, on a failed login. This is one of the few situations where a simple animation effect (too simple to qualify for Ajax, really) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[19,23,24,29,35,38],"class_list":["post-71","post","type-post","status-publish","format-standard","hentry","category-programming-for-apples","tag-html","tag-java","tag-javascript","tag-prototype","tag-scriptaculous","tag-webobjects"],"_links":{"self":[{"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=71"}],"version-history":[{"count":0,"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/71\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.paullynch.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}