On Sun, 2002-02-24 at 13:20, BA wrote:
> hello and thanks for reading this.
> i wonder the following:
> if i have a page object with two buttons on it.
> one button is 'add' and the other button is 'subtract'
> i press one of the buttons.
> what happens to the page?
> 1. nothing. pressing a button just calls the proper method.
> 2. something. the page behaves like a webform and it live ends and the
> action of the form is done.
> 
> what i want to create is a simple calculator with webkit.
> pressing the buttons calls code in my page and it does not cause the loading
> of another page or another instance of the same page.

Well, if you want it to happen entirely on the client side you'd do it
with Javascript.  Otherwise, simple make the form action be the servlet
itself, and put some code in your servlet's awake() method, like:

def awake(self):
    req = self.request()
    if req.field('calculate'):
        # do calculation
        self._result = calculation
    else:
        self._result = None

def writeContent(self):
    if self._result:
        self.write('Answer: %s <br>\n' % self._result)
    self.write('''
<form action="">
<input type="hidden" name="calculate" value="yes, do">
<!-- other form elements -->
</form>
''')

> did i make sense?
> 
> i as a mswindows+visual basic background. in vb or delphi or many other
> products, i create a form, populate it buttons and then write code. i am
> looking for this model for web development. the webware page object seems to
> come close, am i right?
> 
> 
> thanks,
> dave
> 
> 
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
> 



_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to