cswam framework programming techniques

48
CSWAM Framework Programming Techniques  1. Overview A Web-site page presentation window/document maybe thought of as collections of smaller visual entities called containers in fixed positions throughout the page. Web- site layout design usually divides these sections into permanent and variable containers of information. The permanent sections of a Web- site layout/format are referred to as the Master Page and consist of one or more of the following sections:  Top of page  Left-side of page  Right-side of page  Bottom of page The variable  Center section(s) of the page is usually allocated for display of information requested via navigation lists in one or more of the permanent sections . Since all HTML sections (permanent and variable ) must be regenerated for each Web- site data request event, a copy of thepermanent  Master page sections is included as a  preface for all Web-site page contents. Classical Web-site design frameworks, such as ASP .  NET  were created to accommodate this archaic page level request and response design approach and force use of their own proprietary Web-site Server System. This esoteric Page event based framework system is in a continuous state of flux and must add incomprehensible “bells and whistle” controls to accommodate modern Web- site utilization needs (AJAX). Utilization of the CSWAM Framework package ( pk.cswam.framework.js ) revolutionizes the approach to Web-site programming. CSWAM provides element/object level design of Web-site page activities and integrated management of application events from the Client-side of the Web-site:  1. Installing initial Permanent Container elements (the Master Page) of the Application. 2. Managing all variable Application activities (Variable Containers)   Responding to User request  events for new application elements and data.  Updating elements (portions) of the screen with current information.  Controlling Timed Application  events.  Validating Application input data .  Message/Data Communication Standards with Server-side Programs.   Logging and Restoring (on click) Application presentation data.   Providing Startup Macros for Browser ‘add-on’ processors (plug-ins).  3. Structured Program Code Produced  No Page Post-back , or background code confusion.  Separate ( Functional ) control of all of application presentation elements (containers).

Upload: benjamin-rogan

Post on 10-Apr-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 1/48

CSWAM Framework Programming Techniques

1. Overview

A Web-site page presentation window/document maybe thought of as collections of

smaller visual entities called containers in fixed positions throughout the page. Web-site layout design usually divides these sections into permanent andvariable containers of information. The permanent sections of a Web-site layout/format are referred to as the Master Page and consist of one or more of thefollowing sections:

• Top of page• Left-side of page• Right-side of page• Bottom of page

The variable Center section(s) of the page is usually allocated for display of information

requested via navigation lists in one or more of the permanent sections . Sinceall HTML sections ( permanent and variable ) must be regenerated for each Web-site data request event, a copy of the permanent Master page sections is included as a

preface for all Web-site page contents. Classical Web-site design frameworks, suchas ASP . NET were created to accommodate this archaic page level request and responsedesign approach and force use of their own proprietary Web-site Server System. Thisesoteric Page event based framework system is in a continuous state of flux and must addincomprehensible “bells and whistle” controls to accommodate modern Web-site utilization needs ( AJAX ).

Utilization of the CSWAM Framework package ( pk.cswam.framework.js )revolutionizes the approach to Web-site programming. CSWAM provideselement/object level design of Web-site page activities and integrated management of application events from the Client-side of the Web-site:

1. Installing initial Permanent Container elements (the Master Page) of theApplication.

2. Managing all variable Application activities ( Variable Containers) • Responding to User request events for new application elements and data.• Updating elements (portions) of the screen with current information.• Controlling Timed Application events .• Validating Application input data .•

Message/Data Communication Standards with Server-side Programs. • Logging and Restoring (on click) Application presentation data. • Providing Startup Macros for Browser ‘add-on’ processors (plug-ins).

3. Structured Program Code Produced• No Page Post-back , or background code confusion.• Separate ( Functional ) control of all of application presentation elements

(containers).

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 2/48

• Easy/safe Maintenance and enhancement of the Web-site because it isaccomplished at the element level without affecting the integrity of other components.

• The Client/Server Program partners utilize a common communicationlanguage ( AMAC ) and a standard library ( amac_lib. lang ) of string

manipulation and argument parsing functions.

In short, the CSWAM framework changes the design theory of a Web-site froman Active Server Page (ASP ) to an Active C lient Page ( ACP ) approach.

A. Design of CSWAM Program/Page files

CSWAM Web-site program files are designed to operate in pairs, a Client-side pagelayout ( container-definition ) file and its companion Server-side pageupdating ( container-populating) program file. Each presentation element (container) ona page is defined by a unique ID name in the layout file and references its style/attributes

declared in the Cascading Style Sheet (CSS) file. The initialization and updatingof HTML objects and data within Client-side (Browser ) container elements aremanaged by corresponding ID related named functions in the companion Server-side program.

Client-side Program Server-side Program

• Setup ID names for allcontainers

• Startup function – PopulateMaster (Permanent) Containers

• Application code that mayuseCSWAM facilities.

• HTML predefined presentationsections.

• Library functions to obtain thefunction name and argument datafromthe CMAC request string ( cmac-

rqst) .• Master page initialization

functions to populate Client-side ID containers with HTMLpresentationobjects andCSWAM eventresponse calls.

• Input data verification functions• Application functions to set,

retrieve Server (Data-base, etc)information, carry-out Web-site

algorythm logic, andgenerate HTML presentationobjects to report results viaa Client-side container.

B. Web-site Page Presentation Control

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 3/48

CSWAM Web-site design relieson C ascading Style Sheets (CSS), for Container definitions ( position withincontainers, and presentation attributes) . The Browser always applies CSS definitionsto any change of HTML objects on the page. Therefore, when a AMAC call completesupdating the contents a container (ID), all the new HTML objects and attributes are

instantly updated, dynamically refreshing that section/container(s) in the page.

C. CSWAM Tandem Application Programming Files

Web-site programming utilizing the CSWAM framework dictates close integration of pairs of application program files: a client-side request and server-side action/ response program file.

Client-side Program Operations Server-side Program Operations

1. Request, with argument data, that a

named function in a companion Server-side program is to generatethe HTML and/or Application responseinformation to populate/updateits ID Object container(s).

1. Execute the requested function with

argument data to fulfill the Client-side request, and respond with thedesired HTML and/or Application responsedata.

2. Initiate and control timed changingcontainer content (TMAC ) activity.

2. Execute a requested function withargument data to provide the Client-sideTMAC control with the desired file nameresponse data.

3. Client-side Validation of an inputforms data fields in accordancewith VMAC instructions,

3. Execute a requested function withargument data to validate a form data entrywhen requested (during Client-sideVMAC instruction execution) and providethe VMAC with a pass or fail responseindication ( 1 or 0 ).

4. Error reporting of Client-side andServer-side encounteredSystem and Application Error conditions.

4. Provide unique error condition responsesencountered while processing Client-side request for Application services.

5. Record/Log all Requested Server-side response data, and update page Containers IDs by the act of clicking the Left or Right arrow Icons.

D. CSWAM Framework Service Calls

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 4/48

The CSWAM Framework provides a complete set of service calls to structure andsimplify most major Web-site design programming operations.These CSWAM framework calls perform all communication with anaddressed Server companion Program function to populate a container(s) with therequest response data. The following communications and bookkeeping features are

managed in the background to complete this type of CSWAM framework programmingservice call:

• AJAX communication interface control.• Table/queue management of Server call request/response message data.• Update standard CSWAM variable set with embedded Server response

channel data.• Interface, call and Server-side Error management, and reporting.• Client-side container(s) updating with response data.• Recording all ID-response data in the CSWAM History log.• Providing User click-activated recall of all history log records

E. AJAX Managed Application Control (AMAC) Communication Standards

The CSWAM Framework programming environment is based upon the following keyconcepts:

• The layout and Program management of all Page HTML container elements/objects ( DIV, SPAN , etc.).

• Use of the AMAC M essage Data Structure (AMDS) to:a. Request ( RQST ) Server-side function execution with named

argument data and to update Client-side ID container(s) with theresults.

b. Maintain Web-site general Page/Session ( PAGE ) information.• Use of AMAC named variables that provide unique message response

sub-channels (Error messages, separate data response messages to updatedifferent Client-side Container ID’s).

• Familiarity with the AMAC library routines to retrievefunction Call argument (RQST ) and Session (PAGE) related data andeasily access Server-side IO API logic ( file systems , data-base systems,etc )

1. Relationship of Server-side Functions and Client-side Container(s)

