commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolfgang Rabl <wolfgang.r...@maven.at>
Subject Re: [SCXML] two scxml questions
Date Fri, 11 Jul 2008 15:07:41 GMT
Thanks very much, that was quite illustrating!

When working with custom actions, is it possible to pass over parameters 
other than Strings? Within the custom action implementation i get all 
the parameters and the childtagcontent as Strings and have to retrieve 
the corresponding datamodel information out of the scInstance parameter 
of the execute function. Is this the way to go or is there a simpler 
solution to pass over the parameters directly?

So for example if i have a scxml file i get foo and foo.bar only as 
strings and not as the objects they represent:

    <state id="test">
                <datamodel>
                    <data name="foo"/>
                </datamodel>
               <onentry>
                      <customAction1 param1="foo">
                            <param2>foo.bar</param2>
                      </customAction1>
              </onentry>
    </state>


thanks
Wolfgang
   


Rahul Akolkar schrieb:
> On 7/9/08, Wolfgang Rabl <wolfgang.rabl@maven.at> wrote:
>   
>> Hello,
>>
>>  Yes i will try the custom actions, but i dont think it would be a good idea
>> to contribute my solution because I am quite unexperienced and it would not
>> be a very good one :/ But i will see...
>>
>>  Nevertheless I have one further question regarding custom actions. As
>> stated in
>> http://commons.apache.org/scxml/guide/custom-actions.html
>> it is possible to declare child Tags within the custom action if one
>> implements the ExternalConten Interface. Are there any Examples for that? I
>> do not know how to implement the necessary getExternalNodes() function.
>> Whats the purpose of it? Is it to define the allowed childtags? and if so
>> how are they defined? And how do i get access to the childtags within the
>> execute funktion? It would realy be great if you could point me to an
>> example implementation.
>>
>>     
> <snip/>
>
> Its easier to work without child tags, if possible (often, its not, so
> see text below :-).
>
> Say you have a custom action like so (the semantics are not important
> for the purposes of explaining the parsing):
>
>   <my:action>
>       <my:foo/>
>       <my:bar/>
>   </my:action>
>
> Then the skeleton of the backing Action class may be implemented as:
>
>   public static class MyAction extends Action implements ExternalContent {
>
>     private List<Node> nodes = new ArrayList<Node>();
>
>     @Override
>     public List<Node> getExternalNodes() {
>       // this will be populated at parse time and used at execution time
>       return nodes;
>     }
>
>     @Override
>     public void execute(...) throws ... {
>       // Execute <my:action>, whatever the semantics are given
>       // the child nodes.
>       for (Node n : nodes) {
>         // In this case, above loop executes twice since the "nodes"
>         // list contains <my:foo/> and <my:bar/>
>       }
>     }
>
>   }
>
> -Rahul
>
>
>   
>>  thanks
>>  Wolfgang
>>
>>
>>     
> <snap/>
>
> ---------------------------------------------------------------------
> 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