Re: Need help with SCXML transition cond syntax.
On 1/31/07, Paul Spencer [EMAIL PROTECTED] wrote: Rahul, Works as expected. You may mark the issue as resolved. snip/ Done, and thanks for the quick feedback. -Rahul Thanks again. Paul Spencer
Re: Need help with SCXML transition cond syntax.
Rahul, What am I doing wrong? When the next button is clicked my goal is to go from page1 to page2 if the property Leased is checked on the page1, otherwise go to page2. Neither is happening! When the cancel button is clicked, the transition to menu works as expected. *** * Value of dialog.data fields *** licenseTag = 'test' leased = Boolean.TRUE *** * Dialog configuration for the stat Page 1 *** state id=page1 onentry shale:view viewId=vehicle/addPage1 / /onentry transition cond=${dialogData.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.lease} target=page2 / transition event=faces.outcome cond=${outcome eq 'next'} if cond=${dialog.data.leased eq 'true'} target next=page2 / else target next=review / /else /if /transition transition target=menu event=faces.outcome cond=${outcome eq 'cancel'} / /state *** * Logging *** outcome = next _eventdata = null _eventdatamap = {faces.outcome=null} _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'next'} = true _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'cancel'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialogData.licenseTag eq 'test'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.licenseTag eq 'test'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.lease} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.leased eq 'true'} = false _ALL_NAMESPACES = null _eventdata = null _eventdatamap = null Current States: [page1] Paul Spencer Rahul Akolkar wrote: On 1/30/07, Paul Spencer [EMAIL PROTECTED] wrote: Version 1.1.0-SNAPSHOT I would like a transition to be selected when a bean's field is not empty. If the field is an empty string, , or null I do not want the transition executed. Below is the syntax in JSF EL. #{not empty dialogData.companyId} What is the equivalent in SCXML? transition ... cond= ? / snip/ ${not empty dialogData.companyId} The SCXML implementation often doesn't have the liberty of knowing anything about the expression based on the location of the expression within the document (though cond attribute values are expected to evaluate to booleans, in this particular case). The evaluator Javadoc is here [1], and lists some relevant details. -Rahul [1] http://shale.apache.org/shale-dialog-scxml/apidocs/org/apache/shale/dialog/scxml/ShaleDialogELEvaluator.html Paul Spencer
Re: Need help with SCXML transition cond syntax.
On 1/31/07, Paul Spencer [EMAIL PROTECTED] wrote: Rahul, What am I doing wrong? When the next button is clicked my goal is to go from page1 to page2 if the property Leased is checked on the page1, otherwise go to page2. Neither is happening! When the cancel button is clicked, the transition to menu works as expected. *** * Value of dialog.data fields *** licenseTag = 'test' leased = Boolean.TRUE *** * Dialog configuration for the stat Page 1 *** state id=page1 onentry shale:view viewId=vehicle/addPage1 / /onentry transition cond=${dialogData.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.lease} target=page2 / transition event=faces.outcome cond=${outcome eq 'next'} if cond=${dialog.data.leased eq 'true'} target next=page2 / else target next=review / /else /if /transition snip/ The target of a transition element cannot be determined at runtime (if we think of this in terms of a state chart diagrams, when we start to draw a transition we need to also know the end point/state, can't have it TBD amongst some candidates) -- a slight exception is history (but thats OT, see SCXML WD or Commons SCXML test suite / site for semantics). But another way to look at this is that we simply have compound conditional expressions, i.e. the one transition above whose target we're trying to determine using conditionals (if) is conceptually equivalent to the two transitions below (untested): transition event=faces.outcome cond=${outcome eq 'next' and dialog.data.leased} target=page2/ transition event=faces.outcome cond=${outcome eq 'next' and not dialog.data.leased} target=review/ Ofcourse, if the condition expressions start becoming too involved they can be moved to MBEs or custom EL functions. Other observations probably relevant here: * Generally, all outbound transitions from a view state should be guarded by the faces.outcome event (or they may be followed immediately if the cond is satisfied) * The latest SCXML WD [1] (Jan '06) has removed the target element (though the 0.x line of Commons SCXML supports it for backwards compatibility). It is recommended to use the target attribute of transition instead (and once thats done, it becomes hard to provide more than one based on some conditional logic anyway). The SCXML examples in the Shale test app use the newer variants of any such spec changes. * Upto v0.6 of Commons SCXML, the conds are expected to be mutually exclusive (no two -- or more -- should evaluate to true at the same time in a given scenario). That will lead to non-determinism, and the related error being reported. I think the spec may talk about document order priorities in the next rev. -Rahul [1] http://www.w3.org/TR/scxml/ transition target=menu event=faces.outcome cond=${outcome eq 'cancel'} / /state *** * Logging *** outcome = next _eventdata = null _eventdatamap = {faces.outcome=null} _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'next'} = true _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'cancel'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialogData.licenseTag eq 'test'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.licenseTag eq 'test'} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.lease} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${dialog.data.leased eq 'true'} = false _ALL_NAMESPACES = null _eventdata = null _eventdatamap = null Current States: [page1] Paul Spencer snap/
Re: Need help with SCXML transition cond syntax.
Rahul, See below. Rahul Akolkar wrote: On 1/31/07, Paul Spencer [EMAIL PROTECTED] wrote: Rahul, What am I doing wrong? When the next button is clicked my goal is to go from page1 to page2 if the property Leased is checked on the page1, otherwise go to page2. Neither is happening! When the cancel button is clicked, the transition to menu works as expected. *** * Value of dialog.data fields *** licenseTag = 'test' leased = Boolean.TRUE *** * Dialog configuration for the stat Page 1 *** state id=page1 onentry shale:view viewId=vehicle/addPage1 / /onentry transition cond=${dialogData.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.licenseTag eq 'test'} target=page2 / transition cond=${dialog.data.lease} target=page2 / transition event=faces.outcome cond=${outcome eq 'next'} if cond=${dialog.data.leased eq 'true'} target next=page2 / else target next=review / /else /if /transition snip/ The target of a transition element cannot be determined at runtime (if we think of this in terms of a state chart diagrams, when we start to draw a transition we need to also know the end point/state, can't have it TBD amongst some candidates) -- a slight exception is history (but thats OT, see SCXML WD or Commons SCXML test suite / site for semantics). But another way to look at this is that we simply have compound conditional expressions, i.e. the one transition above whose target we're trying to determine using conditionals (if) is conceptually equivalent to the two transitions below (untested): transition event=faces.outcome cond=${outcome eq 'next' and dialog.data.leased} target=page2/ transition event=faces.outcome cond=${outcome eq 'next' and not dialog.data.leased} target=review/ My previous configuration was simply a summary of my attempts. Although I my first attempt matches your suggestion, I did not included it in the example. Below is the configuration you suggested. I suspect that SCXML is not getting the properties from dialog.data because the value of dialog.data.leased is always false. *** * Value of dialog.data fields *** leased = Boolean.TRUE *** * Dialog configuration for the stat Page 1 *** state id=page1 onentry shale:view viewId=vehicle/addPage1 / /onentry transition event=faces.outcome cond=${outcome eq 'next' and dialog.data.leased} target=page2 / transition event=faces.outcome cond=${outcome eq 'next' and not dialog.data.leased} target=review / transition target=menu event=faces.outcome cond=${outcome eq 'cancel'} / /state *** * Logging *** outcome = next _eventdata = null _eventdatamap = {faces.outcome=null} _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'next' and dialog.data.leased} = false _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'next' and not dialog.data.leased} = true _ALL_NAMESPACES = null _ALL_NAMESPACES = {shale=http://shale.apache.org/dialog-scxml, =http://www.w3.org/2005/07/scxml} ${outcome eq 'cancel'} = false _ALL_NAMESPACES = null _eventdata = null _eventdatamap = null Current States: [review] Ofcourse, if the condition expressions start becoming too involved they can be moved to MBEs or custom EL functions. Can you point me to an example of this? Other observations probably relevant here: * Generally, all outbound transitions from a view state should be guarded by the faces.outcome event (or they may be followed immediately if the cond is satisfied) This is good to know. * The latest SCXML WD [1] (Jan '06) has removed the target element (though the 0.x line of Commons SCXML supports it for backwards compatibility). It is recommended to use the target attribute of transition instead (and once thats done, it becomes hard to provide more than one based on some conditional logic anyway). The SCXML examples in the Shale test app use the newer variants of any such spec changes. I only used target in an attempt to get the transition working. I was using an example from Commons SCXML's wiki. * Upto v0.6 of Commons SCXML, the conds are expected to be mutually exclusive (no two -- or more -- should evaluate to true at the same time in a given scenario). That will lead to non-determinism, and the related error being reported. I think the spec may talk about document order priorities in the next rev. This matches my expectations. I only had two potentially evaluating to true for debugging and testing. Once in production only 1 transition will evaluate to true. -Rahul snip Paul Spencer
Re: Need help with SCXML transition cond syntax.
On 1/31/07, Paul Spencer [EMAIL PROTECTED] wrote: Rahul, See below. Rahul Akolkar wrote: On 1/31/07, Paul Spencer [EMAIL PROTECTED] wrote: snip/ My previous configuration was simply a summary of my attempts. Although I my first attempt matches your suggestion, I did not included it in the example. Below is the configuration you suggested. I suspect that SCXML is not getting the properties from dialog.data because the value of dialog.data.leased is always false. snap/ Bah, OK, it seems I missed one todo in code, about three lines needed to tie the application variable resolver to the Commons SCXML context for greater EL capabilities (such as this, arbitrary expressions beyond simply calling action state MBEs etc). Could you file a JIRA issue for this? Thanks! In any case, I intend to get to this later this afternoon, so there will be one soon enough. Ofcourse, if the condition expressions start becoming too involved they can be moved to MBEs or custom EL functions. Can you point me to an example of this? snip/ What I meant was if we ever get into ${A and B and C or D ...} style expressions, perhaps the procedural bits can be captured in a managed bean method for brevity of the dialog descriptor. I only used target in an attempt to get the transition working. I was using an example from Commons SCXML's wiki. snap/ You're welcome to whack any bits on the wiki that are outdated / incorrect, if you feel like it. This matches my expectations. I only had two potentially evaluating to true for debugging and testing. Once in production only 1 transition will evaluate to true. snip/ Sounds good. -Rahul
Re: Need help with SCXML transition cond syntax.
Rahul, Rahul Akolkar wrote: snip Bah, OK, it seems I missed one todo in code, about three lines needed to tie the application variable resolver to the Commons SCXML context for greater EL capabilities (such as this, arbitrary expressions beyond simply calling action state MBEs etc). Could you file a JIRA issue for this? Thanks! In any case, I intend to get to this later this afternoon, so there will be one soon enough. https://issues.apache.org/struts/browse/SHALE-404 snip -Rahul Thank you for you help on this. Paul Spencer
Re: Need help with SCXML transition cond syntax.
Rahul, Works as expected. You may mark the issue as resolved. Thanks again. Paul Spencer Rahul Akolkar wrote: On 1/30/07, Paul Spencer [EMAIL PROTECTED] wrote: Version 1.1.0-SNAPSHOT snip/ Could you try an updated snap, one thats post this issue: http://issues.apache.org/struts/browse/SHALE-403 -Rahul I would like a transition to be selected when a bean's field is not empty. If the field is an empty string, , or null I do not want the transition executed. Below is the syntax in JSF EL. #{not empty dialogData.companyId} What is the equivalent in SCXML? transition ... cond= ? / Paul Spencer
Re: Need help with SCXML transition cond syntax.
On 1/30/07, Paul Spencer [EMAIL PROTECTED] wrote: Version 1.1.0-SNAPSHOT I would like a transition to be selected when a bean's field is not empty. If the field is an empty string, , or null I do not want the transition executed. Below is the syntax in JSF EL. #{not empty dialogData.companyId} What is the equivalent in SCXML? transition ... cond= ? / snip/ ${not empty dialogData.companyId} The SCXML implementation often doesn't have the liberty of knowing anything about the expression based on the location of the expression within the document (though cond attribute values are expected to evaluate to booleans, in this particular case). The evaluator Javadoc is here [1], and lists some relevant details. -Rahul [1] http://shale.apache.org/shale-dialog-scxml/apidocs/org/apache/shale/dialog/scxml/ShaleDialogELEvaluator.html Paul Spencer