Skip to Content
author's profile photo Former Member
Former Member

InitDefaultInterceptor not capturing values entered during creation

Hi,all I implemented an InitDefaultsInterceptor for a Product as follows:

public class DefaultInterceptor implements InitDefaultsInterceptor { public void onInitDefaults(final Object obj,final InterceptorContext arg1) {

                               if(obj instanceof ProductModel)
                                        final ProductModel productModel = (ProductModel) obj;

} I registered this interceptor as follows in the file myextension-spring.xml:

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jul 25, 2016 at 12:34 PM

    The InitDefaultsInterceptor fires when the model is created. This is before it saves any data to it. The model will always be empty at this point. It's meant for you to set default values.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 25, 2016 at 02:15 PM

    Hello Rachit,

    There are different types of interceptors meant for different stages in model's lifecycle. :

    As Andrew explains: Init Defaults Interceptor is triggered when the model is populated with defaults values. You may look at this table to decide which type of Interceptor suits your requirement.

    Hope this helps.

    Br, Shwetha

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.