×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    23

    appuifw.Form.save_hook - how to pass parameters to function?

    Hello

    I recenty asked about how to use the same function as callback for all menu items in appuifw.app.menu, and got a very nice solution with making som lambda function and refering to that. http://discussion.forum.nokia.com/fo...d.php?t=168494

    But what about the callback function i define as save_hook for a Form? In contrast to the menu-issue, appuifw already passes an argument (form-data) to it, but I need to pass another list as argument, as well. I've tried a couple of thins but can't figure out how to make it work. Here is what I tried, which is definitely wrong:

    Code:
    def validateForm(formdata,content):
        valid=True
        error=""
        params=content['params']
        i=0
        for p in params.items():
            element=formdata[i]
            (field,details)=p
            if details['type']=='number':
                if 'max' in details:
                    if element[2]>details['max']:
                        valid=False
                        error="Invalid number, max is %s" % details['max']
                if 'min' in details:
                    if element[2]<details['min']:
                        valid=False
                        error="Invalid number, min is %s" % details['min']
            i+=1
        return (valid,error)
    
    def makeSmsLambda(content):
        def f(content):
            return smsService(content)
        return f
    
    def smsService(formdata,content):
        (valid,error)=validateForm(formdata,content)
        if valid:
            print "#send sms etc"
        else:
            print error
    and somewhere else:
    Code:
            form=appuifw.Form(formdata,appuifw.FFormEditModeOnly)
            form.save_hook=makeSmsLambda(content)

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    23

    Re: appuifw.Form.save_hook - how to pass parameters to function?

    I fixed it like this:

    Code:
        form=appuifw.Form(formdata,appuifw.FFormEditModeOnly)
        form.save_hook=makeFormLambda(content,submethod)
        form.execute()
    
    
    def makeFormLambda(content,submethod):
        def f(formdata):
            if submethod=='send_sms':
                return sendSms(content,formdata)
        return f

Similar Threads

  1. Pass Parameters to native exe application
    By mrudulpen in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2008-05-05, 09:43
  2. pass parameters to web service with ksoap
    By racsus in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2008-04-11, 08:06
  3. Replies: 0
    Last Post: 2007-04-11, 05:23
  4. Replies: 2
    Last Post: 2006-09-26, 03:58
  5. Replies: 2
    Last Post: 2004-02-02, 14:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×