DBFree's Web Objects Detailed information Home


What is a webObject? (see a working demo )

WebObjects (a.k.a MaxObjects in previous versions) are standard MaxScript web pages
They differ from others only by the code and the use you make of them.
Web pages built as WebObjects accepts parameters and perform actions in accordance:
in facts you can use them as black boxes, without knowing anything about them except the paramaters to be passed.
A typical example of a commonly used WebObject is the standard login module used by DBFree, while another is the DB Browser demo

Web Objects perform actions on demand

You can treat WebObjects like black boxes: you don't really need to know what's inside and how they work - once you know what button to push (in effects what the parameters to pass) you can use them.
For example to embed a table (and edit it in-place) into your pages you can use a simple iframe like this:
<iframe 
    class="jumbotron" 
    src="/core/dbbrowse.msp?FILE=customers&ACTION=BROWSE">
</iframe>
Or just an hyperlink:
<a href="/core/dbbrowse.msp?FILE=customers&ACTION=BROWSE">
See the practical example here below.
DBBrowse in action

Add automation to static pages

You don't even need yo have DBFree on your server to use a webObject: just embed remotely. You can embed into an existing page of a site you already own or just straight on your desktop right now.

Test yourself

Just enable the direct editing of our customer demo table, residing on our server here in Dublin (Eire) in few simple steps - no matter where you are - without downloading or installing anything. Just write four lines of code into a test file:
  1. Create a new empty text file on your desktop: don't change the name, leave it as is.
  2. Double clik on the icon so you can edit the new file
  3. Copy and paste these instructions:
    <!DOCTYPE html>
    <iframe 
    style="width:100%;height:600px;" 
    src="http://dbfree.org/examples/dbbrowse.msp?VTABLE=customers&VACTION=LIST">
    </iframe>
    
  4. From the notepad menubar click on Save as.. and type (exactly) "mytest.htm" (don't forget the double quotes surrounding the name).
  5. Close the editor
  6. Locate the new icon mytest on your desktop and double click on it
You should see a new window automatically opening in your browser with the demo table and its data.
The tricky thing is that this method actually works even on Linux machines. All the job is done server-side so you can edit the table from anywhere and any system (as soon as is supporting HTML5).
Notice that this table is not on your desktop but on our server, and every modification you make will be recorded immediately and be available to any other user on internet.
Also notice that this is only a public demo so some features are disabled or limited comparing a standard DBBrowse webObject.
For instance the webObjects accepts these codes for parameter VACTION:
APPENDadd a new empty record
FILTERsets a filter (simple - on a single field)
UNFILTERremove the filter
DELETEmark one or more (those checked) for deletion
RECALLunmark all previously marked records
PACKphisically remove records marked for deletion (must get exclusive access)
LISTorganize records in a grid view

Example of code

What you've seen in action so far is a stock part. In real application you'll probably want to write your own webObjects, not using those available from shared collections.
This is a simplyfied WebObject to illustrate the basics and to give you a starting point:
<!DOCTYPE html><html>
<% 
//-- SET LIBRARY
set library to "c:\maxsis\dbfreev41\free.lib"
cSelf := pagename()
 
//-- INCOMING WEBVARS (parameter for this webObject)
cAction    := MSPFieldValue("VA")
cOption    := MSPFieldValue("VO")
cKey       := MSPFieldValue("VK")
nRecNo     := val(MspFieldValue("VR"))
 
//-- DATABASE SECTION
cDb := setDb("demo")
tMaster := cDb + "markets.dbf"
iMaster := cDb + "markets.mtx"
kField  := "COUNTRY"
use (tMaster) alias MASTER index (iMaster) key (kField)

preload("/common/header.h")
%>
<body>
<%=container()%>
<h3>WebObject Demo</h3><hr>Current table has <%=reccount()%> records.
<%
//-- FOREGROUND ACTIONS
do case
*=============================================
case empty(cAction)
*---------------------------------------------
p( "Input the record number to go to:" )
p( formStart(cSelf) ) 
p( formField( "VA",, "SHOW", "H") )
p( getNum("VR","Record to go?",1, lastrec()) ) 
p( formEnd() ) 
*---------------------------------------------
case cAction = "SHOW"   
*---------------------------------------------
editRecord(nRecNo,"","",0)
p( button(cSelf+"?VA=EDIT&VR="+zz(recno()),"Edit this record" )
*---------------------------------------------
case cAction = "EDIT"   
*---------------------------------------------
editRecord(nRecNo)
*
*---------------------------------------------
endcase
*=============================================
%>
</body>
For a more detailed explanation of WebObjects please see Developing Web Apps in the Publications section of this site.