commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cedric NICOLAS" <cedric.nico...@villefluide.fr>
Subject RE: Managing content in an SCXML file
Date Wed, 04 Nov 2009 21:23:12 GMT
Ingmar,

Thank you very much for your answer it is exactly what I was expecting, is
how to merge <content> and <send>. I will try what you suggest, and keep you
informed.

Regards,
-----Message d'origine-----
De : Ingmar Kliche [mailto:ingmar.kliche@googlemail.com] 
Envoyé : mercredi 4 novembre 2009 20:20
À : Commons Users List
Objet : Re: Managing content in an SCXML file

Cedric,

SCXML's default way to communicate with the outside world ist <send>. <send>
is supported by commons-SCXML and you have to implement the EventDispatcher
Interface and register it at the SCXMLExecutor to hook into the <send>
calls.

One option then would be to put the content into the body of the <send>
element, like this:

<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'">
         <content>
            <title> Welcome ! </title>
            <button text="Click here to continue" action ="send_OK"/>
            <button text="Quit" action ="send_Quit"/>
          </content>
       </send>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>

Note that commons-SCXML currently does not implement the latest W3C working
draft. I used the syntax from a previous WD [1].

I personally haven't used it like in the example above, but I'd expect that
you would get the body of the <send> element in the EventDispachter.send()
method (in the externalNodes parameter).

The drawback of this option though is, that you can not dynamically change
the "content" at runtime (i.e. it has to be known at authoring time). If you
need to create or change the content dynamically (lets say change the button
text) you could use the namelist parameter of <send> instead and store the
content within the datamodel. Then the markup would look something like
this:

<scxml>
...
<datamodel>
   <data id="content">
      <content>
         <title> Welcome ! </title>
         <button text="Click here to continue" action ="send_OK"/>
         <button text="Quit" action ="send_Quit"/>
      </content>
   </data>
</datamodel>
...
<state id="connect">
   <onentry>
      <send event="display" target="'mobiledevice'"
targettype="'mobiledevice'" namelist="content"/>
    </onentry>
    <transition event="send_OK" target="next_state"/>
    <transition event="send_Quit" target="final_state"/>
</state>
...
</scxml>

For more information on using the datamodel look at [2]. I hope this all
addresses your question.

- Ingmar.

[1] http://www.w3.org/TR/2009/WD-scxml-20090507/#send
[2] http://commons.apache.org/scxml/guide/datamodel.html

2009/11/3 Cedric NICOLAS <cedric.nicolas@villefluide.fr>

> Dear Rahul and others,
>
> I want to do a quite simple thing : having a state machine on a server
> controlling user interface of mobile clients.
> The state machine would have a lot of states and complex stream, and for
> some specific states it will embedded a simple markup language content
> (e.g.
> an html subset) that will be delivered to the mobile client which when it
> receives it, interpret and display it.
>
> For example the server state machine would have "connect" state that will
> be
> triggered when the mobile is establishing a connection, and would react by
> giving to the mobile client the content to be displayed. An simple example
> would be :
>
> <state id="connect">
>        <content>
>                <title> Welcome ! </title>
>                <button> text="Click here to continue" action ="send_OK"
> </button>
>                <button> text="Quit" action ="send_Quit" </button>
> </content>
>        <transition event="send_OK" target="next_state"/>
>        <transition event="send_Quit" target="final_state"/>
> </state>
>
> In that case the content in <content> tags will be retrieved by the Java
> code on void connect() method, and sent to the device. Server will listen
> to
> device and when receiving a message like send_OK, trigger this to the
state
> machine.
>
> To summarize I want to emulate a tiny web server hosting some tiny pages
> with a state machine.
>
> I've gone through all the documentation of Commons Scxml, and didn't find
> an
> easy way to do this. The possible ways I see are to use a data model, but
> using <assign> tags for setting my content seems to be quite heavy to
write
> and don't know how to assign an XML tree to a data model node, and other
> possibility would be to use maybe custom actions, but how to describe in a
> simple way my XML like-content ?
>
> Do you have a suggestion to do this in an easy and readable way ?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


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


Mime
View raw message