Facts about the PreCanInvoke Event

View previous topic View next topic Go down

Facts about the PreCanInvoke Event

Post  Admin on Mon May 10, 2010 7:39 pm

Few facts about the PreCanInvoke Event

Below are my findings on how PreCanInvoke event works.

Applet PreCanInvoke event is called very frequently. Writing Code here can impact the performance.

When a page loads, at the end PreCanInvoke event is called for all the methods defined on the Applet.

Everytime a method is called from a button or menu or script, control goes first to PreCanInvoke event to check if

the method is allowed to be called.

After any method is called, PreCanInvoke event is called for all the methods on the Applet. For eg, New button is

clicked, NewRecord event is fired on Applets and BC. After the event completes, PreCanInvoke event is fired for all

the methods defined in the Applet (custom and standard methods)

On change record, when user selects another record, PreCanInvoke event is fired for all methods. Once for each

method.

You must use return (CancelOperation) in PreCanInvoke event to disable standard methods and to enable custom

methods.



return (CancelOperation) in PreCanInvoke event passes the control to code which checks if the methods should be

enabled or disabled (standard or custom) based on value assigned to CanInvoke. By default CanInvoke is FALSE.

The best practice is to use switch statement rather than having many if loops.

All the standard methods are enabled by default unless it is disabled by configuration. To disable standard method

like NewRecord, WriteRecord etc. return (CancelOperation) must be used.

1. NewRecord is standard method

if(MethodName == "NewRecord"){
return (CancelOperation);
}

In this case, just by giving return (CancelOperation), New button gets disabled.

2. WriteRecord is standard method

if(MethodName == "WriteRecord"){
CanInvoke = "FALSE";
return (CancelOperation);
}

In this case, we are assigning CanInvoke to FALSE which is not required as it is by default set to FALSE, Save

button will be disabled.

3. DeleteRecord is standard method

if(MethodName == "DeleteRecord"){
CanInvoke = "TRUE";
return (CancelOperation);
}

In this case, we are assigning CanInvoke to TRUE and using return(CancelOperation) which is not required, Without

writing this code, by default Save button will be enabled. Only if we want to disable standard method, we should

write code in this event and use return (CancelOperation)

4. ExportQuery is standard method

if(MethodName == "ExportQuery"){
CanInvoke = "FALSE";
}

Until return (CancelOperation) is used, assigning CanInvoke a value of TRUE or FALSE does not make any difference.

If return (CancelOperation) is not used, standard methods will be enabled and custom methods will be disabled by

default.

5. CustMethod is custom method

if(MethodName == "CustMethod"){
CanInvoke = "TRUE";
return (CancelOperation);
}

By default, if we do not write any code for this method, custom method is disabled. To enable it, CanInvoke should

be assigned the value of TRUE and use return (CancelOperation) at the end.

6. Take a case where we write the below code in PreCanInvoke

return (CancelOperation);

For every methods standards and custom, PreCanInvoke event is called. All standard methods will be disabled as we

are using return (CancelOperation) and CanInvoke is by default FALSE. All Custom methods will also be disabled as

CanInvoke is by default FALSE.


7. Take a case where we write the below code in PreCanInvoke

CanInvoke = "TRUE";
return (CancelOperation);

For every methods standards and custom, PreCanInvoke event is called. All the standard and custom methods will be

enabled as CanInvoke is TRUE and we are using return (CancelOperation).


Please add if you have anything else.

-Munavvar
avatar
Admin
Admin

Posts : 21
Join date : 2010-02-25

View user profile http://siebelwithmunav.dodiscussion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum