OnView Hook

Overview

Event fired when entity is loading from database.

This hook may be StackOverflowError-prone when used inappropriately.

You have to avoid any kinds of re-loading entity from database within onView hooks. Otherwise you may end up with onView hook indirectly and infinitely calling itself.

Be aware that it's easy to do that unintentionally - for example by using SearchRestrictions.belongsTo(String, String, String, Long) or SearchRestrictions.belongsTo(String, DataDefinition, Long) criterion factory method, which internally loads an Entity for given plugin, model and id.
In such cases you have to use SearchRestrictions.belongsTo(String, Entity) which doesn't cause entity load.

Therefore, treat this hook as potentially dangerous and always check your code in respect of performing any Entity loading.

Obey this rule, and world will be safe.

 

Common Attributes

name

type

required

default value

description

class

string

yes

none

Name of the class defining hook.

method

string

yes

none

Name of the method defining hook.

Example

<onView class="com.sample.SampleHook" method="fillSomeNotPrsistentFields" />

Hook method signature

public void hookName(final DataDefinition dataDefinition, final Entity entity) {
    // ...
}