Monday March 07, 2005
Ajax webapps are cool, but non-javascript versions still needed
I think we can all probably learn a lesson from Google. I've heard that GMail is the "gold standard" for Ajax applications. If that's the case, then you should note that they've recently added a "basic HTML" link to the bottom of their pages. With this link, you can view your e-mail using the old way: Yahoo-style, no-JavaScript-needed. My guess is they added it because of demand, or simply to compete with other providers who have this feature. I think it's a good lesson though: use Ajax features in webapps where appropriate, but don't make JavaScript necessary to use your app.
A couple of Ajax features I've been thinking of developing:
- Saving forms with XMLHttpRequest: just display a success message at the top, and switch the "Cancel" button to "Done". Since the form's content doesn't change, this seems like a reasonable use of the technology.
- Switching out entire "content" <div> elements. Most of my apps have a <div id="content">, so it'd probably pretty easy to just replace that in response to button and link clicks. Of course, the hard part is having the requested server-side object load the view template, process it, and send back the content. This is probably more trouble than it's worth.
Posted in Java
at Mar 07 2005, 07:42:18 AM MST
13 Comments
Search This Site
Recent Entries
- Wine Tasting in Napa Valley
- How to build a Shot-Ski
- Bus Project Update
- Farewell to the 2011-2012 Ski Season
- Cruising around the Western Caribbean
- Spring Break!
- A Spectacular Trip to Stockholm and Madrid
- Comparing Web Frameworks and HTML5 with Play Scala at Jfokus 2012
- Play Framework 2.0 with Peter Hilton at Jfokus
- Secure JSON Services with Play Scala and SecureSocial
Hi -
Making JavaScript-only versions is definitely not the only option. I think it depends on what you are developing, who is the audience, etc. It will be cool to see if we can have components which can failback themselves.
Saving forms: This is a no-brainer, and fits into background validation. Send the info, show validation errors if that it the case, else give feedback that the form was sent. We are doing this, and it is interesting. Of course, if you DO want to change the page then you can go back to 'normal' mode, or you can send back a redirect.
Switching content: We have code that lets the server send back XML, and the client replaces the part of the dom based on an id, or content tags.
Dion
Posted by Dion Almaer on March 07, 2005 at 10:19 AM MST #
I'm looking at using this project to do the content div swapping that you mention.
Posted by Scott Mitchell on March 07, 2005 at 10:21 AM MST #
We developed a product using ajax-style of development back in '99. It was powerful, but a real pain. There were so many little problems we ran into with frames and javascript. Every browser version had its own set of quirks. It's also harder to test in an automated way. (And impossible to automatically test all browser versions.) We were forced to use a functional testing product that automates IE through COM (instead of HttpUnit because of its limited JavaScript support).
The complication of the technologies used makes clean design more difficult, I think. I like the idea of having as much of the (display) logic in Java as possible. Plus you'll find yourself jumping through hoops to get the JavaScript to work correctly for all browser versions.
We are now developing a new product and going with straight frameless HTML with as little JavaScript as we can get away with. I think our customers will be happier with us overall as we'll be able to deliver a higher quality product in less time.
We plan on emulating frames via HTML tables (or equiv) and doing field level verification on the server side. It might be a little slower, but I'd rather buy a few more servers or T-1s than add risk to our software.
No sir. You can keep that technology to yourself.
Posted by Michael Slattery on March 07, 2005 at 07:56 PM MST #
Posted by PJ Hyett on March 07, 2005 at 10:03 PM MST #
Posted by SotA on March 08, 2005 at 01:40 AM MST #
The only real problem I had was the tree which is built via a javascript library and I could get it to load dynamically into its own 'portlet' div and still work. I had a hack for Firefox but IE wasn't very helpful. I'm not a wiz as javascript yet so I'm sure there is a solution, and I've seen some suggestions elsewhere but haven't had time to persue them. Ultimately though I have thought about making the underpinnings of the UI an open source project. The backend happens to be WebWork and Velocity but that was just a personal choice.
Posted by Robert McIntosh on March 08, 2005 at 10:15 AM MST #
Posted by Michael Slattery on March 08, 2005 at 11:22 AM MST #
Posted by Robert McIntosh on March 08, 2005 at 11:31 AM MST #
Posted by Michael Slattery on March 08, 2005 at 09:39 PM MST #
> JavaScript Templates project: http://trimpath.com/project/wiki/JavaScriptTemplates
> I'm looking at using this project to do the content div swapping that you mention.
Why not just use a very small function for same thing, like this:
/** * Create function which will subtitute parameters in the template by their values. * Use construction "${expr}" to insert result of the evaluation of the expression * expr in place of the construction. * * Use unicode escapes to prevent parsing of the symbols. * * @param template a string with template * @return parsed template as function * * @author (c)1999 Volodymyr M. Lisivka */ function compileTemplate(template) { template=template.replace(/"/g,"\\\""); template=template.replace(/\n/g,"\\\n"); template=template.replace(/\$\{([^\}]+)\}/g,function($0,$1){return '"+('+$1.replace(/\\\"/g,'"')+')+"'}); var str='var f=function(params){with(params){var str="'+template+'"; return str;}}; f'; return eval(str); }Usage:
//Compile template var urlTemplate=compileTemplate('${++counter}. ${description} ${longDescription}'); ... //Use template var counter=0; var item=urlTemplate({url:'http://google.com',description:'google.com',longDescription:'Popular search engine.'});Result:
A variant with construction to allow emebeded javascript a bit larger so I don't include it here. (Copied from my JavaScript Server Pages project which is under LGPL license).
Posted by Volodymyr M. Lisivka on March 09, 2005 at 11:12 AM MST #
Posted by Volodymyr M. Lisivka on March 09, 2005 at 11:14 AM MST #
function compileElement(elementId) { //Get element by it ID var element=document.getElementById(elementId); //Use inner HTML of the element as template var template=compileTemplate(new String(element.innerHTML)); //Create function to replace content of the element by the filled template var f=function(params){ var str=template(params); element.innerHTML=str; }; return f; }so you can write HTML with parameters:<div id="userNameFields"> <input type="text" name="firstName" value="${firstName}" /> <br/> <input type="text" name="lastName" value="${lastName}" /> <br/> </div>then compile it:userNameFields=compileElement('userNameFields');and then just call it when needed:userNameFields({firstName:'Volodymyr', lastName:'Lisivka'});It is very pretty in conjuction with JSONRPC.Posted by Volodymyr M. Lisivka on March 09, 2005 at 11:46 AM MST #
Posted by Robert McIntosh on March 09, 2005 at 12:01 PM MST #