My favorites | Sign in
Project Logo
             
Show all Featured wiki pages:
TechnicalGaps
Feeds:
People details
Project owners:
  jonathan.buchanan

Note for would-be source code spelunkers: the js-forms SVN trunk currently uses getters and setters (implemented in Firefox >= version 2, Opera >= version 9.5, Google Chrome and more) - once development has moved on to focusing on new client-side features, js-forms will be made compatible with as many browsers as is reasonable.

Initial Development

The goal of initial development of js-forms is to create a direct as possible a client-side JavaScript port of Django's forms library, which allows you to define Form objects consisting of Fields and Widgets which can be used to generate form elements, validate form data (with a great convention for adding your own Form-specific validations) and effortlessly display populated form data and redisplay invalid form data with error messages.

This includes creating some components which are either impractical or impossible to implement purely on the client-side, such as validation of uploaded file contents and verification of arbitrary URLs.

Why? Firstly, because it's there; secondly, to gain an understanding of exactly how forms has been implemented and the various design decisions which went into its creation; thirdly, it's much easier to port directly than to try and change core design decisions about how a library should work as you go; fourthly, I have a dream... :)

Then What?

Django's forms are designed, and well designed at that, to cope with a specific task as part of a server-side web framework - displaying a form as a response to a request and validating incoming request data and putting it into a state suitable for further use, with the ability to redisplay with the given data if it was invalid. HTTP request parameters do not change during handling of a request, and in normal usage a Form instance goes out of scope as soon as the request it was created to help handle has been responded to. These factors have invariably influenced the design decisions related to how Forms are created and used.

However, on the client-side, a Form instance doesn't effectively "go away" after one use as it does when creating a response to an HTTP request. Data changes constantly as the user interacts with an HTML form, which also gives rise to the need to interactively respond to the user's actions.

Once we have a workable implementation of existing Django forms functionality in JavaScript, we can set that implementation aside for the moment and start to consider what else it needs to be able to do on the client-side, such as:

Pipe Dreams

For Everyone

Being able to use (largely) the same code on the server-side and the client-side to perform validation is surely one of the Holy Grails of web development.

Some of the existing solutions I've seen for this problem tie you into a specific way of doing things in the large. Having easily used Django forms outside the context of Django-based web application development, I feel that it would be useful to have a library of its ilk available on both client and server, with functionality appropriate to which environment it's running in.

You might not be doing any purely server-side JavaScript any time soon (you can do this right now - go hit Google if you're shocked/appalled/amazed), but there are still means of using JavaScript components on the server-side anywhere you can get a handle on an interpreter. For example, Java 6 comes with built-in integration of Mozilla's Rhino implementation of JavaScript. As someone who's shocked/appalled/amazed during his day job at the lack of Java form handling tools of the calibre of Django's forms (and at his own inability to sneak Jython in), I'd love to be able to integrate this library some day...

For Django

Wouldn't it just be amazing if you could automatically generate client-side validation, even partially, from one of your Form instances? Form Media provides a means of requiring that certain static media - such as JavaScript files - be included when rendering a Form instance. Hmm...









Hosted by Google Code