[rules-users] How to trigger update when modifying a list attribute?

Wolfgang Laun wolfgang.laun at gmail.com
Thu Aug 16 08:17:22 EDT 2012


Object is an unlikely class name for something that contains a list
and provides a method hasInList().

Anyway, the RHS must call
   update( $obj );
after modifying the list.

Note that using

   SomeObject( theList contains "item" )

is the usual idiom for testing for a single element. For a subset
test, you'll have to use "eval" (as you've shown). If this is frequent
enough, consider implementing a custom evaluator "supersetOf".

-W


On 16/08/2012, Paulo Reis <casmeiron at gmail.com> wrote:
> Hi guys,
>
> I'm having the follow issue: I have an object that contains a list. The
> object is inserted on the memory but not the list, so I want to do something
> like this:
>
> when
> 	$obj: Object()
> 	eval($obj.hasInList("item"))
> then
> 	$obj.replaceInList("item", "replacement");
> end
>
> How do I trigger the update for $obj? I've tried to add Java Beans support
> but that didn't help, neither @watch nor @PropertyChangeSupport on java
> class.
>
> Im watching the debug but don't see the object being modified and I've rules
> that were triggered that shouldn't be because the value was already
> changed.
>
> Inserting the list on the working memory won't help me, as I need to search
> like this:
>
> when
> 	$obj: Object()
> 	eval($obj.hasInList("item item1 item2 item3"))
> then
> 	$obj.replaceInList("item item1 item2 item3", "singleItem")
> end
>
> The example above search for several items (each one is a list element), so
> I need to replace them all for a single element.
>
> Any thoughts?
>
> Thanks in advance.
>
> Paulo Reis
> casmeiron at gmail.com
>
>
>
>


More information about the rules-users mailing list