Better Web Apps With Ajax
An anonymous reader wrote to mention an article on IBM's site detailing the fundamentals of Java-based Ajax. From the article: "This article gives you a good understanding of the fundamental principles of Ajax, and a nuts-and-bolts knowledge of the client and server side components that participate in an Ajax interaction. These are the building blocks of a Java-based Ajax Web application. In addition, you will be shown some of the high-level design issues that come with the Ajax approach."
Cleaner code than the rest!
I'm glad to see another serious technical article on the pros and cons of implementing an AJAX solution. Most everyone who says the acronym "AJAX" usually falls into one of two camps - either the "OMFGZ teh AJAX is so amazing! It will change the interweb!" How? Oh, it allows parts of the page to be updated without a refresh. How interesting. Perhaps you could go a little more in-depth? No? Thanks...
The other camp... too many Slashdotters, IMO... feel the need to flex their superior understanding of the fundamental dynamics of the internet and development and offer this gem: "AJAX is just an assortment of pre-existing technologies. Nothing to see here".
The automobile was just an assortment of pre-existing technologies, and it radically changed the world. It also introduced a whole bevy of new challenges, both technical and otherwise, that we still haven't fully figured out yet. It was not a transportation panacea, and AJAX is no cure-all. But just because it doesn't solve every problem doesn't mean it doesn't have the power to be revolutionary.
Rex is 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Atlas is Microsoft's entry into the suddenly-popular-even-though-it-has-been-around-fo r-7-or-more-years AJAX trend.
Atlas is a set of extensions to ASP.NET 2.0 that allows for web developers to use AJAX with little or no plumbing work on their part.
It integrates with ASP.NET extremely well and maintains the "event driven" style that ASP.NET is known for.
There is also a Channel 9 video about what Microsoft is doing on the AJAX front elsewhere.
I have been using "AJAX" for almost 8 years now. Even back with IE4 you could use the XMLHTTP object to make "background" XML requests to the server, process the XML on the client and then modify the UI client side. Old hat. It is nice to see they finally have a name for it. Now maybe Microsoft will get rid of that crappy "server-side click" stuff and integrate this into .NET
Ya sorry but everyone knows that to obtain Buzzword Fad Certification (TM) AJAX *must* be coupled with Ruby on Rails, an Agile Development Model and legendary programmer Bill Brasky. Java does not fit in that picture (although apparently Brasky once coded a complete J2EE Web commerce framework in one hand on his BlackBerry while siring a child with his best friend's wife ... that framework launched a little site called Half.com).
...use JSON-RPC instead. XML is longer and hard for a javascript interpreter to interpret. Why does everyone want to use it as a wire protocol? I've never understood this. It makes a lot more sense to me to just store everything as a javascript hash.
Anyway, unlike the almost most ajax libraries, which are at this point almost totally devoid of docs, the guy who wrote a JSON-RPC library actually tells you how to use it. If you've got java, its the way to go, I think. Here it is.
Personally, I'm a perl monger, so I use this lib, which isn't nearly as good, as you have to do most of the javascript stuff yourself. Faster than XML though, and its still rather trivial to turn a DOM object into a plain javascript one for use with JSON.
Mod me down and I will become more powerful than you can possibly imagine!
I much prefer a seaside solution.
--
The "are you a script" word for today is platform.
almost as though there was nothing there. Except the concept...
By the by, from the IBM site:
> Server load
>
> Implementing an Ajax UI in place of a regular forms-based one may dramatically
> increase the number of requests made to the server.
Will be interesting to see how it responds to a slashdotting...
Why? Less verbose (easier on bandwidth) and no parsing (ever tried parsing XML using XmlHttpRequest? It sucks). JSON is object syntax. It is a real, live object serialized to string.
It just so happens that JSON is also legal Python object notation.
Hmmm... GMail, Google Maps, Google Suggest... none of these use XML. Google is also renowned for using Python. JSON syntax is the same in client-side javascript and server-side python... hmmm... makes me think twice, anyway, instead of drinking the web services kool-aid Sun and Microsoft are serving.
I don't know if anyone has noticed, but digg.com seems to be much better with the stories than slashdot. I saw this on there a day or two ago. No dupes either!
So what happens when a java applet is inside a java browser? Java in Java? That can't be efficient.
ModLife.Net - If it ain't modded, what's the point?
revolutionary or not, "AJAX" is now used in lots of languages. and there are some good tools out there. there's ruby on rails with the prototype library which is also now available in perl. there's also CGI::Ajax which is pretty simple to apply... and it's perl!
There's been an interesting discussion on the Erlang mailing list about a possible AJAX implementation. http://www.erlang.org/ml-archive/erlang-questions/ 200509/msg00282.html http://www.erlang.org/ml-archive/erlang-questions/ 200509/msg00320.html
Also interesting on the IBM site is a comparison between the use of J2EE and Ruby on Rails, another great way of achieving Ajax functionality.
AJAX Security
Believe me, if I started murdering people, there would be none of you left.
Why not just use Echo2 and not have to worry about the details of an AJAX implementation for Java? I generally prefer not to reinvent the wheel, and with all of the various browser quirks with respect to AJAX, that's quite a non-trivial wheel to try and recreate.
"First off, I HATE XML. It's overly verbose and wastes tons of bandwidth."
Shhhh! Don't anyone tell him about server-side compression/ Client-side decompression. He hates XML so much. You'd be wasting your breath.
Sure XML is bloated but the kind of XML a developer will want to come back to a web page is unlikely to be. What would it contain?
Well obviously the data to go on the page. In addition to that, probably some meta-data to tell the browser where to put that data on the page. And that's it.
The data coming back from the server is unlikely to be any more bloated than what would have been sent in a standard HTTP response, possibly less bloated - after all if you already have a page hierarchy set up there's no need to send another one down the tube.
My gut feeling is that people will read these pages and decide whether or not AJAX is a "good thing" or not from what they read here, rather than RTFA. I'm not advocating censorship but I do think given the choice of forcing javascript developers to write an LDIF parser or getting them to use the built-in XML parsing capabilities, XML would win out for sheer convenience. Though watching them try to write an LDIF parser would be amusing...
I do some parsing. But instead of XML, I use the HTTP-headers format.
My-var1: Something
My-var2: (Something_base64_encoded)
Has been pretty useful for me.
Does anyone have any real world experience with either DWR or JSON? I'm curious to hear what others think.
While I would like to agree with you, and in terms of information density, XML is pretty fluffy if you go in for descriptive entity tags and all.....its more complicated than information density.
I have written a few XML parsers and developed around Xerces and IBM xml/dom libraries and even written a parser generator code. What I eventually realized was that though the wires had to carry fatter messages, I had to write less code. Why? Regularity of the brutally simple grammar at the heart of XML and the hand-in-glove fit of nested structure and recursive languages means you can be very effective a developing and reusing XML handling objects. You won't notice this on your first project, maybe your second and for sure by the third one. Humans don't have to read the darn XML, programmers do. And we all know into which of those two species the preponderance of bill payers fall.
SLASHDOT: news for people who can't concentrate on work or have no life at all and got tired of yelling back at the TV.
TrackIt is an application that takes advantage of all of the above technologies.
There's a pretty good library I've used recently called DWR.
If you're looking for a Java library to do some of the heavy lifting, check it out.
Check out the new cal for Hula http://hula-project.org/Hula_Server - amazing work.
And the front end to the webmail for Zimbra http://www.zimbra.com/
Really, really nice stuff.
bad_outlook
--
Is this vague enough for you?
<head>
<title>Ajax app</title>
<script type="javascript" src="ajax.js">
</head>
<body onload="ajaxInit()">
<noscript>
We are very sorry but we, the developers of this website don't understand the web. We would like to provide a non-script alternative for the visually impaired, disabled and people with security smarts but "Ajax" is the future of the interweb and you are not. If you do happen to be visually impaired, disabled or security conscious then fuck off because we are too busy fapping to the latest buzzword to give a shit about you.
</noscript>
</body>
</html>
Anyway, yes I know this stuff has been around for years, but it's always been a bit hairy to implement and there were NO standards (kind of where ORM was before Hibernate and iBatis, etc.). This really could be more than a new 'fad' and allow developers to rapidly build dynamic apps based on common standards (think supportable, appliable, and extendable).
Spellchecker? We do not need no stinkin' spellchecker!!!
I made a little window-manager-esque thing in Javascript/CSS/HTML a few weeks ago (Looks messed up in IE, works fine in Firefox)
http://dugnet.com/klown/ajwm/, all that's needed are some AJAX functions to swap out the contents of each window, instant freakish web-app thing..
If you don't like the XML in Ajax, try JSON (JavaScript Object Notation). With JSON you can implement Ajax without all the XML bloat. Ajax is more about the Asynchronous than it is about the XML. So Ajax without the XML and with JSON is... AJAJ?
[signature]
brand name?
Here we have a detailed, in-depth article about client-side browser XML processing that doesn't once mention XSLT. If you're writing JavaScript to transform your XML responses into updated client-side HTML by manipulating your browser's DOM, you probably should be listening to those who are recommending nonstandard-but-terse formats for data interchange.
And while we're on the subject of terseness: complaints about "bloated" XML are meaningless outside of a context that takes the application's overall bandwidth requirements into account. Is an XML document bigger than a binary data stream? Sure. Is this significant? Depends on your application.
Maybe you should try again? There is no forced reg (I don't recall every seeing one in fact) and the content is very good IMO.
No, I did not read the f***ing article!
First, Unicode under JSON is abit exciting. In XML there are no surprises.
Secondly, XML is transported over HTTP 90% of the time.
Almost all modern HTTP implementations implement GZIP as an encoding. If you don't already have this enabled in your servers, then you don't really care about bandwidth utilization.
JSON offers nothing useful over XML+GZIP (which is a transport/encoding issue anyway). It can, however, make it vastly more difficult to interchange your data and tie you to a limited object model. If anything, I support the process used by the W3C. I like their standards. JSON is nice, but not nice enough. Sorry guys.
Learn XML. Learn XPATH. Try to use Twisted's XMLSTREAM implementation for a taste of how easy and flexible it can be. Write some Jabber apps. JSON can't really be in those spaces. Not anytime soon at least.
I think Mauve has the most RAM. --PHB (Dilbert Comic)
It's not "aha"!!!
Since everyone else is mentioning their favorite AJAX toolkit, I'll list one too:
x .html
http://javawebparts.sourceforge.net/javadocs/inde
This is a component of the larger Java Web Parts project called AjaxTags. It's a taglib that allows you to easily add AJAX functionality to arbitrary page elements in a purely declarative manner, i.e., *NO* coding on your part (although there is more capability there if you need more). It really makes AJAX a breeze, and is pretty powerful at the same time. If you are a Java web developer, have a look, you may very much like what you see!
P.S., The parent projects' page is here:
http://javawebparts.sourceforge.net/
If a pion (n-) collides with a proton in the woods & noone is there to hear it, does lamdba decay into the source pa
You stupid asshole, if you hate xml then do this:
<stuff>whatever_data_you_want_here</stuff>
You really think that is going to take a long time to parse? You fucking idiot, you are too damned stupid to be a developer if you couldn't think your way out of that wet paper bag. I'm sick of you dumb shits pissing on every idea.
There's a recent article on MSDN that talks about Ajax on ASP.Net:= /library/en-us/dnaspp/html/ASPNetSpicedAjax.asp
http://msdn.microsoft.com/library/default.asp?url
AJAX!!1
random underscore blankspace at ya know hoo dot comedy.
Now, that's even lighter and faster than GZIP+XML!
random underscore blankspace at ya know hoo dot comedy.
When we can do that, we'll know this "Web 2.0" is really here finally.
random underscore blankspace at ya know hoo dot comedy.
Does anyone know of any AJAX toolkits targeted towards PHP developers? I am currently working on a project that could definately gain a lot from AJAX.
Anthony Papillion
Advanced Data Concepts, Inc.
"Quality Custom Software and IT Services"
For me (I am the author of japano, an MVC/JSP engine also containing dynamic javascript integration features), the following additional principles are were important:
while (!asleep()) sheep++
Why does the Java applet security model require a browser user to set a value in their "Java Control Panel" (or other security policy equivalent), just to allow a browser to use URL class communications via a Proxy object that points at the server from which the applet was served? I'm talking about security exceptions on URLConnection.openConnection(Proxy). Stopping connections to any other host makes sense, because that could be a host within the client's firewall. But what's the point of stopping another connection to the applet's server, which could have sent whatever it wanted embedded in the applet itself? Requiring that manual security change discards the entire applet "zero install" convenience of software distribution. Which is Java's main benefit for client apps.
// Get the MIME type of the object at the URL.
) ;
This code:
String getMIMEType(URL linkURL)
{
HttpURLConnection linkConnection;
String contentType = "";
SocketAddress addr = new InetSocketAddress("appletServer", 6666);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
try
{
linkConnection =
((HttpURLConnection)linkURL.openConnection(proxy)
System.out.println("lC: " + linkConnection.toString()
+ "; C-T: " + contentType);
System.out.println("using proxy: " +
linkConnection.usingProxy());
contentType = linkConnection.getContentType();
}
catch (IOException e)
{
System.out.println("IO Exception: can't connect to "
+ linkURL.toString() + ": " + e.toString());
}
}
just fails to report that it's using the Proxy. Because it isn't. What a pain.
--
make install -not war
AJAX beats JSON when the JavaScript standard includes a XML parser.
Bindows (note the B) is a pretty cool framework for AJAX. It can be downloaded for free for educational/research purposes http://www.bindows.net./ For commercial it's $695. No, I don't work for them, and am not slashvertising. I haven't ever heard any mention of it on /. and wondered if people just don't know of it or don't like it. I'm writing a .NET backend (will be GPL eventually) for it that will make client-server more seamless. Automatic event hook-ups, state-syncs, etc.
The article doesn't say whether this is Telamonian (Great) or Oilean (Little) Ajax. D'oh!
It seems that web geeks are so pleased with themselves that they can now have web applications which dynamically update, without having to redload the page.
Now, I may be dim, but I understood that most computer applications could achieve this around thirty years ago??
Doh!
Who is this delectable creature with an insatiable love of the dead?
"Its not just for XML and its not just a J language either... Ruby will do."
No, XML isn't really a requirement of functionality. If by J you mean a Java backend, you are correct, but not if you mean Javascript Without Javascript you cannot have AJAX-like functionality unless you use a plugin or browser addon like JRE, Flash, etc.
I just wanted to clarify this point to those who might take that statement the wrong way. Coding something in C++ that talks to a server is not AJAX, for instance. AJAX, imho, is defined by 3 characteristics.
1. AJAX involves dynamic content, not static content. This means that there is a seemless interaction, without the application appearing to "reload".
2. AJAX involves a stand alone web browser or an embeded web browser that is running the common scripting language Javascript.
3. AJAX involves data retrival from a source outside of the client-side application itself, and does not solely use data embedded in the application itself.
I could refine those a bit, but I think the general ideas come across. So, really, a Java applet embeded in your browser that talks to the server, such as an IRC chat client, is not AJAX, though it may provide AJAX-like functionality. The language of the backend is irrelevant; the data formats are irrelevant. The only relevance, really, is that you are taking something that has generally been static (web pages) and made the operate like a fully functioning application. It's the transition from "Information" (HTML) to "Application" (AJAX).
The definition really can't go beyond this. If it isn't limitted to seemless dynamic content, you could call any webpage that contained Javascript AJAX. If it isn't limitted to browsers and Javascript, then you could call an SSH program, chat applet, multiplayer game XBOX game, etc. "AJAX clients". If it isn't limitted to outside data, then you'd have to call Javascript clocks AJAX. An application must (at least) satisfy these three conditions before it can be called AJAX. If it doesn't, it may still be a really good interactive and dynamic application, though not AJAX.
The core of AJAX, XMLHttpRequest, is the only place I think the term XML is validated in the AJAX acronym. And, certainly, you can load any type of data you wish with it. If there was any single thing to define AJAX, it is this command. Without it (or something like it coded in a round about way... who knows, some people like the challenge) you cannot satisfy all 3 conditions.
I8-D
I've used AJAX successfully on one corporate site, but for most of my sites I find the dynamic content looks cool, but is impractical as the user can't bookmark the results of their selection - or copy and paste the link to their friends.
ie. google maps has to have the "Link to this page" hyperlink
OK for them, not really ok for my fledgling sites.
The best use I've found for it so far is loading data into select boxes, especially in linked select boxes when narrowing. That actually looks great.
I really want to find a creative use for this tech in the future, I've been trying to innovate. eg. Interactive polls on the front page perhaps, real time comments... all without the page updating. A lot of possibilities, but of course I always have to try and make things useful to the client rather than using it as a way to show off.
generic
More on AJAX and accessibility can be found here: AJAX and Accessibility.
Standards Schmandards
XPATH is barely cross browser (only through gigantic JavaScript libraries like Sarissa). JSON is useful because you don't have to parse it using a clunky JavaScript DOM interface. XML is great, but for my web apps, I appreciate the efficiency and simplicity of JSON.
You know what's human readable? LDIF.
Can I pull information from LDIF with simple XPath expressions? Can I transform it into another format with XSLT? Does it use the DOM API I already have experience with? Can I style it with CSS?
There's this thing called "the network effect". The more people use a standard format, the more valuable it is. XML might have a few minor downsides, but the fact that so many people use it means that the wealth of tools and software that works well with it is far more important than a few bytes shaved off here and there.
it still feels like bloat. You ever look at a raw SOAP request?
Congratulations, you've found one example of a bloated XML document type, and assumed that the same is true of every XML document type. That's simply not true. SOAPs a mess. XML in general isn't.
So far it's been great. Very easy to add to add to a project, well documented, light-weight. It makes AJAX so easy.
For testing and exploring, there's an interactive web page generated automatically by the servlet. From those pages you can see exactly which classes and methods you have access to! From there you can even call your server side methods interactively. Look ma no code!
http://frank@franklinharper.com/
So far it's been great.
DWR is very easy to add to add to a project, well documented, and light-weight. It makes AJAX so easy because javascript stubs are generated automatically for the Java classes you decide to export.
For testing and exploring, DWR creates an interactive web page generated automatically by the DWR servlet. From those pages you can see exactly which classes and methods you have access to and the number of parameters required! From there you can even call your server side methods interactively.
Look ma no code!
http://frank@franklinharper.com/
What's "distrubting" to me is your peculiar spelling...
Is there a way in Java script, or another implementation of this technique, that will trigger an update after a given time interval? OK, I can look this up myself (and will), but was wondering if anyone has done this to create a live page.
You only use 2% of your DNA
The simplest trick I remember was to use the innerhtml property of hidden divs, and write var data there, and then use a timer in the JS to load it up.
I still use that trick as it's a good replacement for session cookies when you really don't want to code a any backend scripts or mess with cookies for some little "play page".
I8-D
Ajax is a fine integration platform. We here at Lightspoke have adopted this framework for our own web-based database. Since then scores of customers have used this capability to extend our database to their existing web sites. We spent a lot of time figuring out the performance aspects - a sort of Ajax for the real world if you will. We need more articles on using Ajax in real settings - best practices, case studies, lessons learned. Integration is the key to eeking ever last but of value out from our existing technology investments. I believe our customers would be the first to agree to that.
Lightspoke Web Based Database