Normal Topic Escaping the Trap (Read 831 times)
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Escaping the Trap
Dec 11th, 2007 at 3:57pm
Print Post Print Post  
Unfortunately, the "Trap" is not foolproof.  It appears that it only works when the focus was previously on another form element.  If the focus is outside the form, changing the focus to element where one wishes to setup the trap fails to fire the On Element Entry event, thus avoiding the setting of the Trap.

As an example, I created a very simple Sesame application with three text elements.  The third element in the Navigation Order has a Trap, which gets set in the element's On Element Entry event.  When I bring up the form in Search mode, and find all records so that I'm in Update mode, the focus is automatically set by Sesame to the first element on the form.  Then I do the following:

1) Click on any menu item in the Sesame menu tree on the left side to take the focus away from the form.
2) Click directly on the text element that the trap is set on.

At this point, the On Element Entry event does not fire, so the trap doesn't get set, and thus I bypass the trap.  As a workaround, I added a trap set to On Element Immediate Change.  I can do this in my system because NULL is valid for the element in question.  But Sesame's Trap sample code can be bypassed by doing what I did above.

Of course, this problem is not specific to the Trap.  Any code that relies on On Element Entry can be bypassed by what I described.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Escaping the Trap
Reply #1 - Dec 11th, 2007 at 4:30pm
Print Post Print Post  
Yes, the trap is easily bypassed if you set it on the element's entry. Don't do that. Setting it on the form's entry or in global code will make it somewhat more fool-proof. In general, try to avoid trapping users, by any means.

Control the data, not the user.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Escaping the Trap
Reply #2 - Dec 11th, 2007 at 5:00pm
Print Post Print Post  
MP,

Mark (The Cow) is 100% correct; forget about trying to control a user. (it creates more problems in the long run) I spent years trying to control (trap) how users interact and work with the application. It did nothing but frustrate me, the user and often in the users attempt to get around my trap would screw up the data more. After listening to Mark and Erika teach validate the data before committing it rather then control the user, I have found everyone is better off because there is less conflict and the data itself  (the main reason we wanted to trap the user) is much more accurate.

Well that’s my 2 cents for what its worth..
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Escaping the Trap
Reply #3 - Dec 11th, 2007 at 5:32pm
Print Post Print Post  
Quote:
Control the data, not the user.

BOBSCOTT wrote on Dec 11th, 2007 at 5:00pm:
forget about trying to control a user.

I understand the reasoning behind postponing validation until the Commit.  However, the issue I'm dealing with is a need for double-entry validation.  I don't like implementing this by having two elements (such as the typical way web pages double-validate an e-mail address) because of the clutter involved.  I prefer to utilize @PromptForUserInput in the On Element Exit event.

I must say that it's frustrating to find functionality that doesn't work as advertised.  In this case, the Trap should Trap the user.  Having exceptions removes any reason to use it in the first place.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Escaping the Trap
Reply #4 - Dec 11th, 2007 at 5:41pm
Print Post Print Post  
MP: We'll look into the On Element Entry not running if you move focus to the tree and back. There are protections in place to prevent this event from running multiply if, for example, On Element Entry pops up a message box which drops the user back into the element after it is dismissed. This condition may also be triggering that looping protection.

At any rate, setting the trap On Form Entry should handle this exception.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
MP
Full Member
***
Offline



Posts: 104
Joined: Sep 3rd, 2007
Re: Escaping the Trap
Reply #5 - Dec 11th, 2007 at 5:49pm
Print Post Print Post  
Hammer wrote on Dec 11th, 2007 at 5:41pm:
At any rate, setting the trap On Form Entry should handle this exception.

That workaround only handles the first instance of the exception.  Once the trap is cleared, the user is still free to by-pass the trap and re-enter the element trap free.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Escaping the Trap
Reply #6 - Dec 11th, 2007 at 5:52pm
Print Post Print Post  
MP wrote on Dec 11th, 2007 at 5:49pm:
Hammer wrote on Dec 11th, 2007 at 5:41pm:
At any rate, setting the trap On Form Entry should handle this exception.

That workaround only handles the first instance of the exception.  Once the trap is cleared, the user is still free to by-pass the trap and re-enter the element trap free.


As I said, we'll look into the tree exception.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Escaping the Trap
Reply #7 - Dec 12th, 2007 at 3:41pm
Print Post Print Post  
FYI: We did look into the tree/entry issue. We put in an adjustment which handles this particular case. We've got it in testing and analysis to check for side effects. If it sticks, it will be in 2.0.5.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged