Here's what I would do:
class mypage(WebKit.Page): def actions(self): return ['nifty_action']
def nifty_action(self): fields = self.request().fields() oldval = int(fields.get('foo','0')) newval = oldval+2
self.writeln('%d + 2 = %d' % (oldval,newval)) self.writeContent()
def writeContent(self):
self.writeln('<form action="mypage.py" method="post">') # can use post or get
self.writeln('Number: <input type="text" name="foo" value="" />')
self.writeln('<input type="submit" name="_action_nifty_action" value="Process it!" />')
self.writeln('</form>')
Of course, this is a really simple example, but I hope it shows you what to do.
--John
[EMAIL PROTECTED] wrote:
Well assuming that you've not over written the usual things in your servlets, first you need to define your actions, this is the a list of methods that you're exposing to your get and post statements. for example
def actions(self): return ['myfunct']
then you can call it from your form by using __action__=myfunct.
Last all you need to do is define myfunct in your servlet and get your variables with either the request().fields() statement or request().field('filed') statement.
I know this is really sketchy but I hope it helps. If you want a more detailed example let me know and I'll email you some read code for you to look at
Jose
-------- Original Message -------- Subject: [Webware-discuss] Basic post/form handling in webkit From: "jacob martinson" <[EMAIL PROTECTED]> Date: Mon, January 31, 2005 11:26 pm To: webware-discuss@lists.sourceforge.net
I'm trying to find a document that explains how to handle forms in Webkit without using any third party modules like FormKit or FunFormKit.
I'm using compiled Cheetah templates to present the forms to the user, and I was planning on using webkit servlets to do the backend work with the submitted form information, and then redirecting either to a success page or back to the form to correct inputs.
Is there a document anywhere that shows how to do simple form handling with servlets?
Thanks!
-jacob
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Webware-discuss mailing list
Webware-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-discuss
------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss
______________________________________________________________________ This e-mail has been scanned by MCI Managed Email Content Service, using Skeptic(tm) technology powered by MessageLabs. For more information on MCI's Managed Email Content Service, visit http://www.mci.com. ______________________________________________________________________
------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Webware-discuss mailing list Webware-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/webware-discuss