Monday, April 19, 2010

Bit #13 - Overriding create() to set the default value for a View Row attribute

One way to set the default value for a View Row attribute is to override its create() method in your custom View Row Implementation and call the attribute setter method to set its default value. Calling the attribute setter from inside the overridden create() method does not mark the new row as changed and it behaves like declaratively assigning a default value for the attribute. An example follows.

Example:

    @Override
    protected void create(AttributeList attributeList) {

        super.create(attributeList);

        // set main company's telephone number as default
        this.setPhoneNumber("6145551212");
    }


Context:

View Object Row Implementation

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...