Be sure that you have created a DSQL directory $HOME/dsql
and set the environment variable DSQLDIR to point to it. Then start Sapphire/Web, if it is not already running.
test.pj
, select File->Open
from the menu bar and open test.pj
.
Tools->Document Manager...
Edit HTML
icon (Fig. 3-2).
<HTML> <HEAD><TITLE> Final Document </TITLE></HEAD> <BODY> This is the final document. Insert Data here: <P> ##Sa_DataDropSite## </BODY> </HTML>
##Sa_DataDropSite##
? It is a Data Site, a place where the results of a Data Object may be placed. Feel free to name the Data Site anything you want, so long as it has the syntax ##Sa_xxxxx##
, where xxxxx
is the variable name by which you will refer to the Data Site.
Preview HMTL
button, you should see the page below (Fig. 3-8).Object Editor
icon (Fig. 3-1) or select the menu item Tools->Object Editor
.
File->New
. An intermediate window will pop up.
pubs2
.
test_db
in the Selection text field at the bottom of this window. Click Ok
.
SELECT * FROM sysobjects
SELECT * FROM ALL_OBJECTS
SELECT * FROM systables
Test
button at the bottom of the Object Editor window. If your DSQL works correctly, an Object Results Viewer window will appear.This window should list the return columns and rows from the database.
Ok
to close the Object Results Viewer.
File->Save
in the Object Editor window.
File->Close
.
begin.html<A>GO
from the Activators list.
Delete Activator
icon (Fig. 3-1).
Object Bind Editor (New Activator)
icon or by selecting the menu item Tools->Object Bind Editor
. An intermediate window will pop up.
GO
. Click Ok
.
DSQL Name
.
test_db
) and click Ok
. This will enable the Object Bind Editor.
Results<=>Template
. The data returned by test_db
will populate the Data Sites in end.html.
test_db
. Click the arrow to the right of the first column. This will pop up a list of possible data drop sites (in this case [None]
and DataDropSite
).
name sysname (30)
) in end.html, click on DataDropSite
to select it. If you don't want this return column displayed, click [None]
.
Ok
to close the Object Bind Editor.
Edit->Options
. The Options Editor will pop up. In the top combo box, select Test
and set the Database Server, Database User Name, and Database User Password to the appropriate values. This will allow you to access database information as an anonymous WWW user. Click Ok
.
Test
icon.
begin.html<A>GO
from the Activators list.
Object Bind Editor
(Selected Activator)
icon (Fig. 3-1). This will open the Object Bind Editor with the attributes for begin.html<A>GO
.
Results<=>Template
section of the window. Click the Results Detail Editor button to the right of the first return column you want to format (Fig. 3-11).SaPopulateTableAll
.
Help
and your browser will display the relevant help page. When you are done, click Ok
to close the Results Detail Editor.
Ok
to close the Object Bind Editor.
Test
in the Project Window. Your browser will display begin.html. Click here to display your results page. Your data should now be neatly organized in a table (Fig. 3-13).
Before starting this tutorial, you should have completed tutorials 1 and 2. If you do not want to overwrite the project file from tutorials 1 and 2, create a directory $HOME/tut3
and change into it:
mkdir $HOME/tut3 cd $HOME/tut3You will also need to copy some project files into whatever directory you choose to contain this project:
cp $SAPPHIRE/tutorials/tutorial3/html/* $HOME/tut3If you have not already done so, start Sapphire/Web:
saweb tut3.pj &If you are already running Sapphire/Web, select
File->New
in the Project Window and name your new project tut3.pj
(in your tut3
directory).Object Editor
icon (Fig. 3-1) or select Tools->Object Editor
.
File->New
. You create a new Data Object.
Object Type
. Select FILE
and enter guestBook
in the Selection
text field. Click Ok
.
gbook.txt
in the File Name
text field. This is the name of the file that the File Data Object guestBook
will use to store information.
,
(a comma) in the Column Delimiter
text field. "
(double quotes) in the String Delimiter
text field.
Delimited Column Names
enter firstName
in the Name
text field.
ADD>>
button
Delimited Column Names
enter lastName
in the Name
text field.
ADD>>
button
File->Save
from the Object Editor.
Read
button in the File Mode
radio box is selected by default. The Data Object guestBook
will be used to read your list of names. You will also want an object that can append names to your file.
Append
and save the Data Object to a new name.
Append
button in the File Mode
radio box.
File->Save As
.
guestBook_append
as the name of the new Data Object. Click Ok
.
File->Close
.
Edit HTML
icon (Fig. 3-2) to examine the documents more closely.Document Manager
icon (Fig. 3-1).
Add HTML
Icon (Fig. 3-2). From the Add Document window select all of the HTML files and click Ok
. The selected HTML documents should now be listed in the Document Manager window (Fig. 3-15).
Preview HTML
icon (Fig. 3-2) to see what the first page of the project will look like to the user.
File->Close
.
Edit->Options Editor
.
Category
and select Project
.
HTML Startup Document
Option.
HTML Startup Document
window.
Ok
.
Ok
to close the Options Editor.
SignBook
anchor in index.html. When this anchor is clicked, the project CGI will play the signbook.html template. There is no dynamic data on this page, so you will use a NULL Data Object. Object Bind Editor (New Activator)
icon. The Activator Selector window will appear.
Document
list.
HREF=SignBook
from the Anchor
list.
Ok
to close the Activator Selector.
Object Type
and select NULL
. Click Ok
.
Results<=>Template
and select signbook.html. Click Ok
.
SignBook
anchor will take the user to signbook.html with no attempt to process any data.
The next binding that you create will define the SeeBook
anchor in index.html. When the anchor is clicked, the project CGI will play the seebook.html template. The guestBook
File Data Object will be used to populate the dynamic data in this document.
Object Bind Editor (New Activator)
icon. This will bring up the Activator Selector.
Document
list select index.html.
Anchors
list select HREF=SeeBook
. Click Ok
to close the Activator Selector.
Object Type
select FILE
.
File Objects
list select guestBook
. Click Ok
to close the Activator Selector.
Results<=>Template
and select seebook.html.
firstName
Result Argument and select the FirstName
Data Site, binding the argument to the site. This will put the file data called firstName
in the seebook.html Data Site called FirstName
.
lastName
Result Argument to the LastName
Data Site. Click Ok
.
Two bindings will be created for the Submit button Activator. The guestBook_append
File Object will be used to add data to the file, and the guestBook
file object will be used to put the guest book data in the seebook.html document.
Object Bind Editor (New Activator)
icon.
Document
list select signbook.html.
Form
select ACTION=FormAction
. Click Ok
.
Object Type
select FILE
.
guestBook_append
. Click Ok
.
Arguments<=>Activator
part of the binding.
Arguments<=>Activator
, bind the firstName
Argument to the FirstName
Form Element.
lastName
Argument to the LastName
Form Element. Click Apply
.
Submit
button is clicked. Clicking the Submit
button should also show the user the updated contents of the guest book. You will create this second binding without exiting the Object Bind Activator.
Data Object
button (Fig. 3-10).
Object Type
select FILE
.
guestBook
. Click Ok
.
Results<=>Template
choose seebook.html.
firstName
Result Argument to the FirstName
Data Site.
lastName
Result Argument with the LastName
Data Site.
Ok
.
The first alias you create will cause the SignBook
Anchor in the seebook.html document to execute the same code that is called when you click the SignBook
Anchor in the index.html document. As you may remember, the SignBook
Anchor shows a form for the user to enter a name.
Tools->Alias Manager
or click the Alias Manager
icon (Fig. 3-1).
index.html<A>SignBook
.
Add Alias
icon or select the menu item Edit->Add...
.
Document
list.
HREF=SignBook
from the Anchor
list. Click Ok
.
SeeBook
anchor in the signbook.html document to execute the same code that is called when you press the SeeBook
anchor in the index.html document.index.html<A>SeeBook
from the Activator
combo box.
Add Alias
icon or select Edit->Add...
.
Document
list.
HREF=SeeBook
from the Anchor
list. Click Ok
.
File->Close
.
File->Save
.
Test.HTML Path
option must be writable by the user on the http server that runs the CGI. Many servers have the CGIs run as user nobody
. In order for the user nobody
to write to a file, the file must be writable by every user on the system. To ensure that the Test.HTML Path
is writable, you'll need to use the UNIX command chmod 777
on the directory pointed to by the Test.HTML Path
option.
For example, if the value of the Test.HTML Path
option is /usr/users/dei/public_html
, a user would enter the command
chmod 777
/usr/users/dei/public_html
at the UNIX prompt.If you do not want to allow everyone to write to this directory, you will need to create a file in that directory that is writable by every user.
touch /usr/users/dei/public_html/gbook.txt chmod 777 /usr/users/dei/public_html/gbook.txtIf you want more information about security concerns you should read the appropriate sections of the User's Guide and Installation Guide. For more information about
chmod
, run the UNIX command man chmod
.
Click the Test
icon in the Project Window. If everything is configured correctly, your browser will display the index.html page.
You will now add names to the Guest Book to test the Data Objects.
Sign Guest Book
Anchor.
Add Name
.
chmod
command described above.
Sign Guest Book
to add another name to the list.