Hi Caroline:
I recently added application data to my project and here's what I did to get
it to work.
1. Add this to your drl file after your import statements.
<application-data
identifier="messages">java.util.ArrayList</application-data>
2. Set your application data to working memory.
workingMemory.setApplicationData("messages", new ArrayList());
Now fire your rules.
3. Consequence using application data.
<java:consequence>
messages.add(new RuleMessage("141", Violation.EXCEEDS,
Recipient.CSR, "Car not garaged at primary residence exceeds guidelines."));
</java:consequence>
4. After executing your rules, get the application data from your working
memory.
List messages = (List) workingMemory.getApplicationData("messages");
Doug
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 30, 2005 5:52 AM
To: [email protected]
Subject: [drools-user] Application-Data Problem
Hi,
Sorry to ask a question thats been asked before but I couldn't
find a satisfactory reply. Is it possible to use application-data in the
following manner:
<application-data identifier="t">Transaction</application-data>
<rule name="rule1">
...............
<java:consequence>
t.setActionName("red");
</java:consequence>
</rule>
and then from my program do workingMemory.getApplicationData("t");
Right now I am receiving a Null Pointer exception in the consequence
block. This is solved by doing
<java:consequence>
te = new Transaction();
t.setActionName("red");
</java:consequence>
However obviously then when this si called
workingMemory.getApplicationData("t"), t does not hold the modified value.
Thanks
Caroline Grima
E-MAIL CONFIDENTIALITY NOTICE:
The contents of this e-mail message and any attachments are intended solely
for the addressee(s) and may contain confidential and/or legally privileged
information. If you are not the intended recipient of this message or if
this message has been addressed to you in error, please immediately alert
the sender by reply e-mail and then delete this message and any attachments.
If you are not the intended recipient, you are notified that any use,
dissemination, distribution, copying, or storage of this message or any
attachments is strictly prohibited.