Unintended execution of Extensions

In one of my preprocessor extensions attached to Item A, I load the related content item of item B. I need to update a field in Item B.

The problem I just noticed is that when I update a field in Item B from Item A extension, all the preprocessor extensions registered to Item B also get executed. This is causing some unintended side effect. Is there any way to prevent those extensions from getting executed automatically?

I tried to put null check conditions by reading following values in the begining of the extension and do a return before the execution of the preprocess logic. This was assuming that these values may not get populated when the exit gets invoked.

String title = request.getParameter(“sys_title”);
String sysCommand = request.getParameter(“sys_command”);
String actionType = request.getParameter(“DBActionType”);

However, this check also doesnot appears to working as the value do get populated. Is there any way to prevent these preprocess extensions from getting executed?

thanks
Manvinder

Is there any other parameter I can possibly use to distinguish from where the extension is being invoked?

manvinder

One technique that I have used is to add a “Private Object” to the IPSRequestContext.

If you set the private object in the extensions registered for Item A, and check for the presence of the private object in the extensions registered to Item B, then you will know if the update occurred as a result of your other operation.

The NavFolderEffect (and some other components) use this technique successfully.

Dave

Thanks Dave…thats a good idea.
So the logic is that I would set a private object using setPrivateObject(object, object) in item A, and then try to retrieve it using getPrivateObject(Object) in itemB. So if the item is present in itemB , then it means that the invoke of extension is as a result of item A, and I can simply exit out.

Else if the private object is not present in item B, then it means the ext is invoked because of item B, and I can continue with the ext logic.

Is the above logic correct?

manvinder

Yes, you’ve got it right. The other thing you should probably do is remove the private object (or set it to NULL) at the end of the routine that processes Item A.

Dave

Dave,

Unfortunately privateSessionObject() solution doesnot seems to work either. I did populate the value in Item A session.

request.setPrivateObject(“urlKey”, “urlInvoke”);

As expected, when I invoked the load for item B in item A extension, item B extension got invoked. In the first invoke, it was able to read the value for urlKey.

String urlKeyVal=(String)request.getPrivateObject(“urlKey”);

However, item B extension got called few more times during the call of loadItems() itself.

In one of the invokes the value of urlKey is not available. Not only this, I checked for sys_command and dbActionType value as well. They were populated with “modify” and “update” values respectively. So there was no filter flag to prevent the call from entering the business logic of item B extension. So I was not able to prevent the call from entering the preprocess logic

Also this requirement is very critical for us and we need to make this working.

thanks
Manvinder