I want to make an array and pass it to a method in the RHS but can't when I
use mvel.  If I use mvel then java new Object[3] causes compile errors.  If
I use the mvel syntax the object is not an real array, only a string in
mvel's special array notation which is not useful for the functions I am
trying to call.  Working example:

rule "Array bug"
        dialect "java" // explicit java or mvel barfs on new Object[];
    when
        Message( )
    then
        Object[] logArgs = new Object[3];
        logArgs[0] = "Sample string";
        logArgs[1] = "Another string";
        logArgs[2] = "And done";
        System.out.println( "Array was "+$m );
end

If you change dialect above to mvel the code no longer compiles.  If you
change it to mvel and use the mvel list syntax ["Sample string", "Another
string", "And done"] you don't have an array so methods requiring an array
do not work.  Concrete example: I want to log 3 values using a logging
framework.  Many logging frameworks (like sl4j) support a notation like
Logger.warn("My name is {} and you killed my {}", array); where array has
"Inigo Montonya" and "father" for values.

Thanks for any advice!
Zack


--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-use-lists-in-RHS-when-using-MVEL-tp3448430p3448430.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to