nextwebgen.com

The Next Generation Web Now

Build an RSS Feed Reader using Ajax and PHP

Filed under: Web 2.0 News, Front Page, Programming, Ajax, PHP — Chris Cornutt at 9:56 am on Wednesday, August 2, 2006

ScratchProjects.com has posted both Part one and Part two in a new tutorial series, this time with a focus on creating a RSS feed reader by combining PHP and Ajax.

In Part one they lay the foundation, explaining how the tutorial will work, what the parts are, and what the parts do. Then, it’s on to the code, showing first how to fetch and parse the remote feeds and create the DIV the results will be dropped into.

Part two takes the next steps and creates the form to add a feed to be parsed, the functionality to insert it and its information into the database, and to grab the list of feeds from the database and read in the contents.

It’s a pretty basic tutorial, but great for those just starting out with this handy, powerful functionality. It requires a bit of knowledge about PHP, but most of the code needed is spelled out for you. Plus, you can download the code as well.

Cross Domain XMLHttpRequests using an IFrame Proxy with Dojo

Filed under: Web 2.0 News, Front Page, Programming, Dojo — Chris Cornutt at 8:12 am on Wednesday, August 2, 2006

On the Dojo Toolkit blog today, there’s a pointer to information about the library’s latest built-in ability - making cross-domain requets using an iFrame proxy.

As of today, the Dojo codebase can do cross domain XMLHttpRequests (XHR) using an iframe proxy. Note that this is not using Flash or a server side proxy — it is pure JavaScript and HTML. A set of iframes (one local, one cross-domain) are used to serialize the XHR information using URL fragment identifiers.

They link to more information about this new feature, including the background of why it was added, the technologies behind it, security considerations and a bit of code to show you how it’s done.

Creating an Ajax Login Page with Dojo/Zend Framework

Filed under: Web 2.0 News, Front Page, Programming, PHP, Dojo — Chris Cornutt at 8:14 am on Monday, July 31, 2006

Alexander Netkachev shows, in this new post on his site, how to create an Ajax-based login page with the help of the Dojo library and a new offering from Zend - the Zend Framework. The Zend Framework is a MVC-based framework written in PHP.

A few days ago I understood the right usage of the framework. Frankly speaking, it does not help with creating Web forms—it has no high-level complex components like TDataGrid in PRADO or even Repeater in ASP.NET. And what I understood is that it is not Zend Framework’s business how developers are creating their forms and here is a reason for this: modern pages are created with a lot of JavaScript and, I believe, are created with client-side components, not server-side.

He set this mission before himself - to create a lightweight Ajax form combining Dojo and the Zend Framework in the easiest way possible.

He assumes you already have both libraries installed (both relatively simple to get working) and gets straight to the code. First off is the creation of the view for the login form itself, the place where the Dojo toolkit is included and the Javascript functionality lives - as well as the simple login form. Next up is the controller for the PHP side, with three actions - a default action, one to perform the login, and the other to show a success message. Finally, there’s the Dojo javascript to make the request to the backend and the PHP script to validate if the username and password are correct.

Cross-site Ajax (from OSCON 2006)

Filed under: Web 2.0 News, Front Page, Programming, Ajax — Chris Cornutt at 3:35 pm on Thursday, July 27, 2006

Kevin Yank, SitePoint’s “reporter in the field” at this year’s OSCON has a new post on the SitePoint Web Tech blog with information and his impressions about a talk given by Joseph Smarr, a Plaxo developer on cross-site Ajax.

Mashups, if you’ve been living under a rock, are web applications built by combining services provided by several specialized web applications, typically using AJAX as the glue. One of the main challenges faced by developers of mashups is the same-origin policy, which prevents JavaScript on one site from contacting other sites as a security measure. For mashups to really work, developers need to find a way around that restriction.

Kevin talks about some of the solutions that have been found to the problem - a server-side proxy, a Flash application proxy, JSON-P - but all have issues surrounding their use. They don’t quite fit in elegantly with the rest of the strong, flexible code around them.

So, is there a solution? Does Plaxo have the answer? They might, but it’s still a bit of a work in progress. As Kevin calls it, it’s a “Javascript wormhole”, a method to tunnel through pages when a service is called and closed when done. There’s even a suggestion of how it might flow, using iframes and callbacks to make it happen. There are still issues surrounding it (not just in its creation, but in its use), but things are looking brighter.

Ajax and the Spring Framework with TIBCO General Interface

Filed under: Web 2.0 News, Front Page, Articles, Programming, Examples, TIBCO — Dietrich Kappe at 2:49 pm on Thursday, July 27, 2006

