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] W3C specs compatibility and state transition issues
Date Mon, 14 Apr 2008 16:49:10 GMT
On 4/14/08, Ouyang, Landon - ES/RDR -Gil <Landon.Ouyang@itt.com> wrote:
> Hi Rahul,
>
>  My (limited) understand of JavaBeans is that a JavaBean object must
>  implement java.io.Serializable, has a public no argument constructor,
>  and contains set/get methods for properties. So I setup my result class
>  as follows:
>
>     class result implements Serializable
<snip/>

I think making the class public will fix the problem.

This is no longer a [scxml] discussion. My preference would be to have
a new email thread, if the discussion continues.

-Rahul


>         {
>         public result() {}
>         private int value;
>         public int getValue()
>             { return value; }
>         public void setValue(int nNum)
>             { value = nNum; }
>         }
>
>  However, the state transition still does not work!
>
>  FYI, I was able to prove that the object is sent to the engine correctly
>  using:
>
>  result newResult = (result)getEngine().getRootContext().get("result");
>
>  But for some reason, I cannot retrieve/use "result.value" in my XML
>  file!
>
>  Any ideas what I'm missing here? Thanks for the help.
>
>
>  --
>  Landon Ouyang
>  Member Technical Staff
>  ITT Electronics Systems, Radar Systems - Gilfillan
>  7821 Orion Ave,
>  Van Nuys, CA 91406
>  (818) 901-2982
>
>  -----Original Message-----
>  From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>
> Sent: Friday, April 11, 2008 6:56 PM
>  To: Jakarta Commons Users List
>  Subject: Re: [SCXML] W3C specs compatibility and state transition issues
>
>  On Fri, Apr 11, 2008 at 7:15 PM, Ouyang, Landon - ES/RDR -Gil
>  <Landon.Ouyang@itt.com> wrote:
>  > Hmmm....
>  >
>  > Given your snippet, I assumed this would work:
>  >
>  > result aResult = new result();
>  >
>  > if(bIsTest)
>  >   aResult.value = 1;
>  > else
>  >   aResult.value = 0;
>  >
>  > getEngine().getRootContext().set("result", aResult);
>  >
>  > where the XML transition is conditional on "result.value eq 1". Why
>  > doesn't it work?
>  >
>  <snip/>
>
>  Try adding getter and setter methods, as I suggest below (for property
>  "value" in this example). Detailed discussion is in the JavaBeans
>  spec, which forms the basis of bean property access in most ELs we
>  use.
>
>  -Rahul
>
>
>  > --
>  > Landon Ouyang
>  > Member Technical Staff
>  > ITT Electronics Systems, Radar Systems - Gilfillan
>  > 7821 Orion Ave,
>  > Van Nuys, CA 91406
>  > (818) 901-2982
>  >
>  >
>  > -----Original Message-----
>  > From: Rahul Akolkar [mailto:rahul.akolkar@gmail.com]
>  >
>  > Sent: Friday, April 11, 2008 2:18 PM
>  > To: Jakarta Commons Users List
>  > Subject: Re: [SCXML] W3C specs compatibility and state transition
>  issues
>  >
>  > On Fri, Apr 11, 2008 at 5:01 PM, Ouyang, Landon - ES/RDR -Gil
>  > <Landon.Ouyang@itt.com> wrote:
>  > > I figured out the solution:
>  > >
>  > > I needed to remove the event properties from the conditional
>  > > transitions. So if I change the state to:
>  > >
>  > > <state id="six">
>  > >        <datamodel>
>  > >                <data name="result">
>  > >                        <value>0</value>
>  > >                </data>
>  > >        </datamodel>
>  > >  <transition cond="result.value eq '1'" target="zero"/>
>  > >  <transition cond="result.value eq '0'" target="five"/>
>  > >  <transition target="three" event="display.prev"/>
>  > > </state>
>  > >
>  > > the code will work! Am I missing any other crucial details?
>  > >
>  > <snip/>
>  >
>  > Not really, but couple of comments:
>  >
>  >  * At a quick glance, I suspect you don't need the <datamodel>
>  > specified declaratively, so you can just remove the entire <datamodel>
>  > element (we are setting "result.value" via Java handlers). A brief
>  > discussion about datamodels is here:
>  >
>  >  http://commons.apache.org/scxml/guide/datamodel.html
>  >
>  >  * When I gave the example (below), I intended "fooresult.success" and
>  > "fooresult.numfailures" to be expressions of the flavor bean.property
>  > i.e. fooresult was an instance of:
>  >
>  > class FooResult {
>  >  get/setSuccess()
>  >  get/setNumfailures()
>  > }
>  >
>  > Generally better if you want to return a data structure, rather than
>  > multiple "flat variables" (your example is fine, for one value its
>  > much overhead).
>  >
>  > -Rahul
>  >

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


Mime
View raw message