Thank you Kris for the explanation. It helps.<div><br><br><div class="gmail_quote">On Thu, Nov 6, 2008 at 3:42 PM, Kris Verlaenen <span dir="ltr">&lt;<a href="mailto:kris.verlaenen@cs.kuleuven.be" target="_blank">kris.verlaenen@cs.kuleuven.be</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">





<div bgcolor="#ffffff"><div>
<div>&gt; If I try to set variable that hasn&#39;t been declared in the ruleflow 
header - the variables section. I get following error:<br>&gt; &quot;Could not find 
variable someVariableName<br>&gt; Continuing without setting value&quot;</div>
<div><font size="2" face="Arial"></font>&nbsp;</div>
</div><div>
<div><font size="2" face="Arial">Actually, the problem here is&nbsp;not that you 
cannot set the value of a variable that is not defined in the process.&nbsp; It 
is possible to simply set the value of a variable on a variable context 
instance, even if the variable has not been defined.&nbsp; 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.&nbsp; Whenever you try to set the value of a 
variable, I must first search for the right variable scope.&nbsp; This searching 
is based on the definition of these variables.&nbsp; At this point, if it cannot 
find the variable, it simply does not set the value.&nbsp; There are however 
other option:</font></div>
<div><font size="2" face="Arial">&nbsp; - set the value on the top-level context 
(i.e. process-level variables)</font></div>
<div><font size="2" face="Arial">&nbsp; - set the value on the lowest-level context 
(the most deeply nested container)</font></div>
<div><font size="2" face="Arial">&nbsp; - allow the user to specify the 
context</font></div>
<div><font size="2" face="Arial">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.</font></div>
<div><font size="2" face="Arial"></font>&nbsp;</div>
<div><font size="2" face="Arial">You can also manually select the scope yourself in 
your action, e.g. setting to the process-level scope can be done 
using:</font></div>
<div><font size="2" face="Arial">((VariableScopeInstance) 
(context.getProcessInstance().getContextInstance(VariableScope.VARIABLE_SCOPE))).setVariable(&quot;name&quot;, 
value);</font></div>
<div><font size="2" face="Arial"></font>&nbsp;</div>
<div><font size="2" face="Arial">Of course, a Util class could hide these internal 
structures for you.</font></div>
<div><font size="2" face="Arial"></font>&nbsp;</div><font color="#888888">
<div><font size="2" face="Arial">Kris</font></div></font></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>