Plasma GitLab Archive
Projects Blog Knowledge


[UP]
Modules
 Wd_application_dtd
 Wd_cycle
 Wd_dialog
 Wd_dictionary
 Wd_encoding
 Wd_interactor
 Wd_run_cgi
 Wd_run_jserv
 Wd_run_fcgi
 Wd_stdlib
 Wd_template
 Wd_templrep
 Wd_transform
 Wd_types
 Wd_types.application_type
 Wd_types.dialog_decl_type
 Wd_types.dialog_type
 Wd_types.session_manager_type
 Wd_types.session_type
 Wd_types.syntax_tree_type
 Wd_types.template_type
 Wd_types.universe_type
 Wd_serialize_types
 Wd_universe
 Wd_upload
 Wd_var_functions
   
WDialog API for Objective Caml: Wd_types

Module Wd_types


module Wd_types: sig .. end
This module defines the fundamental types for WDialog

type 'a dict = 'a Wd_dictionary.t 
The type 'a dict is just an abbreviation for dictionaries (mappings from strings to 'a).

type event =
| Button of string
| Image_button of (string * int * int)
| Indexed_button of (string * string)
| Indexed_image_button of (string * string * int * int)
| No_event
| Popup_request of string

Events are generated when the user presses a button, clicks at a hyperlink, or opens a server-generated popup window.

  • Button n: The button with name n has been pressed (<ui:button name="n" ...>)
  • Image_button (n,x,y): The image button with name n has been pressed at the coordinates (x,y). (<ui:imagebutton name="n" ...>)
  • Indexed_button (n,i): The button with name n and index i has been pressed (<ui:button name="n" index="i" ...>)
  • Indexed_image_button (n,i,x,y): The image button with name n and index i has been pressed at the coordinates (x,y). (<ui:imagebutton name="n" index="i" ...>)
  • No_event: This value indicates that there was no event (or no recognized event)
  • Popup_request s: A server popup window has just popped up, and the contents for the window have been requested. The argument is the second argument of the "open" Javascript function that has been generated by the ui:server-popup element.


type interactors = {
   mutable ui_buttons : string option Wd_interactor.t;
   mutable ui_imagebuttons : string option Wd_interactor.t;
   mutable ui_anchors : string option Wd_interactor.t;
   mutable ui_indexed_buttons : string option Wd_interactor.t;
   mutable ui_indexed_imagebuttons : string option Wd_interactor.t;
   mutable ui_indexed_anchors : string option Wd_interactor.t;
   mutable ui_vars : unit Wd_interactor.t;
   mutable ui_enumvars : (string * string option * string) list;
   mutable ui_uploads : unit Wd_interactor.t;
}
Values of this type store the mapping from the (name,index) pairs of interactor elements to the real CGI parameter names together with auxiliary components.

What's the problem? Interactor elements like ui:a allow the programmer to identify these either by a single name (which is an arbitrary string) or by a pair of a "name" and an "index" (i.e. two arbitrary strings). In contrast to this, CGI parameter names are much more restricted. First, these names are only strings; there is no built-in representation for pairs of strings. Second, you cannot use arbitrary characters within these names because of limitations of the transport protocol and because of bugs in browsers. (As the "multipart/form-data" representation used in the transport protocol bases on the RFC 822 mail format, it is neither possible to pass 8 bit values, nor to pass control characters. A known bug in Netscape browsers is that the double-quote and backslash characters are incorrectly represented.)

The solution is to generate the CGI parameter names using only unproblematic characters, and to keep the mapping of the original string or string * string to the generated CGI name. This record stores the mappings for the various namespaces. The mapping is encapsulated in the Wd_interactor module, and the type 'a Wd_interactor.t (where 'a is arbitrary) represents such a mapping. The CGI names are simply enumerated, and the Wd_interactor.t value stores only the numbers (IDs) of the CGI parameters. The complete CGI name is formed using a prefix and the number stored in Wd_interactor.t. For example, ui:buttons without index have the prefix "button_"; and if the ui_button record component contains entries for the IDs 0, 1, and 2, the complete CGI names are "button_0", "button_1", and "button_2", respectively.