The CSWAM framework provides program control (updating) of eachseparate HTML Page presentation element (container object) when a relevantevent(s) is triggered, rather than “post-back” of the entire page when any eventoccurs. Once Client-side containers (the “Master page”) are established withunique ID names, the AMAC Server request message call is used to populatethem. An AMAC server request , passes a function name with its argument datamessage to a specified Web-site Server program function for execution.The Server function generates aresponse message seqment(s) ( Amac named

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 5/48

variable(s) ) which is used to populate the specified ID container(s) withresultant HTML data.

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 6/48

2. AMAC Server-side Function Execution Service Call

The keystone of Web-site design within the CSWAM Framework is use of the AMAC Server-side Message Service Call (See CSWAM Framework

Manual) . This AMAC Server call provides the means of triggering andasynchronous updating Client-side containers with content generated by Server-side program function output. There are two AMAC message call function formatsthat are used for these purposes, excite and samesite . In both AMAC cases a Web-site program file ( URL-Address ) is addressed and a Message-request is directed toexecute an internal function which generates response message segments to be storedin Client-side Containers( Client-Destination-list ) .

a. URL-address The Universal R esource Locator Address ( URL-Address ) is the location withdata of the Internet Web-site Program/file that is requested. A URL-

Address has the following general format:FORMAT: Web-site/File-address?Request-data

Web-site The location of a Server Web-site withintheInternet

File-Address The Address of the requested File/program withinthe Server File system. The question mark ( ? )character is the CGI separator from thesubsequent Request-data part of the URL .

Request-Data The named CGI encoded data variables,separated by an ampersand (&) delimiter(s), thataccompanies the request.NOTE: CGI = Common GatewayInterface internet messagecommunication standards

b. AMAC Exsite Message Format Call

The exsite function call is used to receive Server-side function execution

response results from a specified URL-address ed program. The format is asfollows:exsite ( URL-Address, Message-Request, Client-Destination-list )

c. AMAC Samesite Message Format Call

The samesite function call is used to receive Server-side function executionresponse results from the same URL-address ed program. The URL-address used

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 7/48

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 8/48

3. AMDS Named Field Message Data

• An AMDS argument field may be identified by its name followed by an“=” character ( name=) at the beginning of its segment. This namedargument field feature allows for specifying different attributes of

information associated with an argument.G. AMAC Request for Server Function Execution Message

An AMAC Server request call, employing the AMDS message structure, passes the name and arguments to a Server function for execution. The firstargument is the name of the Server function to execute followed by

positional or named arguments.

• “,|ldfile, [f]./include/amac_lib,php| cnt=1000”

• In this case the Server program is requested to execute

its ldfile function with the following argument and field values:

Arg#

Arg name Arg-fldname

Argument/Field Value ArgumentPurpose

0 ldfile Function name 1 f ./include/amac_lib.php Name of File

contents toreturn

1 f cnt 1000 Count of chars.to return

H. CSWAM General Page/Session information Message The CSWAM framework maintains general session related information utilizingan AMDS message object ( PAGE) to provide access to its content.Every AMAC Server request call forwards the PAGE message string to

provide Server side access to general Web-site session information:• Client-side Browser identification and OS information.• General Session type information ( Client IP address , login, etc).• Browser Plug-in HTML OBJECT/EMBED Macro definitions.The first argument in the PAGE Object string is the name ’ page ’ followed by the

following named argument entries and field data:

PageArgumentname

Fieldname

Description

[Browser] Client Browser and OS idetification:

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 9/48

name= version= os=

Browser nameBrowser version number Client side operating system

[Client]

calls= userid= login= passwd=

Client Website Access Information:

The number of calls to the server User internet identification addressUser Web-site login nameUser Web-site login passwd

swf Flash Player plug-in HTML EMBED macro:<DIV><EMBED src='~1' ~2 bgcolor='~3'\quality='high' loop=0\align='' type ='application/x-shockwave-flash'\

pluginspage='http://www.macromedia.com/go/getflashplayer'~4></EMBED></DIV>\

flv Flow Player plug-in HTML EMBED macro:<EMBED type='application/x-shockwave-flash'\src='flowplayer.swf'\flashvars=\"config={'clip':'~1'}\"\~2 ~4>\</EMBED>\

mov Quick Time Player plug-in HTML EMBED macro:<EMBED src='~1'\autoplay='true' controller='false'\

pluginspage='http://www.apple.com/quicktime/download/'\ bgcolor='~3' ~2 ~4>\</EMBED>\

wmv Media Player plug-in HTML OBJECT/EMBED macro:<OBJECT CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'\type='application/x-mplayer2'\

bgcolor='~3' ~2 ~4>\<PARAM NAME='URL' VALUE='~1'>\<PARAM NAME='SendPlayStateChangeEvents' VALUE='True'>\<PARAM NAME='AutoStart' VALUE='True'>\<PARAM name='uiMode' value='none'>\<PARAM name='PlayCount' value='1'>\~5\<EMBED TYPE='application/x-mplayer2'\

pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'\src='~1' bgcolor='~3'\ShowControls='true' ShowStatusBar='true'\ShowDisplay='false' autostart='true' PlayCount='1'\~2 ~4></EMBED></OBJECT>\

xap Silverlight Player plug-in HTML OBJECT macro:<OBJECT ~2 type='application/x-silverlight-2'\

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 10/48

data='data:application/x-silverlight-2,'\~2 ~4>\<PARAM NAME=source VALUE='~1'>\<PARAM NAME=onerror VALUE='onSilverlightError'>\<PARAM NAME=background VALUE='white'>\

<PARAM NAME=minRuntimeVersion VALUE='2.0.31005.0'>\<PARAM NAME=autoUpgrade VALUE='true'>\~5\

<A href='http://go.microsoft.com/fwlink/?LinkID=124807'\style='text-decoration: none;'>\<IMG src='http://go.microsoft.com/fwlink/?LinkId=108181'\alt='Get Microsoft Silverlight' style='border-style: none'>\</A></OBJECT>"

I. AMAC Message Channels

In accordance to CGI (Common Gateway Interface) conventionsa Server program in execution has all output directed to its Standard-Output (Fid1) file. This Standard-Output message is returned to the Client-side program thatinitiated the Server request call. AMAC message management provides uniquenamed communication channels within this standard message response pathway.These data channels are identified as AMAC named-variables on the Client-side and AMAC named-data segments on the Server-side.

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 11/48

Client-side

Channel datareferencevariable

Server-side Channel Datasegment Identification

Server-side Channeluse

Stat.response No channel identification isapplied

Default/StandardData

return channel

Stat.answer \n[[amac-answer= channel-data ]] Data Return channel

Stat.data1 \n[[amac-data1= channel-data ]] Data Return channel

Stat.data2 \n[[amac-data2= channel-data ]] Data Return channel

Stat.data3 \n[[amac-data3= channel-data ]] Data return channel

Stat.errror \n[[amac-error= channel-data ]] Server Error Messagereturn channel

Stat.ercode \n[[amac-ercode= channel-data ]] Server Error codeMessage

Stat.exec \n[[amac-exec= channel-data ]] Execute Client-sideCSWAM commands

Stat.rtype \n[[amac-rtype= channel-data ]] Specify type of response

channel data

J. CSWAM Page Element/Container Updating with Server-side data

The CSWAM framework alters the design and programming of Web-site softwarefrom the classical Active Server Page ( ASP ) approach toan Active Client Page C ontainer ( ACPC ) approach. In the CSWAM/ACPC designapproach, Containers/objects within the page are the smallest unit of Web-site presentation and event management, instead of the classical ASP approach of

page level updating for all container events. The AMAC Server request statement isthe means of updating Client-side page containers ( HTML DIV and SPAN objects).The request statement has three general components:

• The address of the web-site program to satisfy the request(URL and CGI variable data)

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 12/48

• The addressed function and argument data within the server programto process the request and generate the channel(s) of message responseinformation.

• The destination relationship of Client-side container ID (s) to beupdated with response message data channel information

(AMAC named variables).

1. Client-side Destination of Server Request Message Response data An AMAC server request statement call is processed by assigning the Server response message channel data to the specified Client-side containers (elements).The destination argument/list of the AMAC server request call may specify acomma delimited list of container-ID:amac_ variable specifications for updating HTML element-containers with Server-side message channel data.The format of a destination-list specification is as follows:

FORMAT: “*{!}Member-1,Member-2,Member-n,..”

* The star character (*) in the first position of this stringargument specifies that a destination list is to follow.

• If a * is not in the destination string argument, theargument is evaluated as Java-script (eval(arg) ).

• If the destination argument is not a string,theJava-script function specified by theargument is executed.

! Normally all Server ID-response channel data is saved by CSWAM in a history log for later access by user command. This character ( !) when present in the second

position of destination specifications will inhibit loggingof this calls response data.

