You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Mike Sparr - www.goomzee.com" <mi...@goomzee.com> on 2006/04/12 06:18:31 UTC

[SCXML] outputting variables

Do variables need to be added to the namelist for display within output?
Strange thing is when sending SOAP message with ${var_name} it captures the
value of that variable and sends in SOAP message.  When attempting to
display variables in another transition event (e.g. Confirmation), it
outputs the literal ${var_name} instead of the value???

=========  PRINTS OUT '${var_name}' instead of 'value' ==========

<state>
<onentry>
    <var name="foo" expr="bar"/>
    .... Same for all fields you see below
</onentry>

     <transition event="uruws.prompt.confirm">
            <assign name="foo" expr="wassup" />
            <send target="http://localhost:8080/app" targettype="client"
event="uruws.authenticate" namelist="cb" delay="0" hints="" sendid="0004">
<vxml version="2.0">
<form>
<field name="input">
<prompt>
Is the following correct?

Name: ${first_name} ${middle_init} ${last_name}.

Yes or No?  

</prompt>
<option dtmf="1">Yes
</option>
<option dtmf="2">No
</option>
<noinput><reprompt/></noinput><nomatch><reprompt/></nomatch>
</field>
<filled namelist="input">
<submit next="http://webservices.goomzee.com:8080/btonramp/Voice"
namelist="input"/>
</filled>
</form>
</vxml>
            </send>
         <target next="logged_in" />
     </transition>

</state>


======== SUCCESSFULLY RETRIEVES VALUES AND POPULATES SOAP MESSAGE =========


<send ....>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
   <Authenticate xmlns="https://www.somecompany.com">
    <userdata>
     <Basic>
      <Forename>${first_name}</Forename>
      <MiddleInitial>${middle_init}</MiddleInitial>
      <Surname>${last_name}</Surname>
     </Basic>
    </userdata>
    <account>${account}</account>
    <password>${password}</password>
  </Authenticate>
</soap:Body>
</soap:Envelope>
            
</send>




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


Re: [SCXML] outputting variables

Posted by Rahul Akolkar <ra...@gmail.com>.
On 4/12/06, Mike Sparr - www.goomzee.com <mi...@goomzee.com> wrote:
> Do variables need to be added to the namelist for display within output?
> Strange thing is when sending SOAP message with ${var_name} it captures the
> value of that variable and sends in SOAP message.  When attempting to
> display variables in another transition event (e.g. Confirmation), it
> outputs the literal ${var_name} instead of the value???
>
<snip/>

The body of the <send> content is *not* any kind of template i.e.
there is no variable substitution. If you're seeing it happen, there
are other factors affecting that particular usage (not listed here).

You can however use any templating method (using the namelist as the
"context") by wiring up the EventDispatcher appropriately. A couple of
unrelated comments based on the code snippets:

 * If you want to separate the view layer markup, such as the VoiceXML
snippet, have the EventDispatcher look up the snippet (send it a
"snippetID" or some such via the namelist and do a lookup).

 * If you want to further leverage the targettype attribute you can
cater to multiple view layer / service layer technologies, for
example:
   - A targettype "x-velocity" may lookup a Velocity template and
populate the VelocityContext with the namelist data
   - A targettype "x-jsp" may send the output rendered by a JSP to the
client, similarly populating the request data
   - A targettype "x-webservice" may make a webservices call
   - A targettype "x-soap" may issue a SOAP request

(the x- prefix indicates non-standard i.e. part of your custom solution).

And that probably gets you the simplest instance of a MVC / Model 2
web architecture using Commons SCXML (for the controller bit and
possibly the model as well if you use <datamodel> exclusively for that
purpose).

Not saying you should do either, just some ideas.

-Rahul

<snip-scxml-snippets/>

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