Re: If you had JavaScript running server-side...?
- From: stevenmoberg@xxxxxxxxx
- Date: Sat, 19 Jan 2008 19:20:43 -0800 (PST)
On Jan 19, 3:11 pm, Peter Michaux <petermich...@xxxxxxxxx> wrote:
I'm writing a server-side web application framework using Mozilla's
Rhino JavaScript engine. My two primary motivations are so I can write
code on server and client sides without needing to switch gears
mentally and so that the server and client can share code.
The types of code sharing I know I can use immediately are form
validations and html previews. For form validation, I'll be able to
specify the regexp for what is an email address in just one language
rather than in both Perl|Python|Ruby|Java|etc and in JavaScript. For
something like a blog comment form or a wiki editor, where the user
can use *bold* or _underline_ syntax, the algorithm to convert this
code to HTML will only need to be expressed in one language. This
makes live previews in the editor much easier to implement.
I'm curious what other bits of common (or uncommon) client-side
functionality that you would be able to share with the server if you
had server-side framework running JavaScript.
Thanks,
Peter
I've recreated the Prototype 1.6.0 Library on the server side. Just
go through the script and pull out references to DOM objects. This
will give you basic OOP functionality. You may also want to look at
Base2 or ExtJS for there implementations of inheritance.
Utilizing the prototype.toString method comes in really handy when
designing widgets.
function Tree(){
this.branches = [];
};
Tree.prototype = {
read: function(sql){
// run ado query
// populate tree with branches
},
addBranch: function(branch){
this.branches.push(branch);
branch.parent = this;
},
toString: function(){
var html = [];
this.branches.each(function(branch){
html.push(branch);
}
return "<ul>" + html.join("") + "</ul>";
}
}
var itemTree = new Tree();
itemTree.read(sqlString);
Response.Write(itemTree);
You can already do this within ASP, just change your language
declaration to "Javascript".
I'm also creating an ASP Framework. It's a port of Fusebox (from the
ColdFusion community) written in JScript, but it will work with either
JScript or VBScript applications.
.
- Follow-Ups:
- Re: If you had JavaScript running server-side...?
- From: Thomas 'PointedEars' Lahn
- Re: If you had JavaScript running server-side...?
- References:
- If you had JavaScript running server-side...?
- From: Peter Michaux
- If you had JavaScript running server-side...?
- Prev by Date: Re: runat="server" functions execute, but variables don't exist - ASP
- Next by Date: js not working consistently
- Previous by thread: If you had JavaScript running server-side...?
- Next by thread: Re: If you had JavaScript running server-side...?
- Index(es):
Relevant Pages
|
Loading