On Wed, Apr 22, 2009 at 9:35 AM, Linda Erlenhov
<linda.erlen...@gmail.com> wrote:
> Hello
> Is there anybody that can help me with my problem described below?
>
> best regards
> //Linda
>
> On Mon, Apr 20, 2009 at 2:05 PM, Linda Erlenhov 
> <linda.erlen...@gmail.com>wrote:
>
>> Hello
>> I think I´ve done some mixing between two things that doesn´t work together
>> as I hoped it would.
>>
>> I have this Datamodel, the scxml document starts like this:
>> ------------------------
>> <scxml version="1.0" initialstate="INIT" xmlns:cs="
>> http://commons.apache.org/scxml"; xmlns="http://www.w3.org/2005/07/scxml";>
>>
>> <datamodel>
>> <data name="DynamicData">
>> <NumDat xmlns="" id="1" type="Integer">0</NumDat>
>> </data>
>> <data name="Indication1" expr="false"/>
>> </datamodel>
>>
>> <snip/>-------------------------
>>
>> I assign the "Indication1" later on:
>>
>> ---------------
>> <state id="StateC">
>> <onentry>
>> <log label="Renegade" expr="'Entering state: StateC'"/>
>> <assign name="Indication1" expr="true"/>
>> </onentry>
>>
>> <snip/>-------------------------------
>>
>> And the "DynamicData" also later:
>> ---------------
>> <state id="StateB">
>> <onentry>
>> <log label="Renegade" expr="'Entering state: StateB'"/>
>> <log label="Renegade" expr="Data(DynamicData,'NumDat')"/>
>> <assign location="Data(DynamicData,'NumDat')"
>> expr="Data(DynamicData,'NumDat')+1"/>
>> <log label="Renegade" expr="Data(DynamicData,'NumDat')"/>
>> </onentry>
>>
>> <snip/>-------------------------------
>>
>> I implemented a custom context with a notification functionality in the
>> "set" function (observer observed pattern) but the problem now is that the
>> only time the "set" function in the context is used is when indications are
>> set. Not when the DynamicData is set. I know that the SCXML works and that
>> the expressions evaluate properly because of the log:labels, my guess is
>> that it´s something with the Data() function that makes these expressions do
>> something different. What? Where is the "set" for the DynamicData located?
<snip/>

Yup, I see what you are running into. Unfortunately for the specific
usage pattern here, the two <assign> variations have different
semantics as follows:

1)  <assign name="..." expr="..."/>
is a set operation, which produces a Context#set(...) call

2) <assign location="..." expr="..."/>
is really a mutation operation, it retrieves the XML <data> tree
(stored as a DOM node in memory) and manipulates it -- there is no
call to Context#set(...)


>> How do I notify when my DynamicData has changed?
>>
<snap/>

ISTR that you prefer to not use custom actions. With those
constraints, one option (since you are generating all the SCXML) is to
accomodate for the above variation via the SCXML markup itself -- so
you could generate a redundant identity assignment to trigger the
Context#set(...) call like so:

<!-- assignment below taken from example above -->
<assign location="Data(DynamicData,'NumDat')"
expr="Data(DynamicData,'NumDat')+1"/>
<!-- followed by assignment that triggers the set call with the new value -->
<assign name="DynamicData" expr="DynamicData"/>

-Rahul

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

Reply via email to