starting a method on leave field

Questions, tips and tricks and techniques for scripting in Servoy

starting a method on leave field

Postby Harjo » Mon May 26, 2003 2:59 pm

I have 2 global fields on a form.

globals.gebruikersnaam
globals.wachtwoord

and I've got the following method:
controller.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog('Waarschuwing','Sorry, Geen geldige gebruikersnaam of wachtwoord!','OK')
controller.loadAllRecords()
controller.show()
}


On the field: global.wachtwoord I have set the property: OnLeave, to the method above. It won't start when I am leaving the field.
What am I doing wrong?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby maarten » Mon May 26, 2003 9:31 pm

This script performs a search on the table where the controller is build on.
Is this your intention? In other words , are the passwords stored in the same table as the controller is build on?

If not, you should build the same script on the form where the username and password are.

assuming:
scriptname is "checkPassword"
formName is "login"
formName is build on table users with fields "user" and "password"

..you could call this script via onLeave script attached to "globalField" on the controller like this:

onLeaveScript
forms.login.checkPassword();



PS: I assume you have a specific reason for handling passwords this way. (Servoy has a user/password check linked to security)
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Harjo » Tue May 27, 2003 12:07 am

ah I found it. I must use: form.find()
I had copied the code from another script.

Strange thought, that the script works correctly when I attached it at a button!
Last edited by Harjo on Tue May 27, 2003 8:15 am, edited 1 time in total.
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby Harjo » Tue May 27, 2003 8:12 am

I'm sorry, It did not work!
I've changed the code in this:

if(globals.gebruikersnaam == "")
{
plugins.dialogs.showDialog('Waarschuwing','U moet een geldige gebruikersnaam invullen!','OK')
return
}

form.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog('Waarschuwing','Sorry, Geen geldige gebruikersnaam of wachtwoord!','OK')
form.loadAllRecords()
form.show()
}
else
{
plugins.dialogs.showDialog('Welkom','Welkom: '+voornaam+' '+achternaam+' ','OK')
form.loadAllRecords()
form.show()
forms.relaties.controller.show()
}

But the script wonth start on leaving a global-field. If I change the global field to a normal field, than it starts. Is this a bug??
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby Harjo » Tue May 27, 2003 9:58 am

PS: I assume you have a specific reason for handling passwords this way. (Servoy has a user/password check linked to security)

Yes I know, but we always built ouer own acces to all ouer solutions. Why? :?: In practice, a lot of ouer users (customers) do not have the knowledge to administrate such a kind of login-structure. (some of them, can't even read English!) So we build ouer own (simple) system, where a super-user can add another (new) user to the system and put this user in a categorie.
Categories are: Super-User, User (can't delete records), Editer (can't delete or create records, only edit) Guest (can only view data)
So the customer can simple administrate the solution.
My next question is: Can I automate the login (I mean the already built-in login) bij methods??
We do this in Filemaker, with a special plugin. DIALOGFM
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby maarten » Tue May 27, 2003 11:22 am

HJK wrote:ah I found it. I must use: form.find()
I had copied the code from another script.

Strange thought, that the script works correctly when I attached it at a button!


This is an old syntax. (may still work, but is depricated)
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Harjo » Tue May 27, 2003 11:58 am

I'm a little bit confused.
When do I use:
controller.find()

or
currentcontroller.find()

or assuming that de form is: actionDetails
forms.actionDetails.controller.find()


Can you explain the differences or when to use which one?
and can you explain why a script is not starting if it is set to leave on an global-field??
Last edited by Harjo on Tue May 27, 2003 12:05 pm, edited 1 time in total.
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby maarten » Tue May 27, 2003 12:04 pm

I'm sorry, It did not work!
I've changed the code in this:

Quote:
if(globals.gebruikersnaam == "")
{
plugins.dialogs.showDialog('Waarschuwing','U moet een geldige gebruikersnaam invullen!','OK')
return
}

form.find();
gebruikersnaam = globals.gebruikersnaam;
wachtwoord = globals.wachtwoord;
controller.search();
if(controller.getMaxRecordIndex()==0)
{
plugins.dialogs.showDialog('Waarschuwing','Sorry, Geen geldige gebruikersnaam of wachtwoord!','OK')
form.loadAllRecords()
form.show()
}
else
{
plugins.dialogs.showDialog('Welkom','Welkom: '+voornaam+' '+achternaam+' ','OK')
form.loadAllRecords()
form.show()
forms.relaties.controller.show()
}

But the script wonth start on leaving a global-field. If I change the global field to a normal field, than it starts. Is this a bug??


I've succesfully tested on the build that will be released soon.
You might check if this is a bug, by shortening the script to:

if(globals.gebruikersnaam == "")
{
plugins.dialogs.showDialog('Waarschuwing','U moet een geldige gebruikersnaam invullen!','OK')
return
}

This way you can at least check if the script is triggered with an onLeave Global.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Harjo » Tue May 27, 2003 12:16 pm

Yes! this:
if(globals.gebruikersnaam == "")
{
plugins.dialogs.showDialog('Waarschuwing','U moet een geldige gebruikersnaam invullen!','OK')
return
}
is working!
Why is my script not triggered?
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby Harjo » Tue May 27, 2003 12:23 pm

AH I FOUND THE BUG!
THe script is'nt triggering because I use globals.wachtwoord with displaytype: password. If I change it to TEXT_FIELD than the script is triggering!
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby jcompagner » Tue May 27, 2003 7:24 pm

The not triggering for password fields was a bug in servoy. Fixed in the next release.
jcompagner
 


Return to Methods

Who is online

Users browsing this forum: No registered users and 12 guests