/// Friday, December 2

Gamba: Helpers or Components?

I can't decide how Gamba should present AJAX to the end developer. After analyzing the prototype javascript library, which is the foundation for most AJAX functionality these days, should Gamba provide helper functions or create a component model? AJAX lends itself to the component model. You're forced to deal with synchronous/ asynchronous events. Events fired by one element may result in the update of another element. For example, clicking a button calls a remote function updating an input box.

Gamba can follow MonoRail and provide helper functions. This requires the developer to learn the prototype javascript library. Gamba can shield the end developer by creating a bunch of helper functions as MonoRail does. Here's an example:

<%= CreateButtonDoRemote("Invoke Remote", Urlize("SayHello")
        , {"onsuccess" : "$('input1').value = request.responseText;"
        , "onfailure" : "alert('Unable to get information from server.')"}
    )
%> &nbsp; <input id="input1"/>

It's just not simple, which goes against the KISS principle. The other option is to create a lightweight component model with pseudo-events. Here's the equivalent behaviour as above:

<%
text = TextBox('input1')
with button = Button(Caption: 'Invoke Remote'):
    OnClick += Client.CallRemote(Urlize('SayHello'))
    OnSuccess += Client.SetValue(text)
    OnFailure += Client.MsgBox('Unable to get information from server.')
%>

${button} &nbsp; ${text}

Comments:

Does that work?
The "with button.....OnClick" stuff.
 
yes, on my local. i'm not satisfied with it yet to release it. it only handles members if they're on the left hand side of an assignment. it should handle members on the right hand side as well.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?