The type parameter 'a of 'a Wd_interactor.t is the type of the auxiliary component stored with every entry. See below for the meanings in every case.

The Wd_interactor.t structure always maps from pairs string * string to numeric IDs. Because of this, there are usually two mappings, one for the (name,index) pairs, and one for the simple names. The record components listed below that have a name with "indexed" are responsible for the pairs, the corresponding component without "indexed" stores the mapping for the simple case.

The simple case is represented as Wd_interactor.t by using always the empty string "" as index.

THE COMPONENTS ARE:

  1. BUTTON-TYPE INTERACTORS:
    • ui_buttons: Enumerates the ui:button interactors that have only a name, not an index. CGI prefix: "button_".
    • ui_indexed_buttons: Enumerates the ui:button interactors that have both a name and an index. CGI prefix: "xbutton_".
    • ui_imagebuttons: Enumerates the ui:imagebutton interactors that have only a name, not an index. CGI prefix: "imagebutton_".
    • ui_indexed_imagebuttons: Enumerates the ui:imagebutton interactors that have both a name and an index. CGI prefix: "ximagebutton_".
    • ui_anchors: Enumerates the ui:a interactors that have only a name, not an index. CGI prefix: "anchor_".
    • ui_indexed_anchors: Enumerates the ui:a interactors that have both a name and an index. CGI prefix: "xanchor_".

    These components use the auxiliary component to store the "goto" attribute of the interactor, if present.

  2. BOX-LIKE INTERACTORS:
    • ui_vars: Enumerates the interactors that are bound to an object variable (i.e. they have a variable attribute, like ui:text). As variables allow either only non-indexed names or only indexed names, this component contains both interactors identified by a simple string name and interactors identified by (name,index) pairs; it is not possible that there are conflicts between the two naming methods. CGI prefix: "var_". This component does not have an auxiliary component.
    • ui_enumvars: This list enumerates the simple names (name, None, pg) or pairs (name, Some index, pg) that occur in checkbox, radiobutton and select list interactors. pg is the name of the page where the interactor occurs (knowing the page is necessary for popup dialogues).
    • ui_uploads: Enumerates the ui:file interactors. These may only have a simple name. CGI prefix: "upload_". This component does not have an auxiliary component.


type 'a poly_var_value =
| String_value of string
| Enum_value of string list
| Dialog_value of 'a option
| Dyn_enum_value of (string * string) list
| Alist_value of (string * 'a poly_var_value) list

poly_var_value is the type of instance variables of dialogs. There are six possibilities for poly_var_values:

  • String_value s: The instance variable contains the string s
  • Enum_value [x1;x2;...]: The instance variable contains an enumerator value with the internal items x1, x2, etc. (As variables are declared it is known which items are possible, and whether there are corresponding external values.)
  • Dialog_value None: The instance variable does not contain a dialog.
  • Dialog_value (Some dlg): The variable contains the dialog dlg.
  • Dyn_enum_value [(x1,y1);(x2,y2);...]: The variable contains the enumerator with internal items x1, x2,... and the corresponding external values y1, y2, ...
  • Alist_value [(i1,v1); (i2,v2); ...]: The variable contains the associative list where the index i1 is mapped to the value v1, i2 is mapped to v2 etc.
See also Wd_types.var_value below.

type enum_decl = {
   enum_name : string;
   mutable enum_definition : (string * string) list;
}
The type of an enumeration declaration (i.e. ui:enumeration). The component enum_name is the name of the enumeration. The component enum_definition is the list of the pairs of internal and external names, in the right order.

type var_type_name =
| String_type
| Enum_type of enum_decl
| Dialog_type
| Dyn_enum_type
The different variable types

type 'a poly_var_decl = {
   var_name : string;
   var_type : var_type_name;
   var_default : 'a poly_var_value option;
   var_temporary : bool;
   var_associative : bool;
   var_protected : bool;
}
This record describes variable declarations. var_name contains the name of the variable. var_type is the declared type according to the type attribute. var_default contains either None, in which case no special initial value is declared, or Some v, where v is the initial value. var_temporary corresponds to the temporary attribute, var_associative to the associative attribute, and finally var_protected to the protected attribute.

