On 2/29/08, Guofeng Zhang <[EMAIL PROTECTED]> wrote: > I practice the Hello custom action. The following is the document. I found > that _eventdata is always null ( or empty). When I use the log action to > display it on an entry, its value is also displyed as null. > > it works well when the event is triggered by engine.triggerEvent(). I do > not make any change to the Hello class. > > <scxml xmlns="http://www.w3.org/2005/07/scxml" > xmlns:my="http://my.custom-actions.domain/CUSTOM" > version="1.0" > initialstate="init"> > > <state id="init"> > <onentry> > <my:hello name="finished" /> > </onentry> > <transition event="helloevent" > cond="empty _eventdata" target="empty" /> > <transition event="helloevent" > cond="_eventdata eq 'finished'" target="finished" /> > <transition event="helloevent" target="tostop" /> > </state> > <snip/>
Use _eventdatamap.helloevent (instead of _eventdata). See this document, for example (long, possibly fragmented URL below): http://svn.apache.org/repos/asf/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/custom-hello-world-04-jexl.xml Internal events generated in a given step, such as the one generated by the <my:hello> custom action, are processed all at once (though this behavior may change in some future major release). Other examples of these events are entry and exit events (init.entry, in the above snippet). Therefore, its necessary to identify which internal event's payload is being looked at, within the event data map (event name key, payload value) as discussed above. -Rahul > the following is part of the java code: > > // (1) Create a list of custom actions, add as many as are needed > List<CustomAction> customActions = new ArrayList<CustomAction>(); > CustomAction ca = > new CustomAction("http://my.custom-actions.domain/CUSTOM", > "hello", Hello.class); > customActions.add(ca); > // (2) Parse the SCXML document containing the custom action(s) > SCXML stateMachine = null; > try { > URL url = > HelloWorld.class.getClassLoader().getResource("custom-hello-world-01.xml") ; > ErrorHandler errorHandler = new SimpleErrorHandler(); > stateMachine = SCXMLParser.parse(url, errorHandler, customActions); > } catch (Exception e) { > // bad document, take necessary action > } > final SCXMLExecutor engine = new SCXMLExecutor( new JexlEvaluator(), > new SimpleDispatcher(), > new SimpleErrorReporter()); > engine.setStateMachine( stateMachine ); > engine.setSuperStep(true); > engine.setRootContext( new JexlContext() ); > engine.addListener(stateMachine, new EntryListener() ); > try { > engine.go(); > } catch (ModelException me) { > System.err.println(me); > } > //waiting in another thread. > > What's is wrong with my document? I use commons-scxml-0.7. > > Thanks for your help. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
