<throw>
Throws an event.
Syntax
<throw
event="event"
eventexpr="js_expression"
message="string"
messageexpr="js_expression"
/>
Description
You can throw either a predefined event or an application-specific event. For more information, see Chapter 3, Event Handling.
| Attribute |
Description |
event
|
Event to throw. Optional (as alternative to eventexpr).
|
eventexpr
|
New in VoiceXML 2.0. JavaScript expression that evaluates to the event to throw. Optional (as alternative to event).
|
message
|
New in VoiceXML 2.0. Message string providing additional context about the event being thrown. Optional.
|
messageexpr
|
New in VoiceXML 2.0. XML expression that evaluates to the message string. Optional.
|
One and only one of the attributes event or eventexpr must be specified. At most one of the attributes message or messageexpr may be specified.
Within an event handler that catches the thrown event, the variable
|
|
Tip:
|
| | If a JavaScript expression contains any of the characters "<", ">", or "&", that character must be replaced with the corresponding escape sequence "<", ">", or "&". For more information, see JavaScript Quick Reference. |
|
Usage
See Also
Examples
See other catch and throw examples under <catch> and <rethrow>.
<?xml version="1.0" ?>
<!DOCTYPE vxml PUBLIC "-//BeVocal Inc//VoiceXML 2.0//EN"
"http://cafe.bevocal.com/libraries/dtd/vxml2-0-bevocal.dtd">
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
<catch event="myEvent">
<prompt>
Catch of my event at document scope.
But here the value of my number has gone away.
It sounds like <value expr="mynumber"/>
</prompt>
<reprompt/>
</catch>
<catch event="nomatch noinput" >
<prompt>
Catch at document scope.
</prompt>
<reprompt/>
</catch>
<property name="universals" value="help" />
<help>
<prompt>
Catch for help at document scope.
</prompt>
<reprompt/>
</help>
<form id="numbers">
<catch event="myEvent">
<prompt>
Catch of my event at form scope.
<value expr="_message"/>
The value of my number has not gone away.
It sounds like <value expr="mynumber"/>
</prompt>
<clear/>
<rethrow/>
</catch>
<block name="numbergame"> This is a test of the throw tag. </block>
<field name="mynumber" type="number">
<prompt>
Tell me a number greater than ten.
</prompt>
<filled>
<if cond="mynumber < 10">
<throw
event="myEvent"
messageexpr="mynumber + ' is less than ten'"/>
<elseif cond="mynumber > 10" />
<prompt>
You said <value expr="mynumber"/>
</prompt>
<else/>
<throw event="myEvent" message="Ten is not greater than ten"/>
</if>
</filled>
</field>
</form>
</vxml>
[Show Frames] [FIRST] [PREVIOUS] [NEXT]