Jump to: navigation, search

trigger

DevGuide2.png Purpose: Defines the trigger element, a mandatory child of event.

Description

The <trigger> element defines the conditions to match to generate the business event If several triggers are part of the event definition, they must all match to raise the business event. If the triggers match a different DOM event in the browser, the set of triggers specifies a serie of web events that must occur before the parent business event is submitted to the Frontend Server. You can add <val> children to the trigger, but in that case, <val> children only have access to the DOM event matched by your trigger.

Parent Element

Child Elements

Attributes

Name Mandatory Type Description
name yes string

Name of the trigger. Must be unique inside the <event> parent. if an <event> element has multiple triggers, they must all have different names across this <event> element.

element yes jQuery selector

Specifies the document's DOM element to which the trigger should be attached. The value of 'element' should be a jQuery selector. For details on jQuery selectors, see http://api.jquery.com/category/selectors/. If action is set to timer:nnn, element can be set to null.

action yes
  • standard DOM events
    • Browser Events
    • Document Loading
    • Keyboard Events
    • Mouse Events
    • Form Events
  • Specific to GWE:
    • timer:nnnn
    • enterkey

Specifies the DOM event to track. The trigger is matched if this DOM event is targeted to the DOM element specified by 'element'. In addition to the standard DOM events, the DSL supports the following two values: 'timer' and 'enterkey'. The timer is specified in milliseconds. If action="timer:nnnn", the 'type' parameter must specify how the timer works.

type yes if action='timer:nnnn'
  • timeout
  • nomove

Specifies how the timer works and is required only if action="timer:nnnn".

  • If type is set to timeout, the timer interval begins after the page is loaded.
  • If type is set to nomove, the timer resets each time that the user moves the mouse.
url no string

Defines the URL of a specific page which should raise the business event. The business event is not submitted if the current document's URL does not math the url parameter.

count no integer

Specifies how many times the trigger must match before the business event is submitted to the Frontend Server.

Examples

Implementation of a Timer

In the following example, the trigger uses a timer of 10 seconds, with the nomove type, which means that the business event InactivityTimeout is submitted to the Frontend when the user is inactive for 10 seconds.

<event id="InactivityTimeout" name="InactivityTimeout">
 <triggername="InactivityTimeout" element="" action="timer:10000" type="nomove"
 url="http://www.MySite.com/site/olspage.jsp"count="1"/>
 <val name="products"value="..."/>
</event>

If, instead of nomove, we had set the type attribute to the timeout value, the business event would be generated 10 seconds after the load of the web page was loaded.

Timeout and Condition Attribute

The following example redefine the previous timeout event by adding a condition to the event. The timeout is started only if the webpage is used for comparison. The event condition checks if the first heading of the page is the string "Compare" and starts the timer if the result is true.

<event id="InactivityTimeout4CompareProductsEvent" name="InactivityTimeout" condition="$('h1').text() == 'Compare'">
 <trigger name="InactivityTimeout" element="" action="timer:10000" type="nomove"
 url="http://www.MySite.com/site/olspage.jsp"count="1"/>
 <val name="products"value="..."/>
</event>

Enterkey Example

Let's assume that the webpage header loading the DSL code contains a search textbox. The following DSL code submits the business event if the user enters text in the search box and presses the "enter" key (in opposition to clicking on the "search" button):

<event id="SearchKeyDownEvent" name="Search">
 <trigger name="SearchKeyDown" element="input.searchfield:text" action="enterkey" url="[http://www.MySite.com%5C%22count= http://www.MySite.com%5C%22count=]"1"/>
 <val name="searchString" value="$('input.searchfield:text').val();"/>
</event>
Note that to match the click on the search button, you must create a new event. If you add a new trigger, the submission of the event will happen only if the user clicks on the search button and presses the 'enter' key.






Retrieved from "https://docs.genesys.com/Documentation:GWE:API:trigger:8.1.1 (2019-08-24 15:00:06)"
This page was last modified on February 27, 2013, at 11:48.

Feedback

Comment on this article:

blog comments powered by Disqus