Online documentation - Websydian v6.0

Users Guide | Patterns Reference | WebsydianExpress | Search

 

Implementing WAP Event Handler Functions


Implement Details WAP Event Handler Function

Declare WAP Event Handler

Event Handlers in WAP applications are scoped under the Card Generator functions or under the Template function (common actions).  Each defined Details Event Handler will appear as a menu point (or a Push button) in the WML Card containing the action.

MyCard includes FNC MyEventHandler
MyCard.MyEventHandler is a FNC WapEventHandler
MyWapDispatcher calls FNC MyCard.MyEventHandler

Like in Websydian for HTML, all WAP Event Handler functions need to be declared by the Dispatcher function of the WAP application.

Specify Name of WAP Event Handler

The WAP Event Handler function will result in an action in the generated Deck Template.  The WML name as well as the label of this action will by default be set to the object name of the Event Handler function.  This name may be overwritten by specifying a FNC name NME triple:

MyCard.MyEventHandler name NME Update

By the name-triple specified above, the name of the resulting action (object name as well as label) in the generated Deck Template will be changed to Update instead of MyEventHandler.

Specify Input Fields

Input to Event Handlers in Enterprise WAP applications are specified a little different from how it is done in Websydian HTML applications.  In both cases, the basic input to an Event Handler function is specified as local fields for the WebInput variable, i.e. the WebInput fields are the fields that the WAP Event Handler function running on the HTTP server will receive.

In WAP applications, all user input fields also must be specified as local fields in the WsyUserInput variable of the Card Generator function.  According to WML, all fields to be entered by the user have to be specified at Card-level – it is not sufficient to declare the fields in the WebInput variable of the WAP Event Handler.  If a field is declared in the WebInput variable of the Event Handler and not in the WsyUserInput of the Card Generator the field will not appear as an input field in the Card, but it will still be passed as input to the WAP Event Handler.

MyCard local FLD
...for VAR
FieldA
WsyDetails
local FLD
...for VAR
FieldA
WsyUserInput
MyCard.MyEventHandler local FLD
...for VAR
FieldA
WebInput

In the example above, FieldA is implemented as a user input field pre-loaded with the value of WsyDetails<FieldA> as set in the action diagram.  If FieldA was not declared in the WsyDetails region of the MyCard Card Generator, it would have been initialized with a blank value.

Specify Hidden Fields

Hidden fields to WAP Event Handlers are specified in the same way as in Websydian for HTML.  The declaration of fields in the Hidden variable may in some cases be omitted (see the section More about Hidden Input Fields to WAP Event Handlers in the Other Uses page).

MyCard local FLD
...for VAR
FieldB
WsyDetails
local FLD
...for VAR
FieldB
OmitDetailsFields
MyCard.MyEventHandler local FLD
...for VAR
FieldB
WebInput
local FLD
...for VAR
FieldB
Hidden

In the example above, FieldB will be displayed in the Card and at the same time used as hidden input for the MyEventHandler function.  The following triples will omit FieldB from appearing in the MyCard Card of the generated Deck Template.

Grid Event Handlers

WAP Event Handlers and Jump functions in Grid tables are implemented by links.  Each Grid Event Handler and Grid Jump will result in a column of links being displayed in the Grid table.  Grid Event Handlers are specified in the same way as in Websydian for HTML:

MyListCard includes FNC Select
MyListCard.Select is a FNC WapEventHandler
option NME
...value SYS
WSYD Grid event
Yes
etc.

The figure below shows the Grid table of the Select function implemented in WML (see next section for remaining specifications):

SelectGrid.gif (1995 bytes)

Not much space is available in a WAP display.

By default, link elements will get the same name as the corresponding WAP Event Handler or Jump function.  If a FNC name NME triple is specified for the function, the name object will be used as the name for the link element.

Hidden Input to Grid Event Handlers

Input to Grid Event Handlers are always specified as Hidden fields:

MyListCard local FLD
...for VAR
Article Code
WsyGrid
local FLD
...for VAR
Article Name
WsyGrid
MyListCard._CardTemplateGenerator local FLD
...for VAR
Article Code
OmitGridFields
MyListCard.Select local FLD
...for VAR
Article Code
WebInput
local FLD
...for VAR
Article Code
Hidden

The example above specifies an Article Grid table with a Select Event Handler for each row in the table.  The Select Event Handler receives the key of the Article table as hidden input, but only the Article Name field is displayed in the table.

User Input to Grid Event Handlers

In WML, it is not possible to specify user input field directly in a Grid table.  Usually this should not be necessary neither, as WAP displays leave very little space for multiple Grid fields.  Instead, a WML Grid table would contain a Jump to another Card in the Deck in which user data could be entered (see also the Designing with Grid Actions section in the Other Uses page).

It is possible though to specify user input directly to a Grid Event.  If an input field to a Grid Event Handler is specified only in the WebInput variable and not in the Hidden variable, the input field is set to the corresponding WML variable (declared in the WsyUserInput variable of one of the Card Generator functions within the Deck).  In this way, user input to the Grid Event Handler is specified as normal Card input fields.