Thanks, I have resolved the problem with some modified to the Drools source, maybe you can take a loot at my blog: <a href="http://wangzaixiang.blogspot.com">wangzaixiang.blogspot.com</a>, (In chinese, but i post some source code)<br>
<br><div class="gmail_quote">On Sat, Mar 27, 2010 at 8:23 AM, Peter Butler <span dir="ltr">&lt;<a href="mailto:peter.butler@141.com">peter.butler@141.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Wang<br>
<br>
I&#39;ve done something similar with questions in an insurance application.<br>
I found it easiest to split the map entries up into separate objects and<br>
put them all into working memory:<br>
<br>
class Answer {<br>
String questionCode;<br>
String answer;<br>
AnswerSet answerSet;<br>
// ...getters and setters omitted<br>
}<br>
<br>
class AnswerSet {<br>
String answerSetCode;<br>
List&lt;Answer&gt; answers;<br>
}<br>
<br>
The rule looks something like:<br>
<br>
when<br>
set1 : AnswerSet(code == &#39;answerSet1&#39;)<br>
answer1 : Answer(questionCode == &#39;question1&#39;, answer == &quot;100&quot;, answerSet<br>
== set1)<br>
answer2 : Answer(questionCode == &#39;question2&#39;, answer == &#39;200&#39;, answerSet<br>
== set1)<br>
then<br>
answer1.hidden = true<br>
<br>
These are also easy to convert into a DSL. The &quot;answerSet&quot; in the rule<br>
is used to make sure both answers have come from the same set of answers<br>
(if that&#39;s important to you).<br>
<br>
I did read somewhere in the docs that MVEL can handle maps in the same<br>
way as beans, but I&#39;m not sure if this is correct.<br>
<br>
Cheers<br>
<font color="#888888"><br>
Peter<br>
</font><div><div></div><div class="h5"><br>
王在祥 wrote:<br>
&gt; I have a requirement of run rules on dynamic map instead of POJO, for<br>
&gt; example:<br>
&gt;<br>
&gt; *when<br>
&gt; Map(* TransCode == &quot;LOGIN&quot; , userName == &quot;wangzx&quot;, password == &quot;123456&quot; )<br>
&gt; *then<br>
&gt; doSth1()<br>
&gt;<br>
&gt; when<br>
&gt; Map( *TransCode = &quot;SaveOrder&quot; userName == &quot;wangzx&quot; category == &quot;Book&quot;)<br>
&gt; *then<br>
&gt; doSth2()<br>
&gt;<br>
&gt; *<br>
&gt; the Fact is not a Java Bean, but a dynamic map&lt;String, Object&gt;, so the<br>
&gt; TransCode == &quot;Login&quot; is what we means map(&quot;TransCode&quot;) == &quot;Login&quot;.<br>
&gt;<br>
&gt; By using map insteam of POJO, we can build a rules run on the message<br>
&gt; dispatch, since there is a lot of Message Types, and each message type<br>
&gt; has different schema, so using dynamic types is more flexible than POJO.<br>
&gt;<br>
&gt; Can someone tell me how can it be supported in drools? Very thanks.<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
<div><div></div><div class="h5">&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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>
</div></div></blockquote></div><br>