28.06.2013 Views

Papers in PDF format

Papers in PDF format

Papers in PDF format

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.1 State and the Swap<br />

State can be added to Web database applications through the addition of a table that we call the “swap” (s<strong>in</strong>ce<br />

it is used to temporarily store form contents). Through use of the swap, tag/value pairs can be associated with a<br />

specific user and the screen they are currently access<strong>in</strong>g. The Swap table conta<strong>in</strong>s five columns: Username,<br />

Screen, Type, Tag, and Value. The Username must be a unique identifier, the Screen is a unique name given<br />

to each <strong>in</strong>put form <strong>in</strong> the Web <strong>in</strong>terface, the Type is used to specify different types of value pairs (for example<br />

form data or error messages), and the Tag and Value fields are used to record the state of the system (for<br />

example form field names and the data they conta<strong>in</strong>).<br />

When a user completes a form, the tag/value pairs sent to the CGI script are saved <strong>in</strong> the Swap table. If some<br />

form data form turns out to be <strong>in</strong>correct, that specific region of the form can be reconstructed with appropriate<br />

help or error messages, leav<strong>in</strong>g the rema<strong>in</strong>der of the data stored <strong>in</strong> the swap. Also, if a user partially completes<br />

a form, but then presses a button to request help, by sav<strong>in</strong>g the form data to the swap, the form can be restored .<br />

More importantly, the swap can be used to protect important data that should not be modified by the user. If a<br />

user modifies a row <strong>in</strong> a database table, it is important to reta<strong>in</strong> the primary key of that row so that an update<br />

can properly be executed. If the primary key of the row is kept <strong>in</strong> a hidden field, the HTML code may be<br />

hacked so that the dest<strong>in</strong>ation of the <strong>in</strong><strong>format</strong>ion is changed. By keep<strong>in</strong>g the primary key <strong>in</strong> the swap, such a<br />

modification is impossible. Therefore the swap ensures the security of the application data.<br />

4.2 Ma<strong>in</strong>ta<strong>in</strong>ability and the Lifetime of an Input Form<br />

Code reuse can significantly reduce development time and cost. This can be through modularization of the<br />

tasks necessary to process an <strong>in</strong>put form. The follow<strong>in</strong>g steps are what we call the “lifetime” of a form:<br />

1. Preparation - If the form is used to edit exist<strong>in</strong>g data, the necessary queries are made here. The results of the<br />

queries are saved <strong>in</strong>to the swap to be used when the actual form is created.<br />

2. Display<strong>in</strong>g the Form - Here the form is generated. If data for the form exists <strong>in</strong> the swap, then the data is<br />

used as the default values for the form objects. If error messages exist <strong>in</strong> the swap, these messages are<br />

displayed <strong>in</strong> appropriate places on the form.<br />

3. Check the User's Input - If the user makes a request for a help screen, we display the help screen and then<br />

return to step 2. If there are errors <strong>in</strong> the data, we save error messages <strong>in</strong>to the swap and then return to<br />

step 2. Otherwise we cont<strong>in</strong>ue to the verification screen.<br />

4. Verification Screen - If desired, the data that the user entered can be redisplayed for verification. If the user<br />

wishes to change someth<strong>in</strong>g, we return to step 2. Otherwise we cont<strong>in</strong>ue to step 5.<br />

5. Update the Database - Here the data is removed from the Swap and entered <strong>in</strong>to the Database. A screen is<br />

displayed that tells the user that the data has been committed to the database.<br />

By identify<strong>in</strong>g these elements common to many forms, rout<strong>in</strong>es can be written to encapsulate these steps. If<br />

separate CGI scripts are used for each step, scripts will not submit data to themselves. Our experience has<br />

found self-submitt<strong>in</strong>g scripts to be difficult to debug or modify and so they should be avoided at all costs.<br />

5. New Developments

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!