commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Akolkar" <rahul.akol...@gmail.com>
Subject Re: [SCXML] two scxml questions
Date Wed, 09 Jul 2008 21:46:45 GMT
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


Mime
View raw message