← servoy magazine

[News] 4...

  • News

Comments (2)

Tom Parry
The custom code feature is nice to have rather than call a method in ones own code module. How does one manage the source code changes in custom code? Where is the code located? Is it in a separate "users_module" or buried within FW module someplace? If I find that I have almost the same code being used over and over from different forms,UL etc how can I go about making the maintenance more efficient such as by consolidating the code into one place and calling with different arguments to specify the source or triggering element or form (I seem to recall that the triggerring method/element/form would always be FW and not perhaps what I would prefer (the "delegate" pattern comes to mind).
David Workman
Your code is in the Frameworks meta data. Table.field = "mosaic_action_item.method". Any valid Servoy javascript code works and the code is run in the context of the form assigned to the navigation item. Given this, lot's of creative ways one could come up with to use and manage things. Generally speaking, it is meant for short many-used code snippets that you don't want to assign in your workflow forms all over the place. Could be used to control clutter. Let me head off your next question: how to abstract a code block to work the same on all forms? The "controller.functionX()" reference works great since we run the code for the workflow form context, not from the context of the top level frameworks form. For added flexibility, you can also reference data in our solution state object which contains tons of information about a frameworks solution. For example, current form stuff could be written: forms[solutionPrefs.config.currentFormName].functionX() Not so useful as this is the same as the controller. But maybe using branching logic based on what UL view is currently active might be.