Difference between revisions of "Codeunit/Formevents"
Jump to navigation
Jump to search
old>Admin |
|||
(22 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
== | Form events fires different actions during execution of a solution | ||
== Creating the codeunit == | |||
# Make sure that '''p2eShared.jar''' is included in the project | |||
# Create a new class that extends | |||
com.tsnocode.codeunit.CodeunitFormevents | |||
LIST level event hooks | == LIST level event hooks == | ||
public String appendListPageHead() { return ""; } | public String appendListPageHead() { return ""; } | ||
Line 11: | Line 15: | ||
public void beforeRenderList() throws Exception {} | public void beforeRenderList() throws Exception {} | ||
ITEM level event hooks | |||
==== LIST execution order ==== | |||
# '''beforeSelectList''' | |||
# Gather form data from database | |||
# '''beforeRenderList''' | |||
# Return list to user | |||
== ITEM level event hooks == | |||
public String appendItemPageHead() { return ""; } | public String appendItemPageHead() { return ""; } | ||
Line 26: | Line 37: | ||
== Event firing global == | ==== ITEM execution order: viewing data ==== | ||
# '''beforeSelectItem''' | |||
# Gather form data from database | |||
# '''beforeRenderItem''' | |||
# Return form to user | |||
==== ITEM execution order: posting data ==== | |||
# '''beforeSelectItem''' | |||
# Gather form data from database | |||
# '''beforeChangeItem''' | |||
# Update field values | |||
# '''beforeUpdateItem''' | |||
# Write changes to database | |||
# '''afterUpdateItem''' | |||
# if NO OTHER ACTION: | |||
#* '''afterUpdateRedirectActive''' | |||
#* if TRUE | |||
#** '''afterUpdateRedirectContent''' | |||
# Return content to user | |||
== FILTER event hooks == | |||
Filters will help you build customized permission schemes | |||
dataFilterActive() {} | |||
dataFilterHandler(StringBuilder sql) { return sql; } | |||
In some cases you only want the filter to trigger for either LIST or ITEM commands | |||
itemFilterActive() {} | |||
itemFilterHandler(StringBuilder sql) { return sql; } | |||
listFilterActive() {} | |||
listFilterHandler(StringBuilder sql) { return sql; } | |||
== Event firing details == | |||
==== Event firing global ==== | |||
The following events are ALLWAYS fired | The following events are ALLWAYS fired | ||
* beforeSelectList | |||
* beforeSelectItem | * beforeSelectItem | ||
* beforeChangeItem | * beforeChangeItem | ||
Line 33: | Line 82: | ||
* afterUpdateItem | * afterUpdateItem | ||
== Event firing reserved for normal users | ==== Event firing in UI (reserved for normal users) ==== | ||
The following events will NOT be fired during imports etc. | The following events will NOT be fired during imports etc. | ||
* appendListPageHead | * appendListPageHead | ||
Line 42: | Line 91: | ||
* beforeRenderItem | * beforeRenderItem | ||
== Event firing in UI depending on user actions == | ==== Event firing in UI depending on user actions ==== | ||
The following events are SOMETIMES be fired for normal users depending on navigation | The following events are SOMETIMES be fired for normal users depending on navigation | ||
* afterUpdateRedirectActive | * afterUpdateRedirectActive |
Latest revision as of 07:18, 26 November 2024
Form events fires different actions during execution of a solution
Creating the codeunit
- Make sure that p2eShared.jar is included in the project
- Create a new class that extends
com.tsnocode.codeunit.CodeunitFormevents
LIST level event hooks
public String appendListPageHead() { return ""; } public String appendListPageFoot() { return ""; }
public void beforeSelectList() throws Exception {} public void beforeRenderList() throws Exception {}
LIST execution order
- beforeSelectList
- Gather form data from database
- beforeRenderList
- Return list to user
ITEM level event hooks
public String appendItemPageHead() { return ""; } public String appendItemPageFoot() { return ""; }
public void beforeSelectItem() throws Exception {} public void beforeChangeItem() throws Exception {} public void beforeUpdateItem() throws Exception {} public void beforeRenderItem() throws Exception {} public void afterUpdateItem() throws Exception { return false; } public boolean afterUpdateRedirectActive() { return false; } public String afterUpdateRedirectContent() { return null; }
ITEM execution order: viewing data
- beforeSelectItem
- Gather form data from database
- beforeRenderItem
- Return form to user
ITEM execution order: posting data
- beforeSelectItem
- Gather form data from database
- beforeChangeItem
- Update field values
- beforeUpdateItem
- Write changes to database
- afterUpdateItem
- if NO OTHER ACTION:
- afterUpdateRedirectActive
- if TRUE
- afterUpdateRedirectContent
- Return content to user
FILTER event hooks
Filters will help you build customized permission schemes
dataFilterActive() {} dataFilterHandler(StringBuilder sql) { return sql; }
In some cases you only want the filter to trigger for either LIST or ITEM commands
itemFilterActive() {} itemFilterHandler(StringBuilder sql) { return sql; } listFilterActive() {} listFilterHandler(StringBuilder sql) { return sql; }
Event firing details
Event firing global
The following events are ALLWAYS fired
- beforeSelectList
- beforeSelectItem
- beforeChangeItem
- beforeUpdateItem
- afterUpdateItem
Event firing in UI (reserved for normal users)
The following events will NOT be fired during imports etc.
- appendListPageHead
- appendListPageFoot
- beforeRenderList
- appendItemPageHead
- appendItemPageFoot
- beforeRenderItem
Event firing in UI depending on user actions
The following events are SOMETIMES be fired for normal users depending on navigation
- afterUpdateRedirectActive
- Not executed in SUBFORM mode
- Not executed in during imports etc.
- afterUpdateRedirectContent
- Depends on a TRUE result from afterUpdateRedirectActive()