type response_header = {
   mutable rh_status : Netcgi_types.status;
   mutable rh_content_type : string;
   mutable rh_cache : Netcgi_types.cache_control;
   mutable rh_filename : string option;
   mutable rh_language : string option;
   mutable rh_script_type : string option;
   mutable rh_style_type : string option;
   mutable rh_set_cookie : Netcgi_types.cgi_cookie list;
   mutable rh_fields : (string * string list) list;
}
This record contains the CGI header of the response. It is initialized quite early and can be modified while executing the request. The fields correspond to the arguments of the method set_header of the class type cgi_activation, defined in Netcgi_types.
type debug_mode_style = [ `Fully_encoded | `Partially_encoded ] 
Whether the generated HTML comments do escape HTML meta characters always (`Fully_encoded), or only partially (`Partially_encoded).

type environment = {
   debug_mode : bool;
   debug_mode_style : debug_mode_style;
   prototype_mode : bool;
   server_popup_mode : bool;
   self_url : string;
   response_header : response_header;
   cgi : Netcgi_types.cgi_activation;
}
This record contains data that may be different for every CGI request. The debug_mode and prototype_mode components are true iff the corresponding mode is switched on. The server_popup_mode is true iff the current request is a popup request. self_url is the URL that invokes the CGI recursively. cgi contains the full CGI request. The request_header is the designated header of the HTTP response.

type trans_vars = {
   mutable within_popup : bool;
   mutable current_page : string;
   mutable popup_env_initialized : bool;
   mutable condition_code : bool;
   mutable serialize_session : unit -> string;
}
This record is private for the transformation engine.
type ('a, 'b, 'c) poly_ds_buf = ('a, 'b, 'c) Wd_serialize_types.poly_ds_buf = {
   ds_str : string;
   mutable ds_pos : int;
   ds_end : int;
   ds_universe : 'a;
   ds_environment : 'c;
   ds_dialogs : (int, 'b) Hashtbl.t;
}
The deserialization buffer
class type dialog_decl_type = object .. end
This class type contains the dialog declaration
class type virtual dialog_type = object .. end
This class contains the dialog instance
class type application_type = object .. end
This class represents the whole application
class type template_type = object .. end
This class represents a template definition
class type syntax_tree_type = object .. end
This class represents the XML syntax tree
class type universe_type = object .. end
The universe is the registry of classes and dialogs
class type session_manager_type = object .. end
The session manager creates new sessions, and looks sessions up in the (possibly fictive) session database
class type session_type = object .. end
This is a single session
type var_value = dialog_type poly_var_value 

This type is the concrete version of Wd_types.poly_var_value that is actually used

type var_decl = dialog_type poly_var_decl 

This type is the concrete version of Wd_types.poly_var_decl that is actually used

type ds_buf = (universe_type, dialog_type, environment)
poly_ds_buf

This type is the concrete version of Wd_serialize.poly_ds_buf that is actually used

exception Change_dialog of dialog_type
The implementation of the handle method of a dialog may raise Change_dialog to drop the current dialog and continue with another dialog.
exception Change_page of string
The implementation of the handle method of a dialog may raise Change_page to set the next page to display for the current dialog.
exception Formal_user_error of string
A formal error that happens independently of the current runtime state. The string argument explains the error.
exception Runtime_error of string
A certain operation cannot be performed because the current state does not fulfill the necessary preconditions. The string argument explains the error.
exception No_such_variable of string
It has been tried to access a non-declared variable. The string is the name of the variable.
exception Instantiation_error of string
An error generated by the instantiate method. The caller should catch this exception and report the error from its own view
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml