Home » ADF » Custom Error Message for Business Component
Custom Error Message for Business Component

Custom Error Message for Business Component

In my previous post, I had explained how to Display Custom error message to user to extend DCErrorHandlerImpl and register to Databinding.cpx file.

Well, there’s another way to do the same. Follow these steps…

  1. Rigth Click on Model Project and select project properties
    image001
  2. Then select “Option” under Business Component
    image002
  3. To add custom message bundle class for your project, click New and add bundle Class.
    image003
  4. Now MyCustomBundle class is generated by framework which extends ListREsourceBundle as follows
    package adftutorials.com.model;
    import java.util.ListResourceBundle;
    public class MyMessageBundle extends ListResourceBundle {
    private static final Object[][] sMessageStrings = new String[][] {
    {"25013","Duplicate Employee Id Found."}
    };
    
    /**Return String Identifiers and corresponding Messages in a two-dimensional array.    */
    
    protected Object[][] getContents() {
    return sMessageStrings;
    }
    }
    
  5. Edit the two-dimensional String array “sMessageStrings” in the custom message bundle class to add your custom message. In this example I’m writing custom message for error code.
    “25013 – To many Object match the primary key” when duplicate record found.
  6. Therefore, I just add my custom message for that
    private static final Object[][] sMessageStrings = new String[][] {
    {"25013","Duplicate Employee Id Found."}
    };
    
  7. Run Application Module, create new row in Employee ViewObject with same EmployeeId that already exist and display your own custom message to the user.
    image004

About Manish Pandey

Manish Pandey is a Senior Developer with more than 3 years of experience in JAVA Programming. Currently enhancing skills in ADF.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>