JSEvent optional?

Discuss all feature requests you have for a new Servoy versions here. Make sure to be clear about what you want, provide an example and indicate how important the feature is for you

JSEvent optional?

Postby lesouef » Thu Feb 04, 2010 12:58 am

Version 5 now puts a mandatory JSEvent on every button.
When porting a solution designed with 3.5, all methods already using arguments fail.
And for developers using methods written to be called either by another method or by a button, everything has to be modified, which represents an extensive work for old solutions.
Could this feature become an option and not be set when re-importing a 3.5 solution? This would leave the methods ok, while being able to use the JSEvent in new methods.
If this is hard to achieve, a possible workaround would be to be able to set the JSEvent as 2nd argument and leave the 1st empty to simulate the former behaviour for the 1st argument.
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: JSEvent optional?

Postby Harjo » Thu Feb 04, 2010 12:55 pm

The problem view does tell exactly WHICH methods are reflected..
do you have so many of them?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: JSEvent optional?

Postby lesouef » Thu Feb 04, 2010 1:38 pm

not many in the current solution, but I have another one I might try to upgrade which has a lot as I often call methods with arguments rather than with global vars.
I'll try to modify the calling methods to send an empty 1st argument, and put the real info in the second, that should to the trick quickly.
These things are not sold, so I don't want to waste too much time on this.
The problem is not to forget any of them, "problems" reports methods which are using arguments, but the ones which call them.
As methods are all bundled into a single file per form, a quick search should locate them quickly as my args names are kind of logic. At least 1 advantage of this file re-arrangement (I prefered separate files...)
I'll be back if I can't work around it this way. In any case, I'll be quickler than a software mod.
Are people using method arguments so few that nobody complained about this?
I also came across quite a lot of fake problems when importing the old 3.5 solution, wrong valuelists which were good, simply editing them with no change fixed it, unresolved onshow methods which did not exit in the original solution, so simply deleting the reference to them was ok.
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: JSEvent optional?

Postby Harjo » Thu Feb 04, 2010 2:01 pm

than you have to take it the other way.

dont fix the methods that call them, but fix the method itself.

that is easy to do with if(event instance of JSEVENT) // out of my head ;-)
{
// do this
} else {
// your old method
}
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: JSEvent optional?

Postby jcompagner » Thu Feb 04, 2010 3:19 pm

its not possible to have that optional.
What happens with a solution that you import from 3.5
And then start adding new stuff like an onaction?
Or use a module that is a 5.0 only thing?

Problem is that using event based methods as bus.logic is wrong in the first place
We did add events to method all the way through from servoy 2.0 to 5.. (like onshow boolean, ondatachange had arguments and so on)
so it is not that it did happen suddenly and only in 5.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: JSEvent optional?

Postby lesouef » Thu Feb 04, 2010 3:27 pm

you're probably right...
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: JSEvent optional?

Postby lesouef » Fri Feb 05, 2010 2:27 am

my answer was not for the last post but the one before (last 2 were almost simultaneous).
Maybe the events sent to methods are not fully new, but they are for buttons.
And testing if the method argument is a JSEvent object issues an error if the argument is a simple string, and I have a few methods which are called by either a button or another method, and the expected argument is a string. if missing, the button name is taken instead.
so I changed since the argument is always present now, but I must test a string vs an object. how do you do this? Harjo's hint does not work if the argument is a string, and that means to modify the calling methods now. not a good idea.
This topic has been discussed in other places here, and I understand you recommand new ways when it's better, but why remove or deprecate old methods?
Some solutions just need to be ported to run on a common server with a newer solution, and nobody fancies to re-work a solution which works fine for 2 years. so better leave old stuff the way it was? or leave the choice to the user?
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: JSEvent optional?

Postby lesouef » Fri Feb 05, 2010 2:53 am

I fixed that by using getMethodTriggerElementName() to determine whether to expect a JSEvent or not. hope this function won't be deprecated now!
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France

Re: JSEvent optional?

Postby ptalbot » Fri Feb 05, 2010 3:49 am

lesouef wrote:I fixed that by using getMethodTriggerElementName() to determine whether to expect a JSEvent or not. hope this function won't be deprecated now!

Hi Serge,

I'm afraid it is deprecated!
Now you get a JSEvent and you use getElementName() on it...

But you can always test if the first argument is a JSEvent and retrieve the name of the button that triggered it like this:
Code: Select all
var yourExpectedVar = null;
if (arguments[0] && arguments[0] instanceof JSEvent) {
    yourExpectedVar = arguments[0].getElementName();
} else {
  yourExpectedVar = arguments[0];
}


[EDIT] Sorry I didn't see what you said before about this test not working with Strings, that is weird.
I just tried it in Servoy 5.0.1 and it works for me. Are you sure that you spell JSEvent and not JSEVENT?
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: JSEvent optional?

Postby Harjo » Fri Feb 05, 2010 9:09 am

Harjo wrote:that is easy to do with if(event instance of JSEVENT) // out of my head ;-)


as I said, doing this out of my head ;-)
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: JSEvent optional?

Postby lesouef » Fri Feb 05, 2010 11:36 am

Harjo: no pb, you had told me.
Patrick: that's where I reach my limits, you use a syntax which is not in the book. I don't know if JSEvent was in v4, and there is nothing yet for v5.
Servoy is now sliding from advanced users to real software people, and they assume I should know what to do with an object, but this is a black hole for me.
Using your way probably works, but I'll be trapped on next problem then.
All I saw is that using getElementName() on an argument which is not the expected object does not work since it's not an object. So all calling methods must be changed as I simply use strings arguments myself, and sometimes arrays.
Again, why use an object instead of a string or array, no idea, I am just a good shell user, you're probably upset that non programmers are attempting to do their own apps? so maybe I should give up that stuff? another debate for another place anyway.
lesouef
 
Posts: 420
Joined: Thu Oct 20, 2005 8:13 pm
Location: Strasbourg & Paris - France


Return to Discuss Feature Requests

Who is online

Users browsing this forum: No registered users and 9 guests