Member (1-n) This is a specification to populate a Client-side element/container with Server-side messageresponse channel data.

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 13/48

An entry/member in the destination-list has the follow format :

FORMAT: ID{.type}{:AMAC_var}

Destination Member Specificationformat. This specification assigns a Server-side response message channel’s data (Thecontents of a AMAC varirable ) to theattribute (. type ) of the Client-sideHTML element identified by ID .

ID The identification (ID ) of the container element ( DIV,SPAN ,etc) to be updated.

.type This optional field specifies the element’sattribute to be updated.• .v = the value attribute of the element

will be updated.• If not provided =

the innerHTML attribute of theelement will be updated withthe AMAC -variable contents.

:AMAC_var This field specifies the response messagechannel contents to be used to update the

container element:• :response (Stat.response )• :answer (Stat.answer )• :data1 (Stat.data1) • :data2 (Stat.data2) • :data3 (Stat.data3)

If this field is not provided, the position of theentry in the list determines the defaultresponse message channel used to update, asfollows:

Pos0 = response (Stat.response )Pos1 = answer (Stat.answer )Pos2 = data1 (Stat.data1) Pos3 = data2 (Stat.data2) Pos4 = data3 (Stat.data3)

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 14/48

2. Client-side Destination of Server Error Request Message Response data

If a Server program generates an error channel message during request processing,the call is completed by AMAC as follows:

• All other Server channel messages are discarded•

If an error container/element ( DIV ) has been declared ( ID=_ermesg) theerror response message ( Stat.ermesg ) will update ( be reported in )the _ermesg container.

• If an error container/element _ermesg) was not declared , the error responsemessage ( Stat.ermesg ) will be reported as an alert message requiring User acknowledgement.

3. Client-side Destination of AMAC or Server System Error Message

If a AMAC system type error is detected or the Server program generates a systemcategory error channel message (error code < 100) during request processing, the call

is completed by AMAC as follows:• All Server channel messages are discarded.• If an error container/element ( DIV ) has been declared ( ID=_sysmesg) the

error response message ( Stat.ermesg ) will update ( be reported in )the _sysmesg container.

• If an error container/element ( _sysmesg) was not declared , the error responsemessage ( Stat.ermesg ) will be reported as an alert message requiring User acknowledgement.

4. Client-side Execution of Server AMAC Exec Message Response data

The final step in AMAC Server request processing is to execute theServer amac_exec response message channel data, if it exists. The statements/scriptcontained in this message data ( Stat.exec ) are executed by the Java-scripteval() function.

K. CSWAM Management of Browser Plug-in (Add-on) Processors

Developers employ other programming languages (other than HTML or Java-script )and action processors to provide dynamic presentation activities to a Web-site designsuch as:

• Java•

Flash Player • Silverlight Player • Java player • Quick time Player • Media Player • Flow Player

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 15/48

The Browser HTML language provides for ‘ placeholder ’ type statements(object and embed ) to allow a ‘ plug-in ’ program (different instruction processor) tomanage the associated container/object area within the presentation page. These

placeholder type HTML statements specify the following general control features for

execution of ‘ add-on’ (plug-in ) language processors:• The location (area within the page) assigned to the ‘plug-in’.• The Server-side URL address of the ‘plug-in’ if not already Client-side resident.

• The Server-side name ( URL address) of the action type program file.• Argument data ( HTML object or embed element attributes and processor options) to be provided for the specified ‘ plug-in ’ processor.

1. Plug-in File Types

A corner stone of Client-side (Windows) and Server-side (Web-site) system control is

the format standards applied to all file names.

FORMAT: Ident.Type

Ident This is a general User-application assigned functionalIdentification for the file within a folder/directory.

Type This field indicates the typeof Client (Windows) or Server system component(process) to manage the file.

The Type portion of a Web-site file name designates what Client-side ‘plug-in’ program is used process it as follows:

File Type Client (Browser Plug-in) Processor

swf Flash Player(Action script) xap Silverlight Player flv Flow Player (movies) mov Quick Time Player (movies) wmv Media Player (movies) class Java Applet Player(processor)

2. Use of PAGE Object to Setup HTML Code to Execute ‘Plug-in’ type Files

CSWAM Framework provides the HTML statement structure tocause Browser execution of Web-site ‘plug-in ’ type files via Session/Page data.The CSWAM session/$_PAGE object contains Macro information for each ‘ plug-in ’type file that can be expanded into the correct HTML object/embed element sequence

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 16/48

for Browser execution. The applicable Macro prototype is retrieved usingthe arg_data method as follows:

$Macro = $_PAGE->arg_data ($plug-in-file-type , null, "X") ;

The plug-in Macro Prototype is expanded into the correct HTML element/statementsequence (Html_seq) via execution of the _STR::make library function withthe Macro prototype followed by five additional positional arguments (~1,~2,~3,~4,~5 )as follows:

$Html_seq = _STR::make($ Macro , $ file , $ id , $bk , $attr , $ param ) ;

Macro The “ plug-in” Macro prototype string. file The name of the Web-site “plug-in” file.id The ident attribute ( id= ident) to be given

the HTMLobject or embed element . bk The background color of the HTML object orembed element .

attr Additional HTML object or embed element attribute (s) param Additional HTML object element param = arguments

3. Setup HTML Code to Execute ‘Plug-in’ type Files Example

The following example demonstrates the use of the CSWAM Sessionobject (_PAGE ) to cause Browser execution of different “ plug-in ” type Web-site files.

// Setup Plug-in file execution in window areafunction movie()

{ global $_RQST,$_PAGE; $file = $_RQST->arg_data('[f]',0,"X") ; $id = $_RQST->arg_data('[f]','id=',"id=M_center_movie") ; $bk = $_RQST->arg_data('[f]','bk=',"#FFFFFF") ; $attr = $_RQST->arg_data('[f]','attr=',"width='100%' height='100%'") ; $param = $_RQST->arg_data('[f]','prm=',"") ; $type = strtolower(_STR::get_field("lv",$file,".","mov") );

$macro = $_PAGE->arg_data($type, null, "X") ; $rsp = _STR::make($macro,$file,$id,$bk,$attr,$param) ; _SND::rsp('',$rsp ) ;}

L. AMAC Request Executable Function List

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 17/48

AMAC is designed to cause execution of Server-side program functions todynamically update Client-side HTML container elements. The names of allfunctions established for this purpose within the addressed Web-site Server programmust be referenced via entries within an array list:

Requested function name Server program function name/reference

PHP Example:

$my_funcs["master"] = "master" ;$my_funcs["title"] = "title" ; $my_funcs["top"] = "top" ; $my_funcs["lddir"] = "lddir" ; $my_funcs["bottom"] = "bottom" ;

M. CSWAM Access to Container/Objects ($ object class)

One factor that defines the usefulness of a Web-site development/control framework isthe ease of retrieving and altering ID named HTML page elements/objectattributes/values.The CSWAM framework provides simple referencing to retrieve and update allestablished container/object attributes and values via the ( $) staticclass function(s)/method(s). These functions enable the programmer to :

Purpose Referencing notation Reference Description Get an HTML objectreference

node = $(id) Variable node is set with a pointer tothe id named HTML object.

Get an HTML objectattribute

Value = $(id, attr) Variable value is set with thevalue HTML id named object.

Set an HTML objectattribute

$(id, attr,value ) The HTML id namedobject’s attr ( attribute/style ) isset with value.

Clear the list of HTMLObjects

$.clear(list) $.clear(‘ id -1, id -2 ,…’)

Clear the contents(value or innerHLML attribute)of the id named objects in list(comma delimited list of id’s ).

1. Client-side Modification of Client HTML Objects

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 18/48

The Client-side Web-site controller (the Browser ) initiates execution of Java-script code under the following conditions:

• When the requested Web-site page is retrieved. In this case all the blocks of Java-script code specified

within HTML <script> and </script> tags are executed . • When the Web-site page is first started. In this case all the Java-script code within the HTML body tag onload attribute areexecuted (<body onload=”Java-script code ” . . . >).

• When an HTML container/object event ( onclick,onmove ,etc) istriggered. In this case the specified attribute-event Java-script code,within the associated HTML tag , is executed.

(EX: <input onclick= ”Java-script code ” . . . >)

2. Server-side Modification of Client HTML Objects via Exec-channel

The CSWAM framework maintains a logical message communication path ( exec-channel) for the purpose of sending Server-side Java-script code snippets toits Client-side partner for execution . AMAC processes exec-channel data as the laststep in completing the Server-side message response of a AMAC function executionrequest.Therefore, a Server-side function can update the attributes of any Client-side HTML Object by employing the exec-channel to return ($) references for

