叽叽歪歪

    follow me on Twitter

    Event Handlers

    |

    Event handlers encapsulate logic that pertains to multiple items where it is easier to centralize the code around an event rather than around individual item behavior. You, the developer, determine when an event handler is easier to read than a set of item handlers.

     

    Very complex cross–item behaviors belong in the event handler, while very simple single item behaviors belong in the item handlers. You can call item handlers from event handlers.

     

    For example, you may code an event handler to populate many items on POST–QUERY. Rather than writing item handlers for each of the items, you could encapsulate all of the logic in a single event handler.

     

    Since an event handler handles only one event, it does not need an EVENT parameter.In fact, it should not take any parameters.

     

    Event handlers are named after the triggers, replacing dashes with underscores (for example, the PRE–QUERY event handler is PRE_QUERY).

     

    Common Event Handlers

    PRE_QUERY: Populates items with values needed to retrieve the appropriate records

    POST_QUERY: Populates non–base table items.

    WHEN_CREATE_RECORD: Populates default values (when using the default value property is insufficient)

    WHEN_VALIDATE_RECORD: Validates complex inter–item relationships

    0 comments:

    Post a Comment