[rules-users] Drools Flow - new variables

Michal Bali michalbali at gmail.com
Thu Nov 6 17:51:31 EST 2008


Thank you Kris for the explanation. It helps.

On Thu, Nov 6, 2008 at 3:42 PM, Kris Verlaenen <
kris.verlaenen at cs.kuleuven.be> wrote:

>  > If I try to set variable that hasn't been declared in the ruleflow
> header - the variables section. I get following error:
> > "Could not find variable someVariableName
> > Continuing without setting value"
>
>  Actually, the problem here is not that you cannot set the value of a
> variable that is not defined in the process.  It is possible to simply set
> the value of a variable on a variable context instance, even if the variable
> has not been defined.  The problem here however is that variable contexts
> can be nested: a composite node can define a sub-context, where the
> variables defined in this context are only accessible from inside that
> composite node.  Whenever you try to set the value of a variable, I must
> first search for the right variable scope.  This searching is based on the
> definition of these variables.  At this point, if it cannot find the
> variable, it simply does not set the value.  There are however other option:
>   - set the value on the top-level context (i.e. process-level variables)
>   - set the value on the lowest-level context (the most deeply nested
> container)
>   - allow the user to specify the context
> I think I might change the default behaviour to setting the value on the
> process-level scope, as that is how I already do it when getting the value
> of a variable.
>
> You can also manually select the scope yourself in your action, e.g.
> setting to the process-level scope can be done using:
> ((VariableScopeInstance)
> (context.getProcessInstance().getContextInstance(VariableScope.VARIABLE_SCOPE))).setVariable("name",
> value);
>
> Of course, a Util class could hide these internal structures for you.
>
> Kris
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081106/4ccd4250/attachment.html 


More information about the rules-users mailing list