Skip to Content
Former Member
Jun 18, 2015 at 10:26 PM

PrepareInterceptor - changed vaue of attribute not reflecting in db or hmc



This might be a basic question, but have just started working with interceptors so please bear with me.

So what I am trying to do is for the B2BCustomer, by default the Original UID is grayed out and it takes the value of whatever is there in the ID field.

alt text

So what I am trying to do here is for the B2BCustomer I have added two new attributes. These are working fine from the hmc i.e I am able to save values in it from the Administration tab in hmc for B2BCustomer. Now what I want to do is that for Original UID, I want the value as the concatinated value of the two string variables which I have declared.

So for this I have created my Interceptor which implements the PrepareInterceptor. I have also made the necessary spring configs for it.

Following is what I have done :

 public class B2BCustomerSaveInterceptor implements PrepareInterceptor
     public void onPrepare(final Object model, final InterceptorContext ctx) throws InterceptorException
         if (model instanceof B2BCustomerModel)
             final B2BCustomerModel b2bCustomer = (B2BCustomerModel) model;
             b2bCustomer.setOriginalUid(b2bCustomer.getDealerCode() + "-" + b2bCustomer.getInternetUserId());
             System.out.println("New OriginalUID : " + b2bCustomer.getOriginalUid());

So the interceptor is called when I try to save the B2BCustomer in hmc. And the print statement shows the correct value of the Original UID attribute like I want it to be.

alt text

But this thing is not getting persisted back in db. Do I need to explicitly call any other method apart from just intercepting and changing the value for saving the above value of Original UID to db.

I know its only a line of code that I am missing here. If anybody can point that out, it would be great.


3270-untitled.png (10.3 kB)