Page 1 of 2

Phonegap issues

Posted: Thu Nov 08, 2012 5:45 pm
by jac53
After recreated the photo application using the new release 4.1.6 I am getting the following:

Re: Phonegap issues

Posted: Thu Nov 08, 2012 5:46 pm
by jac53
Here are the rest of the screenshots.

Re: Phonegap issues

Posted: Thu Nov 08, 2012 5:48 pm
by jac53
How can we remove the "no image selected" pop up? When we tap use, we get undefined.

Re: Phonegap issues

Posted: Fri Nov 09, 2012 11:06 am
by Scott Klement
When a JavaScript variable has not been assigned any value, it will be considered "undefined". Is it possible that you are doing something like alert(myvar) where myvar has not been set to a value?

Or is this message popping up automatically when calling the pui.photoCapture() API?

Re: Phonegap issues

Posted: Fri Nov 09, 2012 12:12 pm
by jac53
Hi Scott:

The steps were:
I pressed the Take Picture button.
I got the camera ready
I pressed the camera icon
I got the photo
I pressed the Use botton
I got the index.html undefined error message

Thanks,

Re: Phonegap issues

Posted: Fri Nov 09, 2012 1:14 pm
by Scott Klement
Can you post the takePicture() routine that you are referring to?

Re: Phonegap issues

Posted: Fri Nov 09, 2012 3:19 pm
by jac53
Here are the final Phone Gap files that we added to our XCode Project from the ProfoundUI Installation on the iSeries.

Re: Phonegap issues

Posted: Fri Nov 09, 2012 4:12 pm
by Scott Klement
Okay, so I extracted this code from the app.js that you have in your project. (I don't know if you wrote this, or if you copy/pasted it from one of our examples -- it may be that our examples aren't very complete.)

Code: Select all

function takePicture() {
   pui.capturePhoto({
      dir: "/www/profoundui/htdocs/pictures",
      fileName: "picture.jpg",
      overwrite: true,
      handler: function(response) {
        if (response.success) pui.click();
        else alert(response.error);
      }
   });
}
You'll notice that you've procided a "handler" function that is to be called when the photo capture process is finished. The handler either calls pui.click(). (Which, more or less, presses ENTER for the user if the photo upload was successful) or runs the alert() Javascript function to display the error message.

The reason you're getting a popup box that says "undefined" is because the response.error variable has not been set to anything -- so when you do alert(response.error) it displays "undefined" in the box.

I think maybe that handler function should do something like:

Code: Select all

      handler: function(response) {
        if (response.success) {
           pui.click();
        }
        else if (response.error===undefined) {
           alert("photo cancelled");
        }
        else {
           alert(response.error);
        }
      }
This is completely untested -- it's just off the top of my head.

The point is: You can write any code you want to handle the situation... maybe you just want to ignore the error? No problem... just remove the alert(). Write the code to do whatever you want it to do...

Does that make sense?

Re: Phonegap issues

Posted: Fri Nov 09, 2012 5:41 pm
by Scott Klement
I was thinking some more about this issue, and was wondering if maybe it's the same issue as the one in the following thread?
http://profoundlogic.com/forums/phpbb3/ ... =53&t=1276

Does that sound right? Did this happen after you upgraded ProfoundUI to the latest version?

Re: Phonegap issues

Posted: Fri Nov 09, 2012 5:50 pm
by jac53
I got the code from the documentation example.
I did the change and now I am getting Photo cancelled.
My problem is when I click USE (upload the picture) after I took the photo.