Sunday 18 May 2014

Retrieve the Old Value of an Attribute in the View Object

This blog we will see how to get the old value of an attribute.


      Let’s consider the situation, if we have an attribute of a view object but we will update the attribute of the view object. Suppose we need to access the old value of the attribute, we need to follow the below steps.
 

     1. Create a transient attribute name as “OldFirstName” in the EmployeesVO view object.
     2. Generate the EmployeesVORowImpl.java on top the view object. While creating the            implementation class we need to follow the below image.


      3. Now open the EmployeesVORowImpl.java, By default the getOldFirstName method looks       like the given below.
    /**
     * Gets the attribute value for the calculated attribute OldFirstName.
     * @return the OldFirstName
     */
    public String getOldFirstName() {
        return (String) getAttributeInternal(OLDFIRSTNAME);
    }


       4. Now we need to edit the same method like below.
    /**
     * Gets the attribute value for the calculated attribute OldFirstName.
     * @return the OldFirstName
     */
    public String getOldFirstName() {
        byte status = EntityImpl.STATUS_UNMODIFIED;
        return (String) getAttributeInternal(FIRSTNAME, status);
    }


   Now run your application and you will get the old value.


  Thanks...

No comments:

Post a Comment