You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Apache Wiki <wi...@apache.org> on 2005/06/14 04:17:12 UTC

[Jakarta-taglibs Wiki] Update of "ReusableDialogComponents/Tutorials/Subdialogs" by RahulAkolkar

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-taglibs Wiki" for change notification.

The following page has been changed by RahulAkolkar:
http://wiki.apache.org/jakarta-taglibs/ReusableDialogComponents/Tutorials/Subdialogs

New page:
''Mix 'n match''

----

RDC components can also be invoked as a VoiceXML subdialog, this is of value if you want to (not mutually exclusive):
 * Mix static VoiceXML documents and JSPs hosting RDCs within an application
 * Have an existing call flow and you want to outsource relevant VUI bits to RDCs
 * Use RDCs in conjunction with other speech application authoring frameworks

There are two bits that have to work together, the subdialog and the host dialog. Invoking a RDC as a subdialog is done by setting the {{{subdialog}}} attribute to {{{true}}}. Here is an example from the distribution {{{<rdc-examples.war>/subdialog-test/subdialog.jsp}}}.
{{{
s10   <%@ page language="java" contentType="application/voicexml+xml" %>
s20   <%@ taglib prefix="rdc" uri="http://jakarta.apache.org/taglibs/rdc-1.0"%>
s30   <vxml version="2.0" xml:lang="en-US"  xmlns="http://www.w3.org/2001/vxml" >
s40     <jsp:useBean id="dialogMap" class="java.util.LinkedHashMap" scope="session"/>
s50     <rdc:task map="${dialogMap}">
s60
s70       <rdc:creditcardInfo id="ccInfo" subdialog="true" />
s80 
s90     </rdc:task>
s100  </vxml>
}}}

If you have looked at the ../FirstPage tutorial, this will look familiar. {{{creditcardInfo}}} is a composite RDC and it returns a ''(credit card type, number, expiry date and security code)'' tuple. The public data model [refer to the ../BuildingBlocks tutorial] of this composite looks like:

{{{
public class CreditCardData {

    private java.lang.String type;
    private java.lang.String number;
    private java.util.Date expiry;
    private java.lang.String securityCode;

    // Class constructors, getters, setters etc.

}
}}}

When invoked as a standalone dialog, the RDC will return its value as a JSP page scope variable whose name equals the value of its ID attribute. Thus, the value collected by the {{{creditcardInfo}}} composite can be played out in a prompt like so (replace s70 in the above JSP with lines s71 to s79 below and bind the ''c'' prefix to JSTL's core taglib):
{{{
s71       <rdc:creditcardInfo id="ccInfo"/>
s72 
s73       <c:if test="${not empty ccInfo}">
s74        <prompt>
s75         The credit card is a ${ccInfo.type} card with number  
s76         ${ccInfo.number}, has an expiry date of ${ccInfo.expiry}
s77         and the security code for this card is ${ccInfo.securityCode}
s78        </prompt>
s79       </c:if>
}}}


When the RDC is invoked as a subdialog, the public contract is very similar. It returns its value such that it is available to the caller as a subdialog variable whose name equals the value of the RDC's ID attribute. This value is serialized, since it will be part of a HTTP request. Composite RDCs use a preset serialization contract (via the {{{toString()}}} method of their public data models), so the deserialization script in the caller can construct an appropriate ECMAScript object representation of the RDC's public data model. The above subdialog is called from the following host dialog (which, in this illustrative case, does nothing but call the subdialog) - this example is available at {{{<rdc-examples.war>/subdialog-test/parent.jsp}}}
{{{
p10.  <%@ page language="java" contentType="application/voicexml+xml" %>
p20.  <vxml version="2.0" xml:lang="en-US" xmlns="http://www.w3.org/2001/vxml">
p30.   <form>
p40.    <subdialog name="ccInfoSubdialog" src="subdialog.jsp">
p50.     <filled>
p60.      <script src="${pageContext.request.contextPath}/.grammar/return.js"/>
p70.      <var name="ccData" expr="deserializeReturnValue(ccInfoSubdialog.ccInfo)"/>
p80.      <prompt>
p90.        The credit card is a <value expr="ccData.get('type')"/> card
p100.       with number <value expr="ccData.get('number')"/>, has an expiry date of
p110.       <value expr="ccData.get('expiry')"/> and the security code for this 
p120.       card is <value expr="ccData.get('securityCode')"/> 
p130.     </prompt>
p140.    </filled> 
p150.   </subdialog>
p160.  </form>
p170. </vxml>
}}}

The deserialized ECMAScript object {{{ccData}}} can now be used to obtain the credit card's properties using the {{{get( propName )}}} method supported by the deserialized objects. The script {{{return.js}}} is distributed in the {{{<taglibs-rdc.jar>/.grammar}}} directory.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-dev-help@jakarta.apache.org