Take a look at funformKit.

You can bind a function directly to a button, and a mixin manages state until the form is successful.

Why bother saving the initial state of the widgets w/ javascript?
All of the properties come in as Request variables and a tool like FFK can automagically set the values to what the users just selected.


If you want to keep the event handler code style you could try rewriting the action handler code in WebKit.Page to look for some other condiction, but to keep it html friednly and open I would recommend you only work with the elements name and/or value. Currently webware only uses the element name to determine which action to fire.

ASP has some interesting ideas, but much of it is focused on making it easy to use a GUI builder / IDE.

-Aaron

deelan wrote:

hi there,

yesterday i played around with webware and tried to implement
"events" ala ASP.NET in a webware form. basic event handling is
half done.

if you are not familiar with ASP.NET's webform model
a click on a <button> or an item selection on a <select> of a form on the client (the browser) trigger a post-back of the form to its containing servlet (via a simple __postBack() javascript function).


when the form is post'ed back it carries the initial status of the widgets in a hidden field called VIEWSTATE (a base64 encoded version of the pickled widgets) and the event triggered by user (e.g. "onclick", the id of the widget, an optional argument). viestate content is used to
restore widgets status. basically the webform knows it is on post-back status doing a lookup for VIESTATE field in request.fields(). then if
in post-back:


# ...in the webform awake() method:
if self.postback:
    # items holds all form widgets
    self.items = deserializeItems(request.fields(VIESTATE, ''))

i've written a series of simple wrappers for each HTML form widgets:
i have Button, TextBox, CheckBox, ListBox classes and so on. each class has a render() method returning a HTML4-strict markup code. for each widget you can specify all basic attributes, plus an id (mandatory) and a CSS class (to style the widget it in a separate stylesheet).


i was able to trigger the correct event handler on the widget during
the post-back, e.g. onClick() handler on the Button. but it's not enough, calling onClick() on the widget it's not optimal, since to trap
the event widget you have actually to subclass it, and this was a pain
in the first Java AWT, so i don't want to repeat the experience. instead
ASP.NET delivers the event on the webform, so if you have a button called "calc1" on your form the corresponding handler on the
form will be "calc1_onClick".


so, in the my webform  onLoad() handler i thought to
do something like:

btn1 = Button('calc1', 'Calculate total')
btn1.onClick = self.btn1_onClick

#...later in the webform code...

def btn1_onClick(self, event):
 # ... do something when btn1 is clicked

so when btn1 is clicked on the client it generates a post-back, and btn1_onClick is triggered on the form (you can access the original event target via an hypotetic event.target attribute).

BUT there's a big problem, after the "btn1.onClick = self.btn1_onClick" assigment btn1 widget cannot be plicked any more, and serialization function spits out a PickleError "cannot pickle function objects" ;-(
eh, i should have expected a problem, it was all too simple. in not in any way a "pickle" expert, so i'm missing somethinbg obvious.


i'm just sharing some ideas with you, in the hope that my experiments
ring some bells! if you are interested i can post some sources later in the afternoon. i the case some work in this direction has alredy been
done please point me to the right direction. i would love to
see event-driven webform in webware too.


later,
deelan















-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss


--
-Aaron
http://www.MetroNY.com/
"I don't know what's wrong with my television set. I was getting
C-Span and the Home Shopping Network on the same station.
I actually bought a congressman."
   - Bruce Baum





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to