execution as below (in this example, PHP is the Server-side programming language):

_SND::rsp('exec', (" $('tfn','value', 'cswam.doc' );") ;

When executed, the HTML container/object with an ID name of tfn will haveit’s value attribute set to cswam.doc .

3. AMAC Server Function Message Request Processing

One corner stone of CSWAM framework is AMAC management of messagecommunication for Server-side function execution. AMAC processes a Server-

side function request as follows:• Prepares a Server-side Function request message to send to theServer( URL address)

• Sends a asynchronous Function Request message to the Server.• Completes Function Request processing when the response messageis received from the Server.

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 19/48

AMAC preprocesses all provided request message argument data for the appearanceof _STR(………) method reference strings. If a _STR method string isdetected, AMAC will initiate its execution and replace the original string withthe _STR methods results. Since the _STR(..) method executes the string between theParenthesis, thus providing the means of delivering the most current HTML object

attribute settings to Server-side function execution.

EX. onclick="samesite(',|ldfile,[f ]_STR( $(\'tfn\',\'value\') ','*_response,_answer' ); "

II. Server-side AMAC Library

The AMAC library is collections ( classes ) of functions ( methods ) providing a structured basis for Web-site program development within the CSWAM framework.Of coarse the Library components must be coded in a Server supported programminglanguage ( VB, PHP, C#, etc .). These routines would be used by most AMAC Server-side requested functions and is organized into types ( classes) of general AMAC Web-

site programming tasks:CollectionName

Type of reference ReferenceFormat(PHP)

Collection/Class Purpose

_STR Static Class _STR _STR:: A general setof AMAC application Stringmanipulation methods/functions.

_SRV Static Class _SRV _SRV:: Provide AMAC initialization &Function executionmethods/functions.

_AMAC Object of _AVARSClass: $_AMAC = new

_AVARS

$_AMAC-> Provide access to AMACServer-side CGI variable data : • amac-rqst • amac-mid

_RQST Object of _AMDSClass: $_RQST= new

_AMDS

$_RQST-> Provide access to all AMAC callfunction and argument and fieldmessage data

_PAGE Object of _AMDSClass: $_PAGE= new

_AMDS

$_PAGE-> Provide access to all Web-siteSession/PAGE information.

_SND Static Class _SND _SND:: Send/Return response data tothe Client -side via one of nine(9)AMAC logical messagechannels:

• response • answer • data1

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 20/48

• data2 • data3 • rtype • exec • ermesg •

ercode _FS Static Class _FS _FS:: A set of Server-sideF ileSystem I/O methods/functions.

In this case AMAC Library components were coded in the PHP language and its Classmember referencing notations are based on PHP language requirements.An AMAC library coded in another object Oriented Language (Ex. C#, C++,JS, etc. )would have a slightly different referencing notation for access to the same functionalconstituent class members.

A. AMAC General String Manipulation Functions

Web-site presentation programming is primarily a collection of string manipulationtasks, There is a need for a tailored set of functions to obviate re-inventing the wheel for each new application. The _STR static class contains the methods ( functions ) to accessand manipulate string information. These functions provide general string managementfeatures that are used by other AMAC library routines and provide useful tools for Web-site program implementation.

_STR Method Method/Function Description

• STR::substr ($str, $pos, $cnt) Return field of character within

$ STR beginning at $ POS for a countof $CNT characters. If $ CNT == 0, theremaining characters will be the default$CNT .

• _STR::trim ($str, $lst) Return a new string byTrimming/removing the prefacingcharacters of $STR that match thoselisted in $LST .

• _STR::replace ($str, $mlst,$nlst) Return a new string by replacing all

matching $ MLST stringswithin $STR with a new string $NLST.

• _STR::type ($var) Return TRUE (1) if $VAR is a string,otherwise FALSE (0) .

• _STR::equal ($str, $mstr) Compare the beginning charsof $STR with$MSTR for equality, and if

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 21/48

they match return TRUE (1), or FALSE(0) .

• _STR::match ( $str, $mstr, $ldel ) Match the beginning chars of $STR witha delimited $LDEL list of entries

in $MSTR for equality and if an entrycompares its position (1-n) inthe $MSTR list is returned TRUE (n), or if there no matches a FALSE (0) state isreturned.

• _STR::fld_pos ($oper,$str, $fld) Return f irst or last position of matchingstring $FLD within $STR in accordanceto$OPER setting:$OPER [0] Type of match (f= first,l=last match occurrence )

Return -1 is $FLD is not found in $STR . _STR Method Method/Function Description

• _STR::get_fld($oper,$str,$fld,$def)

Return string before/after matched $FLD within $STR in accordanceto $OPER settings:$OPER [0] Type of match (f= first, l=last matchoccurrence ) $OPER [1] Type of return data (t= Tag data: beforematching $FLD , v=Value data: after

matching $FLD , e= End data: $FLD plusValue data).If a matching field $FLD is not encountered, thedefault $DEF string is returned.

• STR:: splits($str, $del) Return a string array by splitting the $DEL delimitedstring $STR segments into array members.

• _STR:: join($sary, $del) Return a string by joining the $SARY array memberstogether with a $DEL delimiter between the segments.

• _STR::get_data

($str,$nm,$del)

Return the request numbered ( 0-n ) or named ($NM )field of $DEL delimited data within string $STR . If the $NM field is not found, a NULL string is returned.

• _STR::set_data($str,$nm,$del,$data)

Set the (named or entry #) field $ NM data withinstring $ STR with the specified data $ DATA.

• _STR::make($istr,$args….)

Create/make a new string from $ISTR by replacing allits call argument positional references (~1-~n ) with the

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 22/48

contents of the provided argument variables $ ARGS 1 -$ARGS n.

B. AMAC Initialization Functions (_SRV Static Class )

Server-side AMAC processing facilities are initialized via services (functions) provided in _SRV static class methods/functions. These functions:

• Create the $_AMAC object for referencing AMAC related call variables.• Create the $_RQST object for referencing the requested function’s

argument data within the message.• Initiate execution of the requested Server program function.• Generate error report message on Server-side error conditions

_SRV Method Method/Function Description

_SRV::amac_init() Initialize AMAC developmentframework by creatingthe $_AMAC & $_RQST objects.

• _SRV::amac_func_exec ($myfuncs) Execute the Server function requestedin the AMAC message, provided it’sname is present in theServers $MYFUNCS list.

• _SRV:: error($status, $pref, $type, $file) Send an error response message to theClient if $STATUS is < 0 . The message

will be constructed with:• $PREF prefixing to themessage

• $TYPE of error incorporated inthe message

• $fFILE name associated withthe error condition

C. AMAC Variable Accessing Functions ($_AMAC Object )

The $_AMAC Object (an instance of the _AVARS class ) provides simple namedaccess to the AMAC variables as follows:

$_AMAC Method Method/Function Description

• $_AMAC->tag(“name”) Returns the

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 23/48

value of AMAC CGI variable amac-$NAME data :

• amac-rqst • amac-mid

D. Message Access Functions via AMDS Class Definition (_Amsd_class)

The AMDS class contains the methods ( functions ) to manipulate argument and fielddata within the message ( rqst ) and session( page ) data of the AMAC Server requestcall. The AMAC initialization function creates an $_RQST and $_PAGE object(instances of _Amds class ) and thereby providing a set of functions to access the callsargument data and Web-site session/page information.

$_RQST = new _Amds(mesg) ; $_PAGE = new _Amds(mesg) ;

1. $_RQST Object storage ($_RQST-> name )

NAME Storage Use $_RQST->mesg $_PAGE->mesg

Complete message string

$_RQST->adel $_PAGE->adel

Message argument delimiting character ( mesg[0] )

$_RQST->fdel $_PAGE->fdel Message argument-field delimiting character( mesg[1] )

$_RQST->dels $_PAGE->dels

Message component delimiting characters( mesg[0,2] )

$_RQST->args $_PAGE->args

Array of parsed message arguments

$_RQST->nm $_PAGE->nm

Name used to parse args array entries into thenamed args array ( nmargs ).

$_RQST->nmargs $_PAGE->nmargs

Array of named ( nm ) arguments from the args array

$_RQST->posargs

$_PAGE->posargs

Array that specifies the position in the args array of

eachnmargs entry2. $_RQST/$_PAGE Object methods ($_RQST-> name/ $_PAGE-> name )

RQST Method Method/Function Description

1. $_RQST->mk_array(mesg) $_PAGE->mk_array(mesg)

Store the message string MESG, thedelimiters ( DELS,ADEL,FDEL ) and

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 24/48

parse it into the ARGS array.

2. $_RQST->mk_nm_array(fary, nm,pary)

$_PAGE->mk_nm_array(fary, nm,

pary)

Create the NM named NMARGS argumentarray and a position PARY array (if

provided) from the provided argument

array FARG .

3. $_RQST->arg_data(nm,fnm,def) $_PAGE->arg_data(nm,fnm,def)

Return the (named or entry#) fieldFNM data within the specified(named or entry #) argument NM data.

• If FNM is not provided, therequested argument NM data isreturned.

• If the named NM argument andfield FNM do not exist,the DEF value is returned.

4. $_RQST->set_nm_data(nm,pos,fnm,data)

$_PAGE->set_nm_data(nm,pos,fnm,data)

Set the (named or entry #) field FNM datawithin the specified (named or entry #)argument with the provided DATA .

• If FNM is not provided, the position POS of thenamed NM argument data is setwith NM + DATA.

• If the named NM argument does notexist, the new argument is setwith NM + DATA.

RQST Method Method/Function Description

5. $_RQST->fld_data(str,nm,def) $_PAGE->fld_data(str,nm,def)

Return the (named or entry#) field FNM data within the specifiedstring STR. If the named field FNM does not exist,the DEF value is returned.

6. $_RQST->arg_nm_data (nm,i,fnm,def)

$_PAGE->arg_nm_data (nm,i,fnm,def)

Return the (named or entry

#) field FNM data within the specifiedentry # I in the named NM argumentarray NMARGS .4. If NM is not the current

named NMARGS argument array itand the POSARGS position arraywill be created fromthe ARGS array.

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 25/48

4. If the (named or entry

#) NM argument or FNM fieldwithin the argument does not exist,the DEF value is returned.

7. $_RQST->mk_fld_array(mesg) 8. $_PAGE->mk_fld_array(mesg)

Store the message string MESG thedelimiters ( DELS,ADEL,FDEL ) and

parse it into the ARGS array.9. $_RQST->reset_args(args) 10. $_PAGE->reset_args(args)

Reconstruct the message MESG stringfrom the contents of the ARGS arrayand ADEL delimiter

E. Send Message Response Data via _SND Static Class Functions

The _SND class contains the methods ( functions ) to return response data, to therequesting Client, via any of the AMAC named logical message response channels.The _SND function accepts a Short-name to identify the channel and it provides theadditions to the name and format control characters to generate a syntacticallycorrect AMAC return message.

ChannelShort-name

Channel Data MessageChannel Name

Server-side Channeluse

“” (no name) Default/Standard Datareturn channel

Stat.answer \n[[amac-answer =channel-data ]]

DataReturn channel

“data1” \n[[amac-data1= channel-data ]] DataReturn channel

“.data2” \n[[amac-data2= channel-data ]] DataReturn channel

“data3” \n[[amac-data3= channel-data ]] Data return channel“error” \n[[amac-error= channel-data ]] Server Error Message

return channel“ercode” \n[[amac-ercode= channel-

data ]] Server Error code

Message“exec” \n[[amac-exec= channel-data ]] Execute Client-

sideCSWAM commands

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 26/48

“rtype” \n[[amac-rtype= channel-data ]] Specify type of responsechannel data

1. _SND Class storage (_SND::$ name )

NAME Storage Use

11. _SND:: $chan Channel Default Short-name to be used if not provided innext SND::rsp method call ( __SND::tag(“”) ). _SND::chan is reset to null by the _SND::rsp method/function atcompletion of its logic.

2. _SND Class methods (_SND:: name )

_SND Method Method/Function Description

12. _SND:: _(“”, $mesg) Send response $MESG data via default(response ) logical channelto ClientAMAC request caller.

13. _SND:: rsp($channel,$mesg) Send response $MESG datavia$CHANNEL logical channel tothe ClientAMAC call.If $CHANNEL is null the currentcontents of _SND:: $chan is used as thelogical channel.

NOTE: A null value for the logical

channel destination defaults to sendingthe data via the response channel.

F. Server File System I/O via _FS Static Class Functions

The AMAC library provides a simple means of performing general I/O activities for aServer operating system platform. The _FS static class provides the basicMethods/Functions, and call arguments to manipulate files within a Server-side operation system ( UNIX, XP, Linux , etc). The methods included in this packagehave been programmed in PHP language to be executed on a Microsoft XPServer operating system.

The AMAC library _FS static class methods/functions provide the following CSWAMframework Web-site Server file system activities.

_FS Method Method/Function Description

14. _FS::io($type,$file, $ext, &$fbf, $cnt) Perform $TYPE (File, Dir or Stat ) I/Owith file $FILE using the address ( & ) of

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 27/48

buffer $FBF for a count of $CNT (characters to read for read operationonly).$TYPE is a (:) delimited string thatspecifies the type of I/O activity

(Stat, F ile or Dir) in the first fieldand I/O operation in the secondfield( R ead, W rite , M od time, etc.)$EXT is used for Directory readoperations to limit the returned entrynames to those types(ending string) listed(: delimited) in the $EXT argument.

15. _FS::stat( $oper, $file ) Return the $OPER specified state info of a$FILE .$OPER is a (:) delimited string that

specifies the type of state information to be returned( Status of file:-1=doesn’texist, 0= directory file, 1 = non-directorytype file), M odification time, and Accesstime)

_FS Method Method/Function Description

16. _FS:: file( $oper, $file, &$fbf, $cnt ) $OPER=( R ead

or W rite ) File $FILE from or to buffer $FBF $CNT number of characters and return amount of characters transferred.

17. _FS::dir($oper, $dir, &$daray, $ext) Populate the array $DARAY with thenames of entries in the $DIR havingname types specified in the $EXT list. $EXT is a (:) delimited string thatspecifies the directory entry types to beincluded in the array $DARAY. Return the number of entries inthe$DARAY.

18. _FS::dir_cvt_nm($ent) Convert the directory entryname $ENT to a simple name and returnresult..

III. CSWAM Execution of Client-side Functions

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 28/48

A. Client-side Modification of Client HTML Objects The Client-side Web-site controller (the Browser ) initiates execution of Java-script code under the following conditions:

1. When the requested Web-site page is retrieved. In this case all the blocks

of Java-script code specified within HTML <script> and </script> tags areexecuted .

2. When the Web-site page is first loaded. In this case all the Java-script codewithin the HTML body tag onload attribute are executed (<bodyonload=”Java-script code ” . . . >).

3. When an HTML container/object event ( onclick,onmove ,etc) is triggered. In thiscase the specified attribute-event Java-script code, within theassociated HTML tag , is executed.

i.

(EX: <input onclick= ”Java-script code ” . . . >) 4. At completion of a CSWAM Server Request Function call.

B. Server-side Modification of Client HTML Objects via Exec-channel

The CSWAM framework maintains a logical message communication path ( exec-channel) for the purpose of sending Server-side Java-script code snippets toits Client-side partner for execution . The request object Stat.exec variable is

populated with the Java-Script statements received via Server-side exec-channel . AMAC processes exec-channel (Stat.exec) data as the last step incompleting the Server-side message response of a AMAC function executionrequest.

Therefore, a Server-side function can update the attributes of any Client-side HTML Object by employing the exec-channel to return Java-script statementsfor execution as follows:(in this example, PHP is the Server-side programming language):

_SND::rsp('exec', (" $('tfn','value', 'cswam.doc' );") ;

When executed, the HTML container/object with an ID name of tfn will haveit’s value attribute set to cswam.doc .

C. CSWAM Argument Execution References During client-side CSWAM AMAC or TMAC Server function request processing,all argument data is examined for the appearance of _STR( JS-stmts ) methodreferences. If a _STR method string is detected, CSWAM will initiate its executionand replace the argument text reference ( _STR( JS-stmts) with its results. Sincethe _STR(..) method executes the string between the Parenthesis, it provides the

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 29/48

means of delivering the most current HTML object attribute conditions to Server-side function execution.

EXAMPLE : ',|ldimg,[f]_STR(Nd(\’ lpics1\’).src)'

In this example of RQST argument substitution, the file name [f] of theargument to the ldimg Server-side function is generated by executingthe CSWAM Nd function ( Nd( \’ lpics1\’) ) , to obtain and substitute thesource (.src) name of . img type file with an object ID name/attributeof lpics1 .

D. CSWAM client-side Java-Script Language Functions

1. CSWAM Argument Retrieval Functions

CSWAM framework also provides string management functions to operate upondelimited string segments:

Function Function Purpose

_STR.get_field_num(str,nm,del) Return the entry # position (0 – n) of thenamed NM field within thedelimited DEL string STR .

_STR.get_data (str,nm,del) Return the (named or entry #) field NM data withinthe specified string STR.

_STR.set_data (str,nm,del,data) Set the (named or entry #) field NM data within thespecified string STR with the specified data DATA.

_STR.splits ( str {, del}) Return an array of DEL delimited string segmentswithin the specified STR . If a delimiter DEL is nota comma (,) is the default delimiter.

_STR (JS-stmts) Return the result of executingembedded CSWAM/Java-script statements JS-

stmts . The specified JS-stmts statement(s) areexecuted and the resulting data replaces theoriginal statement reference (_STR ( JS-stmts )). This statement is detected only during client-side CSWAM Server request argument data

preparation.

_STR.replace (str, fld, nfld ) Return a string that replaces all occurrences of dataFLD within a string STR , with new

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 30/48

data NFLD .

_STR.trim (str, trmlist ) Return a string that trims (removes) all occurrencesof the listed characters in TRMLST that are a

prefixcharacter in the string STR.

_STR.lbl(name,snum,del,cnt) Return a list of CNT number of unique labels/Ids bycombining the NAME withthe SNUM ++ argument and providing adelimiter DEL between entries .

2. CSWAM Access to Container/Objects ($ object class)

One factor that defines the usefulness of a Web-site development/control framework is

the ease of retrieving and altering ID named HTML page elements/objectattributes/values.The CSWAM framework provides simple referencing to retrieve and update allestablished container/object attributes and values via the ( $) staticclass function(s)/method(s). These functions enable the programmer to :

Purpose Referencing notation Reference Description Get an HTML objectreference

node = $(id) Variable node is set with a pointer tothe id named HTML object.

Get an HTML objectattribute Value = $(id, attr) Variable value is set with thevalue HTML id named object.

Set an HTML objectattribute

$(id, attr, value ) The HTML id namedobject’s attr ( attribute/style ) isset with value.

Clear the list of HTMLObjects

$.clear(list) $.clear(‘ id -1, id -2 ,…’)

Clear the contents(value or innerHLML attribute)of the id named objects in list(comma delimited list of id’s ).

IV. Cswam Web-Site Application Example Using CSWAM Framework

This section presents an example using the CSWAM software to implement asample Web-site (cswam) application. The sample Web-site employs

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 31/48

the CSWAM package and was implemented on an Apache/PHP Server platform, andconsists of the following files:

• The CSWAM-Framework File (pk.cswam.framework.js) • The CSWAM-Framework Cascading Style Sheet file (cswam.framework.css ).• The AMAC Server-side String Management Library (amac_lib.php )•

Arrow symbol files ( l-arrow.gif and r-arrow.gif). • The sample Web-Site Cascading Style Sheet file (cswam_client.css ).• The sample Web-Site Client-side program ( cswam_client.php ).• The sample Web-Site Server-side program ( cswam_server.php ).• Any sample Picture files (.jpg& gif) in the Web-Site /pics directory/folder.

A. Cswam Web-Site Client-side Program

The Client-side program of this sample Web-site is divided into three sections:•

Master Page (Permanent containers) Initialization• Support Code including Form Verification Tables• HTML defined Container Page layout

1. Cswam Web-Site Client-side Layout(Master page) and Presentation

The design of the cswam sample Web-site breaks the presentation page into eleven ( 11 )sections ( containers ). The section object ID names are declared inthe cswam_client.php program file and their named attribute definitions are located inthe cswam_client.css file as follows:

Page Container Description ID Names incswam_client.php

ID Style Names incswam_client.css

Page Heading • Page navigation _pgnav S_pgnav • AMAC Request string _answer S_answer • System error reporting•

_sysmesg S_sysmesg

Master Page Sections Master S_Master • Page Title M_title S_title • Top of Page M_top S_top • Left side of page M_left S_left • Right side of page M_right S_right • Bottom of page M_bottom S_bottom

Center of page(Variablecontainers)

M_center S_center

• Server ermesg message _ermesg S_ermesg

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 32/48

• Server data1 response variable _data1 S_data1 • Server response message _response S_response

2. Cswam Web-Site Server-side Function Execution and Variable Settings

The design the cswam Web-site demonstrates the interaction between the Client-side(cswam.client.php) and its companion Server-side (cswam.server.php) program.The ID named containers declared in the cswam_client.php program are populated viaoutput response data from specified functions or variable settings executed in thecompanion cswam_server.php program on the Server. These relationships are asfollows:

Page Container Description ID Names incswam_client.php

Function or Variable incswam_server.php

Page Heading • Page navigation _pgnav S_pgnav • AMAC Request string _answer \n[[amac-answer=……]] • System error reporting _sysmesg \n[[amac-ermesg=……]]

Master Page Sections Master

• Page Title M_title title() • Top of Page M_top top() • Left side of page M_left lrqst() • Right side of page M_right lddir() • Bottom of page M_bottom bottom()

Center of page(Variablecontainers)

M_center

• Server ermesg message _ermesg \n[[amac-ermesg=……]] • Server data1 response

variable _data1 • butform()

• submit() • tmac() • track ()

• Server response message _response • butform () • page() • ldfile () • tblform () • menu () • track ()

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 33/48

Server response message Used by CSWAMVMAC package toverify input dataitems at server

input (amac_args)

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 34/48

3. Client-side Master Page (Permanent containers) Initialization/Startup

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CSWAM Client side Web-site</title> <link rel="stylesheet" type="text/css" href="cswam_client.css" /> <script src="pk.cswam.framework.js" language="javascript"type="text/javascript"></script>

<script language="JavaScript">

// ************ Master Page (Permanent containers) Initialization ************ Ajax.site = 'cswam_server.php' ;

function startup() { var flash = ",|movie,[f]./videos/Media.wmv"; xsamesite(',|master,[d].',

'*!M_title:response,\ M_top:data1,\ M_bottom:data2,\

M_right:data3,\ _answer:answer');

xsamesite(flash,'*!_response,_answer'); Ajax.Log.init('_pgnav') ; }

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 35/48

4. Client-side Support Code including Form Verification Tables

// load pics function ldpics(fnm)

{ var fnms = _STR.replace($(fnm,'value'),'\n','|' ) ; var pargs = ',[ids]_STR(_STR.lbl("rpics",1,"|",1)),[attr]h=296|w=396|c=1';var rqst = ',|tmac,[ops]sc=10000|dn=0,[imgs]' + fnms + pargs ;xexpics( 0,'_response',rqst,"") ;}

// Input Verification definition entrys // 'req','group','item','eid','ecolor','emesg');

vmac_ents = {'kitchen':"req=req,group=ckbox,item=Kitchen,ecolor=red,emesg=Must

select at least 3 items,test=[^:]{$*0>=3}", 'color':"req=req,group=radio,item=Car_color,eid=vermess,ecolor=red,emesg=Mustselect a car color,test=[^:]{$*0==1}", 'interests':"req=req,group=select,item=Interests,eid=vermess,ecolor=red,emesg=Mustselect at least 1 item,test=[^:]{$*0>=1}", 'date':"req=req,item=Date,eid=vermess,ecolor=red,emesg=**date,test=**date", 'email':"req=req,item=Email,eid=vermess,ecolor=red,emesg=**email,test=**email", 'passwd':"req=req,item=Passwd,eid=vermess,emesg=*erM_passwd,test='{$*0>0}'", 'login':"req=req,server='~~',emesg=*erM_login,test=*tst_login" } ;

var tst_login ='{@cswam_server.php,input,login[login,$0,pw,$[passwd]0]==1}' ; var erM_login ='Login not allowed' ; var erM_passwd ='Invalid passwd' ;

// Send Form data on SUBMIT event // form argument is the ID of the HTML Form element/object function sendform(form)

{ var url = Ajax.xsite + '?' + Amac.mk_url_list( $(form) ) ; var cmd = '!!submit![s]style="height:100px"![no]login,passwd,amac-' ; var list = 'login,passwd,kitchen,color,interests,date,email' ; if( vmac( 1, vmac_ents, list) )

{ exsite(url,cmd,'*!_response,vresults.v:data1') ; return(true) ;}

return(false) ;}</script>

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 36/48

5. Client-side HTML defined Container Page layout

</head> <body onload="startup();">

<div id='_pgnav' class='S_pgnav'></div> <div id='_answer'class='S_answer'></div> <div id='_sysmesg' class='S_sysmesg' ></div> <div id='Master' class='S_Master'> <div id='M_title' class='S_title'></div>

<div id='M_top' class='S_top'>

</div> <div id='M_left' class='S_left' >

</div>

<div id='M_right'class='S_right' >

</div>

<div id='M_center' class='S_center'>

<span id='_ermesg' class='S_ermesg'></span> <span id='_data'></span><span id='_response'></span>

</div>

<div id='M_bottom' class='S_bottom' > <span id='_bottom'></span>

</div>

</div></body></html>

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 37/48

B. Cswam Web-Site Server-side Argument String Servicing Functions

The directions for processing a Server message request ( AMAC ) are contained in the

amac-rqst variable string passed to the requested Server program ( URL ). The amac-rqst string contains the information needed to process the message request; the functionname and its argument data. Amac-rqst is a delimited list of arguments and delimitedfield data within the argument members. The first argument (0) in the list is the name of the function to be executed followed by its argument data (1-n).

TMAC Named Argument List Members

Argument and/or field data specified in the (rqst/args) argument of a CSWAM Server call may be distinguished by its bracket enclosed name [ nm ]

or nm= within its delimited list. The name ( nm ) can consist of any number of characters.The CSWAM T imed M anaged A pplication C ontrol ( TMAC ) Service Call, inthe initpgm/tmpgm default case , requires the use of named arguments and field data inits (rqst/args) field as follows:

TMAC ARG Name Argument Purpose

[ops]………. Specifies the operations to complete the timed request: Named Fields:

dn= 1 Place objects down within the container

0 Place objects across within container sc= The timing cycle to manage container content changes

[imgs]………. Specifies the name of a folder of or image file(s) on the Server:

[ids]………. Specifies ID’s to create within the container to populate with theimages:

[attr]………. Specifies the attributes of each object/container presented: Named Fields:

h= the height (px) attribute of each object IDw= the width (px) attribute of each object IDg= the gap (px) between each object IDs= the spacing (px) between each line up of objects

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 38/48

c= the count of objects that comprise a lineup before starting the next column ( dn=1 ) or row(dn=0 ).

C. Cswam Web-Site Server-side General Purpose Code (PHP Language)

1. Cswam Setup Processing Code

// Setup Processing Codeinclude("./amac_lib.php") ; $my_funcs["master"] = "master" ;$my_funcs["title"] = "title" ; $my_funcs["top"] = "top" ; $my_funcs["lddir"] = "lddir" ; $my_funcs["bottom"] = "bottom" ; $my_funcs["ldfile"] = "ldfile" ; $my_funcs["page"] = "page" ; $my_funcs["butform"] = "butform" ; $my_funcs["ldimg"] = "ldimg" ;

$my_funcs["tblform"] = "tblform" ; $my_funcs["input"] = "input" ;$my_funcs["submit"] = "submit" ; $my_funcs["dump"] = "dump" ; $my_funcs["tmac"] = "tmac" ; $my_funcs["menu"] = "menu" ; $lines_in_page = 30 ; //Max number of report lines

// Setup Processing Code $lines_in_page = 30 ; //Max number of report lines

_SRV::amac_init(); //Init $_RQST & $_AMAC _SND::rsp('answer',$_AMAC->_("rqst") ) ; _SRV::amac_func_exec( $my_funcs) ;

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 39/48

2. Cswam Master Permanent Container(s) Contents

// Master Template for page function master() { title() ;

_SND::$chan = "data1"; top() ;

_SND::$chan = "data2"; bottom() ;

_SND::$chan = "data3"; lddir() ; $lrqst ="\",|tmac,[ops]sc=20000|dn=1,[imgs]./pics,\

[ids]_STR(_STR.lbl('lpics',1,'|',9)),\ [attr]h=80|w=80|g=20|s=20|c=9\"" ; $exec = _STR::make(";expics( 0,'M_left',~1, '' );",$lrqst);

_SND::rsp('+exec',$exec ) ;}

3. Cswam Title Section Permanent Container Contents

// Title of page function title()

{global $_PAGE ; $rsp = _STR::make("<SPAN style='margin-left:300px;font-weight:bold; font-size:18px'>CSWAM Framework Example(~1:~2-~3)</SPAN>",

$_PAGE->arg_data('[Browser]','OS=',"X"), $_PAGE->arg_data('[Browser]','name=',"X"), $_PAGE->arg_data('[Browser]','version=',"X") );

_SND::rsp('',$rsp); }

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 40/48

4. Cswam Top Section Permanent Container Contents

// Top of page function top()

{ $rsp = _STR::make("<SPAN id='S_top'> <DIV id=menu>

<SPAN style='position:absolute;left:0px'> <UL> <LI><A href='#'>Item(s) =<TEXTAREA class='inlist' id='tfn' value='' rows=1ondblclick= \"samesite(',|ldfile,[f]_STR( $(\'tfn\',\'value\'))','*_response,_answer');\"></TEXTAREA><SPAN> Items to access</SPAN></A></LI>

<LI><A href='#' onclick=\"$.clear('_ermesg,_response,_data');\"> reset form<SPAN>Reset everything</SPAN></A></LI> </UL> </SPAN>

<SPAN style='position:absolute;left:260px'> <UL> <LI><A href='#' onclick= \"track( 'tfn' );\"> Track Items<SPAN>Track the named items</SPAN></A></LI>

<LI><A href='#' onclick= \"samesite(',|butform,[f]_STR( $(\'tfn\',\'value\'))','*_data,_answer' );\"> load pages<SPAN>load pages of named file</SPAN></A></LI>

<LI><A href='#' onclick= \"ldpics('tfn') ;\">load pics<SPAN>Cycle Pics from named Dir.</SPAN></A></LI> </UL> </SPAN>

<SPAN style='position:absolute;left:380px' > <UL><LI><A href='#' onclick= \"samesite(',|tblform','*_response,_answer') ;\">load tblform<SPAN> load table form</SPAN></A></LI>

<LI><A href='#' onclick= \"samesite(',|menu','*_response,_answer') ;\">load menu<SPAN> load the Menu</SPAN></A></LI>

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 41/48

<LI><A href='#' onclick= \"samesite(',|lddir,[d]_STR($(\'tfn\',\'value\'))','*_data:data1,_response:response,_answer:answer' );\"> load folder<SPAN>load the named folder</SPAN></A></LI>

</UL>

</DIV>

</SPAN>");

_SND::rsp('',$rsp ) ; }

5. Cswam Bottom Section Permanent Container Contents

// Bottom/footer Section Perminent Container Contentsfunction bottom()

{ _SND::rsp('',"<SPAN style='margin-left:400px;font-weight:bold;\ font-size:18px'>Bottom Of Page Section</SPAN>"); }

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 42/48

6. CSWAM Right Side Section Permanent Container Contents

// Load Directory/folder Output into Container

function lddir() { global $_RQST; $dir = $_RQST->arg_data('[d]','',"X") ;$dir_aray = "" ; $n=_FS::io("dir:read",$dir,"",$dir_aray,0) ; $rsp= _STR::make("<DIV id='folder' ><INPUT type=text id='dfn' value='~1'

ondblclick= \"samesite(',|lddir,[d]' + $('dfn','value'),'*M_right:response,_answer:answer');\">",$dir);

for( $i = 0; ( $i < $n ) ; $i++ )

{ $entry = $dir_aray[$i] ; $file = _STR::get_field("lv",$entry, "/",$entry) ; $type = strtolower(_STR::get_field("le",$file,".","") ); $bkground = ""; $cfunc = "" ; $sfunc = "ldfile" ; $opt="f" ; $dest="*_response,_answer" ; if( !(_FS::stat( "stat",$entry ) ) )

{

$sfunc = "lddir"; $opt="d"; $dest="*!M_right:response,_answer:answer" ; $bkground="style=\"background:#00FFFF\""; $entry=_FS::dir_cvt_nm ($entry); $cfunc= _STR::make("$('tfn','value','~1');",$entry ); }

else if( _STR::get_field("le",".jpg:.gif",$type,null) != null)$sfunc = "ldimg" ; else if( _STR::get_field("le",".swf:.flv:.fff:.mov:.wmv:.xap",$type,null) != null)

{ $sfunc = "movie" ; $entry = $entry.$_RQST->fdel."bk=#FF0000"; }

$click = _STR::make("onclick= \"~5samesite(',|~1,[~2]~3','~4')\"",$sfunc,$opt,$entry,$dest,$cfunc);

if( !$i )$click="" ; // current directory $rsp= _STR::make("~4<DIV><A href='#' ~1 ~2>

~3</A></DIV>",$bkground,$click,$file,$rsp) ; }

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 43/48

$ex=_STR::make("$('tfn','value','~1');",$dir); _SND::rsp('exec',$ex ) ; _SND::rsp('',$rsp . "</DIV>" ) ; }

7. Cswam Load Server-side Text File into Container

// Load Select file Text Output in window areafunction ldfile()

{ global $_RQST; $file = $_RQST->arg_data('[f]','',"X") ;$file_bf ="" ; $status = _FS::io("file:read",$file,"",$file_bf,64000) ;

$file_bf=_STR::special($file_bf,"<>" ) ; $rsp = _STR::make("<TEXTAREA id='textshow'class='textshow'>~1</TEXTAREA>",$file_bf );

$ex=_STR::make("$('tfn','value','~1');",$file); _SND::rsp('exec',$ex ) ; _SND::rsp('',$rsp ) ;}

8. Cswam Load Server-side Image File into Container

// Load Image file into in window areafunction ldimg()

{ global $_RQST; $img = $_RQST->arg_data('[f]','',"X") ;$rsp = _STR::make("<IMG src=~1 class=M_center

alt='~1'><DIV>~1</DIV>",$img); _SND::rsp('',$rsp ) ; }

9. Cswam Place Plug-in Action Program in Window Container

// Setup Plug-in file execution in window area function movie()

{ global $_RQST,$_PAGE; $file = $_RQST->arg_data('[f]',0,"X") ;

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 44/48

$id = $_RQST->arg_data('[f]','id=',"id=M_center_movie") ; $bk = $_RQST->arg_data('[f]','bk=',"#FFFFFF") ; $attr = $_RQST->arg_data('[f]','attr=',"width='100%' height='100%'") ; $param = $_RQST->arg_data('[f]','param=',null) ; $type = strtolower(_STR::get_field("lv",$file,".","mov") );

$macro = $_PAGE->arg_data($type, null, "X") ; $rsp = _STR::make($macro,$file,$id,$bk,$attr,$param) ; _SND::rsp('',$rsp ) ;}

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 45/48

10. Cswam Place Timed Picture Images in Window Container

// Place Timed Picture Images in Window Container // Set up picture display windows and return Image file names in amac-answer

// tmac call named arguments and fields // [ops] sc=scan time| dn= down/across // [imgs]image file name(s) or image directory name // [ids]container id-1|.|.| container id -n // [attr] h=height| w=width|g=gap|s=space|c=cnt of container windows

function tmac() { global $_RQST; $imgs = $_RQST->arg_data('[imgs]','',"***") ;

$ids = $_RQST->mk_fld_array('[ids]') ;$down = $_RQST->arg_data('[ops]','dn=',0) ; $height = $_RQST->arg_data('[attr]','h=',0) ; $width = $_RQST->arg_data('[attr]','w=',0) ; $gap = $_RQST->arg_data('[attr]','g=',0) ; $space = $_RQST->arg_data('[attr]','s=',0) ; $cnt = $_RQST->arg_data('[attr]','c=',0) ; $left= 0 ; $top= 0 ; $tinc = 0 ; $linc = 0 ;

if( $down )$tinc = $height + $gap; else $linc = $width + $gap; for( $i=0, $j=$cnt, $n=sizeof($ids); ( $n-- > 0 ) ;$i++, $left += $linc, $top +=

$tinc ) { $rsp =

_STR::make("<SPANstyle='position:absolute;top:~1px;left:~2px;",$top,$left) ; $attr =_STR::make("height:~1px;width:~2px'>",$height,$width)

;$id= $ids[$i] ; $img =_STR::make("<IMG id=~1 style='height:~2px;width:~3px'

alt='~1' onclick=\"samesite(',|ldimg,[f]_STR( $(\'~1\',\'src\'))','*_response,_answer');\" ></SPAN>",

$id,$height,$width); _SND::rsp('',$rsp . $attr . $img ) ; if( --$j == 0 )

{ $j = $cnt ; if( $down )

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 46/48

{ $left += $width + $space ; $top = -$tinc ; }

else

{ $top += $height + $space ; $left = -$linc ; }

}}

if( _STR::field_pos("f",$imgs, $_RQST->fdel) >= 0 ){ $list=_STR::splits($imgs,$_RQST->fdel); $pics=_STR::join($list,",");}

else { $ents=_FS::io("dir:read",$imgs,'jpg:gif',$dir_aray,0) ; $pics =_STR::join($dir_aray,","); }

_SND::rsp('data1',$pics ) ;}

11. Cswam Load Input Table-Form verification into response window area

// Load Input Table-Form verification into response window area function tblform() { $rsp = _STR::make("

<DIV id='vermess'></DIV> <form id=form1 class='S_response' action='cswam_server.php'

method='post' onSubmit=\"sendform('form1');return false;\">

<TABLE id=tbl width='300px' align='center'> <TR valign='middle' align='left'>

<TD align='center' height='25'width='45%' ></TD><TD width='45%'align='left'></TD></TR> <TR><TD>Login</TD><TD><DIV id=login_x></DIV><INPUT

type=text name=login id='login' value=''></TD></TR> <TR><TD>Passwd</TD><TD><INPUT type=password name=passwd

id='passwd' value='' ></TD></TR> <TR><TD></TD><TD>What is in your Kitchen?</TD></TR> <TR><TD></TD><TD><DIV id=kitchen_e></DIV>

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 47/48

<DIV id='kitchen'> <INPUT type=checkbox name=kitchen[] id='k_sk' value=sk

><B>sink</B><BR> <INPUT type=checkbox name=kitchen[] id='k_rf' value=rf

><B>refrig</B><BR>

<INPUT type=checkbox name=kitchen[] id='k_st' value=st><B>stove</B><BR> <INPUT type=checkbox name=kitchen[] id='k_wa' value=wa

><B>washer</B><BR> <INPUT type=checkbox name=kitchen[] id='k_ta' value=ta

><B>table</B><BR> <INPUT type=checkbox name=kitchen[] id='k_ch' value=ch

><B>chairs</B><BR> </DIV></TR>

<TR><TD></TD><TD>What is the color of your car?</TD></TR> <TR><TD></TD><TD>

<DIV id='color'> <INPUT type=radio name=carcolor id='c_wh' value=white><B>white</B><BR>

<INPUT type=radio name=carcolor id='c_bk' value=black ><B>black</B><BR>

<INPUT type=radio name=carcolor id='c_re' value=red ><B>red</B><BR> <INPUT type=radio name=carcolor id='c_bl' value=blue

><B>blue</B><BR> <INPUT type=radio name=carcolor id='c_si' value=silver

><B>silver</B><BR> </DIV></TR>

<TR><TD></TD><TD>What activities interest you?</TD></TR> <TR><TD></TD><TD> <select id='interests' name='other_interests[]' multiple size='5' >

<option id='o_no' value='None Selected'><B>Select Interests</B></option> <option id='o_bicycle' value='Bicycling'><B>Bicycling</B></option> <option id='o_golf' value='Golf'><B>Golf</B></option> <option id='o_tennis' value='Tennis'><B>Tennis</B></option> <option id='o_none' value='None'><B>None of the above</B></option> </select></TD>

<TD width='100px' valign='top'><BR> Hold down the &#145;CTRL&#146; key to Select more than 1.<BR> (Mac Users: hold down the &#145;COMMAND&#146; key).

</TD></TR> <TR><TD><B><P>Date</P></B></TD><TD><INPUT size='30px' id='date'

name='date' type='TEXT' /></TD> </TR> <TR><TD><B><P>Email</P></B></TD><TD><INPUT size='30px'

id='email' name='email' type='TEXT' /></TD>

8/8/2019 CSWAM Framework Programming Techniques

http://slidepdf.com/reader/full/cswam-framework-programming-techniques 48/48

</TR> <TR><TD></TD></TR> <TR><TD></TD><TD><INPUT size='10px' type='SUBMIT'

name='Submit' value='Submit' ></TD></TR> </TABLE>

</form> ");_SND::rsp('',$rsp ) ; }

12. Cswam Verify Input form item(s) data

/ Verify Input form item(s)data function input()

{ global $_RQST;

$type = $_RQST->arg_data('[type]','',"X") ;if( $type == 'login' ) { $n = $_RQST->arg_data('[n]','',"X") ; $login = $_RQST->arg_data('[login]','',"X") ; $pw = $_RQST->arg_data('[pw]','',"X") ; if( ($login == 'rer') && ($pw == 'mypasswd') )_SND::rsp('',"1" ) ; else _SND::rsp('',"0" ) ; }

else {

_SND::rsp('ermesg',"*** Server Application Error: ".$type." is not ainput name option ***" ) ;}

}