Brian Walsh has written an exceedingly well documented tutorial on combining Spring MVC, XStream and TIBCO GI. The focus is on using GI at the view layer while making only incremental changes to an existing Spring MVC application (the application from the Spring MVC step-by-step tutorial in this case, which you'll have to step through before you go on to the GI tutorial):

Application owners and developers alike predictably want to increase productivity and reduce time to market. This type of rapid implementation gives us several imperatives:

  • No wholesale replacement of our Spring investment.
  • Incremental change of existing server code as opposed to wholesale change to, for example, SOAP Web services
  • Continued support for non-Ajax clients
  • Re-use of existing code wherever we can. Develop the GI application along side the JSP layer.

Since GI generates the view at the client, Spring need no longer generate HTML at the server. Instead, we'll modify our Spring configurations such that Spring can also return raw data in form of XML that can be consumed as a service by the Ajax processes in GI.

The tutorial is generously illustrated with sequence diagrams, annotated configuration files and screen shots. It shows how to replace the HTML rendering logic of the existing application with an XStream-based logic that transforms the model into XML. (If you haven't looked at XStream yet, you really should. It's a clever library that allows you to serialize and deserialize objects to and from XML with a few lines of code.) All of the rendering is handled by GI in the client now, including degrading gracefully for non-AJAX clients.

The tutorial also serves as a lesson in how the development of web applications will change when WYSIWYG, component GUI interface tools become involved. The story board before-and-after shots of the UI in particular suggest some of the artifacts that might be produced in legacy web to AJAX migrations.

tibcogi.jpg

Planning an Ajax Boot Camp

Filed under: Web 2.0 News, Front Page, Programming, Workshop — Chris Cornutt at 8:18 am on Wednesday, July 26, 2006

In an effort to help budding Ajax developers out there (or somewhat seasoned ones looking for a refresher), Eric Pascarello is organizing a series of “Ajax Boot Camps” to help show them the way.

I have been helping people work with Ajax applications since Ajax has become popular. My goal was to create a course that will teach any serverside developer how to code a maintainable and scalable Ajax solution. A lot of tutorials out there that developers are using are full of bad practices.

He talks more about his goals for the training courses, things like:

  • what is the consequences of not using caching on the client?
  • what happens with session?
  • what causes that memory leak?

His plans for the boot camp currently include two days of lecture and hands-on programming, but the locations of the camps haven’t been selected. If you’d like to have one of the camps come around to your area, send him an email and let him know!

Rediscovering Flyweight for Javascript

Filed under: Web 2.0 News, Front Page, Editorial, Programming — Michael Mahemoff at 6:05 pm on Tuesday, July 25, 2006

We posted about memory problems the other day (“the biggest Ajax problem” :-) and while it’s always good practice to clean up, another good practice is to avoid allocating excessive memory in the first place. To that end, I’ve recently been experimenting with the Gang Of Four Flyweight pattern within Javascript.

Flyweight works like this. Instead of creating an object for every entity, we only allocate a “Flyweight” object only for every type of entity. Because these Flyweight objects don’t have internal, object-specific, state, we have to pass a little context each time. It’s a compromise to cut down on memory. Flyweight often rears its head when you have some kind of object pooling (e.g. stateless session EJBs).

The pattern works well with Ajax apps, where the DOM already holds a lot of context, since we’re displaying that for the user. So I just need to pass in an element (or an element ID) as the context, and the Flyweight object will get the actual state of that element by reading its DOM properties.

To use the canonical blog example, we can have two kinds of comments - ManualComments and TrackbackComments. Assuming this is an Alpha blogger who gets 200 ManualComments and 50 TrackbackComments after posting that it’s cloudy outside, we would have a lot of objects to allocate if we did things the naieve way. And, of course, it would get a lot worse with a dynamic app that keeps creating and deleting objects, if there happened to be a memory leak (yes, which should ideally be avoided, but when you have a deadline and one browser or another isn’t playing nice …).

Instead of holding 250 Comment objects, we simply use two objects - a ManualComment object and a TrackbackComment object. Each div representing a manual comment would then have a “comment” property referencing the (singleton) ManualComment object. Alternatively, we might prefer to implement some kind of factory that accepts an element and gives us back either the ManualComment object or the TrackbackComment object. So when the user clicks a “Mark As Spam” button inside the div, we have a means of getting back either a ManualComment or a TrackbackComment, and we can then call comment.markAsSpam() on it.

We might also have a Comment “superclass” to encapsulate common property (relying on prototype chaining supported by Dojo/Prototype/Base/etc libraries). Unlike Java-style Flyweights, we don’t have to declare abstract methods though; JS being dynamic, we can rely on Duck Typing, so it’s possible that our ManualComment and our TrackbackComment will each have their own markAsSpam() method, but Comment (if it exists at all), will have no such thing.

A Java-based HTTP Proxy for Ajax

Filed under: Web 2.0 News, Front Page, Java, Programming — Chris Cornutt at 7:53 am on Friday, July 21, 2006

On the Java.net blog of Greg Murray, he demonstrates a method of creating a proxy client in Java for an XMLHttpRequest of your choice.

One drawback of working with AJAX is that an AJAX-based client cannot make calls to URLs outside of its domain, which means that it cannot access services located on another server. To overcome these problems, you need a generic proxy that can communicate with external services on your client’s behalf. The proxy passes a call from your client application to the service, receives the content in response from the service, and returns the content to your client. You can then use this content in your AJAX-based application.

With the brief explaination out of the way, Greg gets started with the code/application. First off, he includes a graphic (sequence diagram) to show how the flow of the application will go - in his example, a request to the geocoding interface at Yahoo. His framework of choice to work with is the Project jMaki proxy functionality.

Where the blog post gets a little sparse on the details, this doucmentation on the Project jMaki site provides the complete story - code and all. Check it out!

Next Page »