|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
WDDX and UDF
Looks like you can’t save a reference to a UDF to a WDDX packet ???DDE 02/04/03 07:35 A Thats because "function" is not a "type" so cf doesn't know how towebguy 02/04/03 08:16 A Hi,D. Delcomminette 02/04/03 08:54 A > I am not really convinced about the explanation,webguy 02/04/03 09:13 A Typo..webguy 02/04/03 09:18 A OK, I'll try to explain a bit more , but I can't give full details otherwiseDDE 02/04/03 10:49 A Ok understand that. But what I don't understand is why you need to store thewebguy 02/04/03 11:07 A Ouuuuuuuups ..... I wish my English was better .............D. Delcomminette 02/04/03 11:40 A Are you saying that based on user input, you would need to call aRaymond Camden 02/04/03 11:55 A Yeah, almost. Users can save preferences but I cannot use the simple methodD. Delcomminette 02/04/03 12:40 P So wait a minute - you mean your data structure looks like this - kinda:Raymond Camden 02/04/03 01:16 P It is much more complex than that and it doesn't concern pages but displayDDE 02/05/03 02:19 A Why store the udf as a preference? I'd just store a string, ie,Raymond Camden 02/05/03 10:41 A Your suggestion is good as soon as the set of function is pre-defined andD. Delcomminette 02/05/03 10:41 P Hmm, something else to consider. You can pass the name of a UDF to a UDFRaymond Camden 02/06/03 09:55 A Yes, Exactly what I did today .... A bit tricky to play with Evaluate whenD. Delcomminette 02/06/03 10:59 A Just an fyi, I sent in a bug report about this issue. If WDDX allows youRaymond Camden 02/04/03 09:51 A Yes that is true, it certainly should behave in a consist manner.webguy 02/04/03 09:58 A > Yes that is true, it certainly should behave in a consist manner.Raymond Camden 02/04/03 10:04 A * I am not really convinced about the explanation,D. Delcomminette 02/04/03 10:45 A Wouldn't something like this involve a change in WDDX? I thought MM/AllaireRobertson-Ravo, Neil (RX) 02/04/03 10:52 A WDDX has NOT been dumped. In fact, Updater2 fixed some bugs that existedRaymond Camden 02/04/03 10:59 A OK, its not been dropped per say, but it certainly has fallen out ofRobertson-Ravo, Neil (RX) 02/04/03 11:08 A > OK, its not been dropped per say, but it certainly has fallen out ofRaymond Camden 02/04/03 11:22 A Looks like you can’t save a reference to a UDF to a WDDX packet ??? If I do that when I de-serialize the packet I don’t have my UDF anymore. Any explanations or other suggestion to work it out. I use a struct of array of struct containing information about a kind of cfgrid object. These struct contain amongst other formatting function for the columns and I want to save these settings to the database between sessions. Thanks, Dominique Thats because "function" is not a "type" so cf doesn't know how to serializes it. Why not use a CFC that has your functions + the Data , create a function that returns converts your data into WDDX and also has a function that can take your wddx and populate you cfc again . WG ----- Excess quoted text cut - see Original Post for more ----- Hi, I am not really convinced about the explanation, the deserialized packet shows the function name, access hint, output and array of parameters .. I thought about the CFC solution but can't see exactly how to implement it ... Thanks anyway Thats because "function" is not a "type" so cf doesn't know how to serializes it. Why not use a CFC that has your functions + the Data , create a function that returns converts your data into WDDX and also has a function that can take your wddx and populate you cfc again . WG ----- Excess quoted text cut - see Original Post for more ----- > I am not really convinced about the explanation, Why not? > the deserialized packet > shows the function name, access hint, output and array of parameters .. i.e. the same stuff you get when you cfdump it. All those things are "simple" values, or built in object types. The code logic would be a complex "type" or hidden etc. Why do you want to serialize the function code anyway? Are you going to have "custom" or runtime function code? I'm a little confused as to what you are trying to do. if you do a = myfunction(a,b,c); ... "a" will contain the return code, unless you return the struct of array of struct (as a struct), which you should be able to store as wddx > I thought about the CFC solution but can't see exactly how to implement it Tell us what you are trying to do, and we can comment further > Thanks anyway Welcome WG ----- Excess quoted text cut - see Original Post for more ----- Typo.. > if you do a = myfunction(a,b,c); ... "a" will contain the return code, > unless you return the struct of array of struct (as a struct), which you > should be able to store as wddx should read if you do a = myfunction(a,b,c); ... "a" will contain the return code. if you return the struct of array of struct (as a struct),you should be able to store as wddx WG OK, I'll try to explain a bit more , but I can't give full details otherwise it will become to complex. I have a struc of array of struct and so on ... A part of is a description of columns appearing in a dhtml table. For each column, I have a name, a datatype, a filter value ...... and an optional reference to formatting function ... Most of those data can be customized per user. That's the reason why I have to save it somewhere, and I choose to save in a user related table of my database. I tried to store just the name of the function as a string, but than I have other problems in the object managing the all stuff. Hope you get a better idea. Thanks Dominique Typo.. > if you do a = myfunction(a,b,c); ... "a" will contain the return code, > unless you return the struct of array of struct (as a struct), which you > should be able to store as wddx should read if you do a = myfunction(a,b,c); ... "a" will contain the return code. if you return the struct of array of struct (as a struct),you should be able to store as wddx WG Ok understand that. But what I don't understand is why you need to store the preferences as a function. Can't you just store the "struc of array of struct" ? WG ----- Excess quoted text cut - see Original Post for more ----- Ouuuuuuuups ..... I wish my English was better ............. I do not want to store anything as a function, but I have to! Because some parameters amongst others are just the function the user chooses to places at some point . Can't find how to explain it in another way. Thanks for your patience. Dominique Ok understand that. But what I don't understand is why you need to store the preferences as a function. Can't you just store the "struc of array of struct" ? WG ----- Excess quoted text cut - see Original Post for more ----- Are you saying that based on user input, you would need to call a function but you don't know which at runtime? If your options are limited (let's say 3 differnet UDFs), you could use a simple cfif block... <cfif foo is 1> <cfset x = goo()> <cfelseif foo is 2> <cfset x = moo()> <cfelseif foo is 3> <cfset x = doodoo()> </cfif> Or, you can consider writing one UDF and passing the option (foo above) to the UDF. ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Yeah, almost. Users can save preferences but I cannot use the simple method you describe, because the same thig happens on different pages. I mena users can save preferences for different pages and the same object has to handle all of them. So, I really need to save for user x preference for page y a whole bunch of parameters amongst which a couple of functions. Are you saying that based on user input, you would need to call a function but you don't know which at runtime? If your options are limited (let's say 3 differnet UDFs), you could use a simple cfif block... <cfif foo is 1> <cfset x = goo()> <cfelseif foo is 2> <cfset x = moo()> <cfelseif foo is 3> <cfset x = doodoo()> </cfif> Or, you can consider writing one UDF and passing the option (foo above) to the UDF. ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- So wait a minute - you mean your data structure looks like this - kinda: Preferences Page A background color: red music: techno Page B coolness factor: high hipness factor: can't walk through doors If so - why not simply store the preferences in a structure? How exactly are you using the dynamic UDFs? ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- It is much more complex than that and it doesn't concern pages but display objects ... Anyway I will add to your example so that it is closer to what I need, each "page" also has a couple of functions defined by default and these one can also be changed by the user. Let's take your page a as an example: Page A Background color: red Music: techno UDF1: DisplayThumbnail UDF1_param: ArtistName UDF2: Playsong UDF2_param: SongName As a user I can choose to replace DisplayThumbnail by DisplayResume or PlaySong by PlayVideo and UDF2_param by ClipName, and save it to my preferences. DO you have a better idea of what I mean ?? Thanks Dominique So wait a minute - you mean your data structure looks like this - kinda: Preferences Page A background color: red music: techno Page B coolness factor: high hipness factor: can't walk through doors If so - why not simply store the preferences in a structure? How exactly are you using the dynamic UDFs? ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Why store the udf as a preference? I'd just store a string, ie, pageA.display="thumbnail" or pageA.display="Summary", then you could do: <cfif pageA.display is "thumbnail"> <cfoutput>#displayThunbnail(.... etc Or even easier. Write a UDF called displayContent. It takes as an arg what style to display and the data to show. So you could do: displayContent("thunbmail",artistnail) ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Your suggestion is good as soon as the set of function is pre-defined and well known, which is not the case. The object I am talking about is part of a completely dynamic development framework and must be able to handle other set of functions without changing the code. Dominique Why store the udf as a preference? I'd just store a string, ie, pageA.display="thumbnail" or pageA.display="Summary", then you could do: <cfif pageA.display is "thumbnail"> <cfoutput>#displayThunbnail(.... etc Or even easier. Write a UDF called displayContent. It takes as an arg what style to display and the data to show. So you could do: displayContent("thunbmail",artistnail) ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Hmm, something else to consider. You can pass the name of a UDF to a UDF and then call it dynamically... function alpha() { return "a"; } function beta() { return "b"; } function main(f) { return f(); } writeOutput(main("alpha")); There is an example of a sort UDF on cflib.org that works like this. Would this help? ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Yes, Exactly what I did today .... A bit tricky to play with Evaluate when you have to pass function names and function arguments .....Another problem is scoping, functions passed by reference are known everywhere down ... but not when passed by name ...... Dominique Hmm, something else to consider. You can pass the name of a UDF to a UDF and then call it dynamically... function alpha() { return "a"; } function beta() { return "b"; } function main(f) { return f(); } writeOutput(main("alpha")); There is an example of a sort UDF on cflib.org that works like this. Would this help? ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Just an fyi, I sent in a bug report about this issue. If WDDX allows you to serialize a UDF, it should work correctly when deserialized. (Or, if not, it should throw an error when you first serialize it.) ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- Yes that is true, it certainly should behave in a consist manner. But would you concur with my logic otherwise? WG > > Just an fyi, I sent in a bug report about this issue. If WDDX allows you > to serialize a UDF, it should work correctly when deserialized. (Or, if > not, it should throw an error when you first serialize it.) > > Yes that is true, it certainly should behave in a consist manner. > But would you concur with my logic otherwise? You mean about using a CFC and only serializing the data? Then sure - yea. As you know, you can't serialize a CFC and deserialize it back as well (I mean to it's original form.) ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda * I am not really convinced about the explanation, Why not? * As Raymond says in a further message if I am able to serialize it without getting any error, I shoul be able to de-serialize it as well > the deserialized packet > shows the function name, access hint, output and array of parameters .. i.e. the same stuff you get when you cfdump it. All those things are "simple" values, or built in object types. The code logic would be a complex "type" or hidden etc. * not really, the serialized packet also contains a full reference to the page where my UDF is defined, which should be sufficient to make a link to it ... Why do you want to serialize the function code anyway? Are you going to have "custom" or runtime function code? * I do not want to serialize the function code, but a reference to a function. By the way if you specify a function as a structure member the struct contains a ref to the function, not the code. The serialized packet also contains a kind of reference to my function, but unfortunately is not de-serialized properly. I'm a little confused as to what you are trying to do. * I can understand that, I will more specific in a further message. if you do a = myfunction(a,b,c); ... "a" will contain the return code, unless you return the struct of array of struct (as a struct), which you should be able to store as wddx > I thought about the CFC solution but can't see exactly how to implement it Tell us what you are trying to do, and we can comment further > Thanks anyway Welcome WG ----- Excess quoted text cut - see Original Post for more ----- Wouldn't something like this involve a change in WDDX? I thought MM/Allaire dumped WDDX a long time ago (as far as further development is concerned.) * I am not really convinced about the explanation, Why not? * As Raymond says in a further message if I am able to serialize it without getting any error, I shoul be able to de-serialize it as well > the deserialized packet > shows the function name, access hint, output and array of parameters .. i.e. the same stuff you get when you cfdump it. All those things are "simple" values, or built in object types. The code logic would be a complex "type" or hidden etc. * not really, the serialized packet also contains a full reference to the page where my UDF is defined, which should be sufficient to make a link to it ... Why do you want to serialize the function code anyway? Are you going to have "custom" or runtime function code? * I do not want to serialize the function code, but a reference to a function. By the way if you specify a function as a structure member the struct contains a ref to the function, not the code. The serialized packet also contains a kind of reference to my function, but unfortunately is not de-serialized properly. I'm a little confused as to what you are trying to do. * I can understand that, I will more specific in a further message. if you do a = myfunction(a,b,c); ... "a" will contain the return code, unless you return the struct of array of struct (as a struct), which you should be able to store as wddx > I thought about the CFC solution but can't see exactly how to implement it Tell us what you are trying to do, and we can comment further > Thanks anyway Welcome WG ----- Excess quoted text cut - see Original Post for more ----- WDDX has NOT been dumped. In fact, Updater2 fixed some bugs that existed with WDDX in CFMX/original. I still use WDDX as it's a quick and easy way to serialize data. In fact, I have a simple bug tracker (written by Nathan Dintenfas) that uses WDDX to store data to the file system. It's not going to support a thousand users, but I can drop the file in an app and have it running in a few seconds. No need to set up a database or dsn. ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- OK, its not been dropped per say, but it certainly has fallen out of favour.....when was the last update to www.wddx.org? I am not saying its crap, jeez we use it extensively too, but it seems that since CF5, it has not been improved upon other than changes to the already existing model. p.s. is your bug tracker out there to download? WDDX has NOT been dumped. In fact, Updater2 fixed some bugs that existed with WDDX in CFMX/original. I still use WDDX as it's a quick and easy way to serialize data. In fact, I have a simple bug tracker (written by Nathan Dintenfas) that uses WDDX to store data to the file system. It's not going to support a thousand users, but I can drop the file in an app and have it running in a few seconds. No need to set up a database or dsn. ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda ----- Excess quoted text cut - see Original Post for more ----- > OK, its not been dropped per say, but it certainly has fallen out of > favour.....when was the last update to www.wddx.org? I am > not saying its > crap, jeez we use it extensively too, but it seems that since > CF5, it has not been improved upon other than changes to the > already existing model. Yea, the site seems to be dead. I don't know - WDDX works fine for me and does everything I need - so the fact that new APIs have not been added lately doesn't really bug me per se. > p.s. is your bug tracker out there to download? > It's not mine, it's from Nathan Dintenfas. I did add some stuff to it, but for a copy, email him at nathan@changemedia.com. Again - it's one of those things like cfdump - simple and easy to use yet _really_ helpful. ======================================================================= Raymond Camden, ColdFusion Jedi Master for Mindseye, Inc Email : jedimaster@mindseye.com WWW : www.camdenfamily.com/morpheus Yahoo IM : morpheus "My ally is the Force, and a powerful ally it is." - Yoda
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||