[rules-users] Getting the return from a funcion

Chandana Pingle chandana.pingle at intunity.com.au
Wed Sep 9 17:41:55 EDT 2009


hi

from what i see from the code given, System.out.println("ERROR: " + word);

u missed the $ symbol,it should be

System.out.println("ERROR: " + $word);

Hope that works

chandana

On 9/10/09, Leandro Carvalho <leandrodcarvalho at gmail.com> wrote:
> Hi! I'm new here and a have a doubt about rules and functions in Drools.
>
> I have this rule:
>
> rule "ProductDescription validation"
>     when
>         $listing : Listing( $description:productDescription != null )
>         eval( $description.getTitle() != null )
>         eval( hasForbiddenWordsSet( wordsSet, $description.getTitle() ) )
>     then
>         System.out.println("ERROR!");
> end
>
> And this function:
>
> function boolean hasForbiddenWordsSet(Set wordsSet, String value) {
> #do something useful here
> }
>
>
> And everything works fine. But now I want that function
> "hasForbiddenWordsSet" return a String. For example to print at "then".
> I tried something like this:
>
> rule "ProductDescription validation"
>     when
>         $listing : Listing( $description:productDescription != null )
>         eval( $description.getTitle() != null )
>         $word : hasForbiddenWordsSet( wordsSet, $description.getTitle() )
>     then
>         System.out.println("ERROR: " + word);
> end
>
> function String hasForbiddenWordsSet(Set wordsSet, String value) {
> #do something useful here
> }
>
> But it doesn't work, tried some other things and still no success.
>
> Could someone help me?
>
> Thanks in advance.
>
> --
> Leandro Carvalho
>



More information about the rules-users mailing list