Difference between revisions of "Codeunit/Formevents"

From TempusServa wiki
Jump to navigation Jump to search
old>Admin
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Methods and events ==
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


Form events fires different actions during execution of a solution
    com.tsnocode.codeunit.CodeunitFormevents


LIST level event hooks are
== 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 are
 
==== 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:




=== LIST execution order ===
==== ITEM execution order: viewing data ====
# '''beforeSelectList'''
# Gather form data from database
# '''beforeRenderList'''
# Return form to user
 
=== ITEM execution order: viewing data ===
# '''beforeSelectItem'''
# '''beforeSelectItem'''
# Gather form data from database
# Gather form data from database
Line 38: Line 43:
# Return form to user
# Return form to user


=== ITEM execution order: posting data ===
 
==== ITEM execution order: posting data ====
# '''beforeSelectItem'''
# '''beforeSelectItem'''
# Gather form data from database
# Gather form data from database
Line 46: Line 52:
# Write changes to database
# Write changes to database
# '''afterUpdateItem'''
# '''afterUpdateItem'''
# Display result
# if NO OTHER ACTION:  
# IF NO OTHER ACTION:  
#* '''afterUpdateRedirectActive'''
#* afterUpdateRedirectActive /
#* if TRUE
#** '''afterUpdateRedirectContent'''
# Return content to user
 
== Event firing details ==


== Event firing global ==
==== Event firing global ====
The following events are ALLWAYS fired
The following events are ALLWAYS fired
* beforeSelectList
* beforeSelectList
Line 58: Line 68:
* afterUpdateItem
* afterUpdateItem


== Event firing in UI (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 67: Line 77:
* 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 08:22, 3 October 2023

Form events fires different actions during execution of a solution

Creating the codeunit

  1. Make sure that p2eShared.jar is included in the project
  2. 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

  1. beforeSelectList
  2. Gather form data from database
  3. beforeRenderList
  4. 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

  1. beforeSelectItem
  2. Gather form data from database
  3. beforeRenderItem
  4. Return form to user


ITEM execution order: posting data

  1. beforeSelectItem
  2. Gather form data from database
  3. beforeChangeItem
  4. Update field values
  5. beforeUpdateItem
  6. Write changes to database
  7. afterUpdateItem
  8. if NO OTHER ACTION:
    • afterUpdateRedirectActive
    • if TRUE
      • afterUpdateRedirectContent
  9. Return content to user

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()