When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Partner Programs 4D Partner Central

WebForms

All of the work we've done is about to pay off. Before you proceed, it is suggested that you quit 4D and re-start it, opening the WebForms4D structure file that you created. This step will make sure that the Web Server settings will have the proper effect. There are other ways to do this, but quitting and re-launching is the easiest to explain and the most fool-proof.

Now we are going to view the HTML form we created and submit it back to 4D. Please launch your web browser, and type "127.0.0.1" into the address bar. 127.0.0.1 is the TCP/IP loopback address.

You should see something like this in your web browser:

screenshot

Into the text area, type anything you want to. Contrary to what the web page says, the words aren't really important. However, you might consider using this string of text:

Sent from Browser to 4D

That's the string of characters that will be seen later on in this tutorial.

After you have typed some text, click the Submit button. When you do that, nothing should happen in your web browser. It should be sitting there, waiting. That's because back in 4D, a window should have opened up. It should look something like the one in the picture below:

screenshot

Welcome to the 4D Debugger! 4D's Debugger is a great tool for watching what happens as your methods run. Normally you only want to see the debugger if there is a bug (a problem, an error, an unexpected result) with a method you have written. However, in this case, we just want to use the debugger to see what is going on when you hit the Submit button back in the web browser.

The Debugger is showing you the Compiler_WEB method. That's because when we wrote this method, we put a TRACE command in there, which tells 4D to bring up the Debugger.

Why was the Compiler_WEB method called? The Compiler_WEB method (if it exists) will always be called when a form is posted to 4D. This is so that you can be sure you have declared variables that you may have used in the HTML form when you created it (as we did). Please click the Step Over button a couple of times.

screenshot

This is what the "Step Over" button looks like.

You will see that the gold-colored arrow on the left edge of the window moves as you click "Step Over." When you step past the line that beings with C_TEXT you should then fall into the "On Web Authentication".

screenshot

Here is the 4D Debugger showing the On Web Authentication method. You will probably have to move the splitters around so you can see the Call Chain Pane (upper right quadrant of the window) as fully as in the picture above. The picture shows the six parameters ($1, $2, $3, etc.) that are passed to this method by 4D. With the data provided by these parameters, you should be able to determine if the request should be authenticated or not. In our example, we're not worried about authorizing access to the WSC_FormHandler method, so we assign $0:=True. If we had assigned $0:=False, then the WSC_FormHandler method would not be executed.

Press the "Step Over" button a few more times. Since $0 is True, the next thing that will happen is that the WSC_FormHandler method is executed.

screenshot

In the picture above, you can see that WSC_t_FormItem1 appears in the Custom Watch pane. You can get WSC_t_FormItem1 to appear in the expression pane by holding down the Control key (or Command key, on Macintosh) and double-clicking on WSC_t_FormItem1 where it appears in the Source Code Pane (the pane where the gold-colored arrow is pointing at, the bottom half of the screen).

The question is, how did WSC_t_FormItem1 get assigned the value "Sent from Browser to 4D"? This is the string that was entered in the <textarea> of the HTML form. After 4D executes Compiler_WEB (where you declare 4D variables) it will automatically assign the form data to 4D variables that have names that match that of a form item. Remember, when we set up the HTML form, we did this:

<textarea name="WSC_t_FormItem1" rows="5" cols="46" wrap="SOFT"></textarea>

The name for the text area was "WSC_t_FormItem1" - so whatever the user entered into this form item will be automatically copied into the 4D variable named WSC_t_FormItem1. Very convenient!

If you hit the green arrow in the debugger (upper left corner), 4D will then close the debugger and execution of the method will continue unhindered. You should go back to your web browser. You should see the words you entered in the HTML form echoed back to you.

Previous Step  1 2 3 4 5 6 7 8 9 10 11 Next Step


International | Company | Contact 4D | Site Map | Privacy Policy | © 4D, Inc. 1995-2008 | Change font size: [A] [A] [A] | Print this page | 4D RSS Feeds