cancel
Showing results for 
Search instead for 
Did you mean: 

Getting old Value from Prepare interceptor

Former Member
0 Kudos

Hi, I'm using a prpareInterceptor,to save the newatt value and get the oldattr value and save it into another filed.The problem that the interceptor save in the two fields the value of the newattr.

if (ctx.getModelService().isModified(voyageModel)) { if (ctx.isModified(vModel, VModel.NEWATTR)) { final VModel oldVModel = modelService.get(vModel.getPk()); vModel.setOldAttr(oldVModel.getNewAttr()); }

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
 ItemModelContext itemModelContext = ModelContextUtils.getItemModelContext(model);
 Attributetype oldValue =  (Attributetype) itemModelContext.getOriginalValue(model.ATTRIBUTE);


OR

 ItemModelContextImpl modelContext = item.getItemModelContext();
  Object oldValue;
  
  if (modelContext.isLoaded(attribute))
  {
      oldValue = modelContext.getOriginalValue(attribute);
  }
  else
  {
      oldValue = modelContext.getAttributeProvider().getAttribute(attribute);
  }

Answers (1)

Answers (1)

0 Kudos

Object obj = getModelValueHistory(item).getOriginalValue("attributeName");

private ModelValueHistory getModelValueHistory(final ItemModel itemModel) { final ItemModelContext itemModelContext = ModelContextUtils.getItemModelContext(itemModel); if (itemModelContext != null) { return ((ItemModelContextImpl) itemModelContext).getValueHistory(); } return null; }