<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
You should initialise your globals and then pass them into the session.<BR>
Your rule file will have:
<PRE>
global java.lang.String recipients
global java.lang.String to
global java.lang.String cc

</PRE>
On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@ wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Thanks for your help , Sudhir, 

I used 

rule
when $a:A(b.z.s==&quot;test&quot;);
then
end

And that solved my problem.

But I would like to know one more information about global variables.

package...
dialect java
import ..,

global java.lang.String recipients=&quot;<A HREF="mailto:divya@gmail.com">divya@gmail.com</A>&quot;
global java.lang.String to=&quot;<A HREF="mailto:xyz@yahoo.com">xyz@yahoo.com</A>&quot;
global java.lang.String cc=&quot;<A HREF="mailto:abc@gmail.com">abc@gmail.com</A>&quot;

rule
when when $a:A(b.z.s==&quot;divya&quot;);
then
$a.setRecipients(recipients);
$a.setTo(to);
$a.setCC(cc);
update($a)
end

Is this feasible with Drools. I get 

unable to comile myfile.drl file
[9,40]: unknown:9:40 mismatched token: [@49,201:201='=',&lt;71&gt;,9:40];
E

exception. Could you please help me with this too.


Thanks
-D








Sudhir M-2 wrote:
&gt; 
&gt; Hi D,
&gt; I don't know which version of drools are you using. If u are using drools
&gt; 4
&gt; or higher you can use 'from'  to write rules on nested objects. All u need
&gt; to do is insert the root pbject in the working memory
&gt; 
&gt; Regards,
&gt; sudhir.
&gt; 
&gt; On Mon, Feb 23, 2009 at 2:56 PM, Divya Rajendranath &lt;
&gt; <A HREF="mailto:divya.rajendranath@gmail.com">divya.rajendranath@gmail.com</A>&gt; wrote:
&gt; 
&gt;&gt; Hi,
&gt;&gt;
&gt;&gt; I am planning to use Drools - JBoss Rules Engine. My requirement is to
&gt;&gt; disburse mails from my application to different groups based on various
&gt;&gt; criteria. I want to use Drools here.
&gt;&gt;
&gt;&gt; My object structure is as follows:
&gt;&gt;
&gt;&gt; class A{
&gt;&gt;
&gt;&gt; String B = &quot;&quot;;
&gt;&gt;
&gt;&gt; B b;
&gt;&gt;
&gt;&gt; C c;
&gt;&gt; }
&gt;&gt;
&gt;&gt; Hence Obj A has embedded objects within it, and obj B and C further has
&gt;&gt; embedded objects.
&gt;&gt;
&gt;&gt; class B {
&gt;&gt;
&gt;&gt; String X;
&gt;&gt;
&gt;&gt; Z z;
&gt;&gt;
&gt;&gt; }
&gt;&gt;
&gt;&gt; class Z{
&gt;&gt;
&gt;&gt; String t;
&gt;&gt;
&gt;&gt; String s;
&gt;&gt;
&gt;&gt; }
&gt;&gt;
&gt;&gt; The decision on sending the mails based on the fields in embedded objects
&gt;&gt; of A. I pass instance of A to Drools
&gt;&gt;
&gt;&gt; Format of drl file:
&gt;&gt;
&gt;&gt; package...;
&gt;&gt;
&gt;&gt; import ..;
&gt;&gt;
&gt;&gt; rule &quot;Test&quot;
&gt;&gt;
&gt;&gt; when $a:A(B(Z(s == &quot;testvalue&quot;)))
&gt;&gt;
&gt;&gt; then
&gt;&gt;
&gt;&gt; $a.setSomething();
&gt;&gt;
&gt;&gt; update($a);
&gt;&gt;
&gt;&gt; end
&gt;&gt;
&gt;&gt; I wanted to know if this (accessing fields in embedded/child object) is
&gt;&gt; feasible with Drools.
&gt;&gt;
&gt;&gt; I get an error saying &quot;UNable to compile myfile.drl when i try to fo
&gt;&gt; this.
&gt;&gt;
&gt;&gt; Could some one look into this issue and let me know the reason for this ?
&gt;&gt;
&gt;&gt;
&gt;&gt;
&gt;&gt; Thanks
&gt;&gt;
&gt;&gt; -D
&gt;&gt;
&gt;&gt; _______________________________________________
&gt;&gt; rules-users mailing list
&gt;&gt; <A HREF="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A>
&gt;&gt; <A HREF="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A>
&gt;&gt;
&gt;&gt;
&gt; 
&gt; _______________________________________________
&gt; rules-users mailing list
&gt; <A HREF="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A>
&gt; <A HREF="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A>
&gt; 
&gt; 

</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>