Object methods

Topics related to using ToolBook for building web apps.

Object methods

Postby John Robin Dove » Tue Feb 24, 2015 12:46 pm

I frequently use object methods. They suit my requirements very well. There is one thing I don't understand. I can create object methods for the page and the background but then when I try to call them from other objects I can't because the Toolbook Actions interface does not include the page and the background on the dropdown list of objects. Have I missed something?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Object methods

Postby Clifton » Tue Feb 24, 2015 2:02 pm

I never have used object methods because they are dependent on too many factors that do not make them very portable. For example, it is easy the suddenly find an object method throwing JavaScript errors because some important dependency no longer exists or a object property has changed. However, I find a better approach is to use sharedActions as these often can be adapted to work with most other objects and on multiple pages, etc. All PowerPac functions work very well in sharedActions and are vastly more flexible than any of the normal ToolBook actions. Another advantage of sharedActions is that they are loaded at the book level so they are available throughout the applications. Object methods basically increase page load times if you have several of them assigned. They generally are loaded at page level and have to loaded multiple times as you navigate to and from pages.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Object methods

Postby John Robin Dove » Tue Feb 24, 2015 3:46 pm

I started by using shared Actions and I still use them for some actions but not those involving objects. I switched to object methods after I discovered what seems to be a bug (in TB 9.01). When you export sharedActions and reimport them elsewhere they refer to objects as of this page. I have found on several occasions that this creates an error that causes the 'export to web' process to abort. I have also discovered that if of this page is changed to of page id 0 (I only have one page so far!) with the actions interface the problem goes away.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Object methods

Postby Clifton » Tue Feb 24, 2015 4:06 pm

I haven't experienced the "this page" reference issue. However, sharedActions can stumble if you use "this book" as a reference. In those cases, I just set a parameter and pass in the information to the sharedAction that would otherwise not be available to the action sequence.

Example:
  • studentName of this book will always resolve to an empty string in a sharedAction (though not in an object method).
  • To fix this I set a sharedAction parameter called studentName and send it along with the sharedAction execution at the object level. This works because at object level on the page or background, there is a property called studentName of this book.
The nice thing about all of this is that the PowerPac functions are not object dependent. They are object NAME dependent. Therefore, they will work with any object on any page or background as long as the object NAME used can be found by PowerPac's object referencing engine.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Object methods

Postby John Robin Dove » Wed Feb 25, 2015 10:35 am

Thanks for this useful information. I have now identified the cause. I think. The problem occurs if I try to run an object method from within a shared action. Something like Execute Action Method "ShowDetails" of button "Details" of page id 0 will be exported without a problem but Execute Action Method "ShowDetails" of button "Details" of this page will not.

Ideally I would prefer to use shared actions for this part of my project because I have two very similar pages to make. One for using video files and one for using audio files. If the this page system would work I would make 2 different pages. However as it doesn't I may opt for one page only. This was how I did it in VB.NET. I just changed the color scheme and hid the screen for audio files. I guess I could do the same in this version. The other four pages of the project are all completely different so shared actions would seem less appropriate for these.

I've been reading your guide about 'how to overcome Toolbook's limitations'. I'm a little apprehensive about TB capacity. At the moment I still have 76% free space on the page and 99% on the background. The app doesn't take long to load so far in fact it seems pretty fast to me. But I can now no longer use the Actions Tools: Show 'Page Actions' and 'Dump Book Actions'. Both now produce an error. I have tried to limit the length of the Action Sequences but there is still a lot of complexity to be programmed. This is why I've chopped the code into Object Methods. I wonder how fast the app will load when all the 5 or 6 pages are finished. I seem to remember something called TBSlice but maybe that was for native apps?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Object methods

Postby Clifton » Wed Feb 25, 2015 1:44 pm

Dumping actions is limited to 64Kb. That is why you can only export so much then an error is generated. Complicated apps are more of an issue when it comes to long action sequences (I.e.: they sometimes cause ToolBook to crash) or they make hunting for problems when they occur more difficult.

You may want consider embedding applications inside each other. My PowerPac Help API is an example of this. Several smaller applications that run inside of each other using field objects, pgGotoURL(), and pgExecuteRemote() to exchange data and to manipulate objects and run actions in separate application windows where necessary. This makes editing actions easier and you can isolate what your actions were designed to do more effectively down the road. Troubleshooting can be narrowed down to a module, instead of searching through one big application AND your action exporter will work again because the modules are never likely to grow out of control.

Downside of embedding is that load time will slow a bit, but the PowerPac can be set up to share its JavaScript so at least that part is cached between applications. I don't think the slower performance is that bad though.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Object methods

Postby John Robin Dove » Thu Feb 26, 2015 5:37 am

Thanks for your reply. I feel a lot more optimistic now that I can see a way round the capacity problem. I had thought of something like this vaguely without knowing that you had already dealt with it. I'll plod on with my conversion.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: Object methods

Postby John Robin Dove » Sat Mar 28, 2015 7:15 am

I'm still using Object methods. Maybe I shouldn't be but so far I'm still happy with them. One thing I didn't mention earlier is what seems like a bug (in Toolbook 9.01). When you create a parameter (for example a String) for an object method and set it to another variable by typing the name of this variable under parameter value in the actions editor and then close it, the next time you open the editor for this object method (ctrl + F5) the variable has disappeared. But it still works! So I guess it's not a serious bug. Maybe it's been fixed in more recent editions of Toolbook.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to Web (DHTML) Development

Who is online

Users browsing this forum: No registered users and 2 guests