Saturday, March 20, 2010

Using Static HTML Pages in TapLynx

As I've been experimenting more with adding plug-ins to TapLynx I started to think about how some of the other iPhone libraries work. In those libraries, they are basically wrapping javascript and HTML pages with some iPhone classes so that the application will compile into a binary that can be sold on the Apple App store. Today we're going to make a little form that will sit in our TapLynx application and then post itself up to a .php file on our server for rendering.

If you do not have TapLynx and want to see the files that I'm using you can navigate to the html form from this link and you can grab the .php file that processes the POST from this link (form_process.php). The initial form will take two text fields as input and the .php processing form will echo the values of those fields back to the user.

An interesting thing to note as you design your pages, TapLynx uses a custom web controller so you cannot take advantage of the mobile Safari controls. You will need to give the person a way to get back to the launching page or else TapLynx will get stuck.

As with many things in TapLynx, the instructions for adding the HTML file are well documented in the supporting wiki. For this example, we make a configuration change to the NGConfig in our TapLynx project so that we can show the controller and have it display a file called form_test.html which we have copied into our XCode project. Our NGConfig looks like this:

The form_test.html file is a pretty simple html file and the code for the file looks like this:

Finally, here is the code for the .php file that is processing the data. Notice that I have included a little javascript link tag to take the person back to the initial form.

Any other issues? Well, the initial page needs to be local to the system. This is sort of contrary to a big part of TapLynx where you can have the configuration file remote and the rss feeds remote so you can make changes without resubmitting the application for approval by Apple. Also, my .php processing form is not on the phone, it's on my server. You can have your file link to other files on the phone (they will all be in the same directory on the phone regardless of if you have them in different folders in XCode). However, I can't think of a real reason in the context of a TapLynx application where I would want to do this. The .php file won't execute on the phone because the phone is just a browser.

So, if you're working on a TapLynx application and you want a few little things to be custom and you know some html and javascript, you can get the job done and extend your application and still not have to learn Objective-C (which is kind of the point, right?). I'm thinking of making a little glossary and dictionary for one of my applications and this is going to be just the thing.

No comments:

Post a Comment