creating form in Servoy 4.1rc3?

I am writing an application which automatically converts FileMaker layouts, scripts and relationships to Servoy - but I am having trouble getting a simple form to be created. I suspect that I am just missing something simple in my knowledge of using Servoy. I am using the following code posted in one of the previous forum posts:

var fname = "testform"
if (!forms[fname])
{
       // create dataset
       ds = databaseManager.createEmptyDataSet()
       ds.addColumn("x_id")
       ds.addColumn("bla t")
       ds.addRow([100, 'aap'])
       ds.addRow([101, 'noot'])
       ds.addRow([102, 'mies'])

      //Create a new data source, returns an uri that can be used to build forms on
      var uri = ds.createDataSource('mydata', [DM_TYPE.INTEGER, DM_TYPE.TEXT]);

      // create form
      var jsform = solutionModel.newForm(fname, uri, null, true, 300, 300);
      jsform.newTextField("x_id",100,100,100,20);
      jsform.newTextField("bla_t",100,130,100,20);
  }

  application.output(fname)
  forms[fname].controller.show()

I selected the code to run after saving the .js file, and expected to see the new form “testform” show up in the list of forms in the solution explorer - but nothing happened. The code seemed to run without error, but no forms were created. Any ideas?

A few other questions I have are:

  1. How can I load and run a whole group of files, such as: form1.js, form2.js, form3.js ?
    I need to convert FileMaker files having hundreds of layouts, so I need to automate this process of running the forms code which I have generated.
  2. Is there an example showing how to create a graphic image object on a form using an existing media object which has already been imported into the project?
  3. How can I save each form which has been created? I read somewhere that these forms are created in memory and something extra needs to be done to actually save them into the project.

Hi David,

First of all welcome to the Servoy forum. :)

dsimpson:
I am writing an application which automatically converts FileMaker layouts, scripts and relationships to Servoy - but I am having trouble getting a simple form to be created. I suspect that I am just missing something simple in my knowledge of using Servoy. I am using the following code posted in one of the previous forum posts:

I selected the code to run after saving the .js file, and expected to see the new form “testform” show up in the list of forms in the solution explorer - but nothing happened. The code seemed to run without error, but no forms were created. Any ideas?

Did you actually trigger the method? Via the menubar, button or on one of the formevents? How did you run it?

dsimpson:
2) How can I load and run a whole group of files, such as: form1.js, form2.js, form3.js ?
I need to convert FileMaker files having hundreds of layouts, so I need to automate this process of running the forms code which I have generated.

Those js files are loaded when the corresponding form is loaded. They are in the scope of that form.
Running the forms code is not something anyone has to automate. Servoy takes care of that.
To put it in FMPro terms, you don’t have to do anything than to create a script and a button and link them together. FMPro will do the rest when you actually click the button. Right ?
Same deal with Servoy. Make sure the methods you create link to an (application/form/field/button/label/menuitem/popupmenu/toolbarbutton/etc.) event and it will be triggered.

dsimpson:
3) Is there an example showing how to create a graphic image object on a form using an existing media object which has already been imported into the project?

In Servoy image objects in a form are in fact labels with imagemedia linked to it. So you create a label and attach a media object.
To take a snippit of your example method it looks something like this:

var oForm = solutionModel.newForm(fname, uri, null, true, 300, 300);
var oLabel = oForm.newLabel("", 50, 100, 100, 100, null); // 100px by 100px image
oLabel.imageMedia	= solutionModel.getMedia("mySolutionBasedImage.jpg");

dsimpson:
4) How can I save each form which has been created? I read somewhere that these forms are created in memory and something extra needs to be done to actually save them into the project.

Troy of Data Mosaic posted a way of storing a form into a database and recreating them from data as well.
But you should know this means it’s still not part of your solution, it won’t be living in the repository. It’s just data that the solution can use to create any custom forms.

Hope this helps.

Robert,
Thanks for the warm welcome and the assistance. I now understand the label creation technique.

So when I try to run this form creation js code, I am clicking on the green/white triangle run button in Servoy Eclipse at the top of the toolbar (to the right of the debugger button). Clicking on the pull down menu displays a list of .js files I have opened, and I select the file from the list.

I expected that once I ran the supplied example code, Servoy Eclipse would process the javascript code, create a new form in the workspace with the appropriate .obj workspace files, and then the form would show up in the list of forms in the solution explorer. But this does not occur, and in fact nothing really shows up indicating an error either. No entries show up in the .metadata/.log file either.

I understand that Servoy will automatically display the forms which have been previously created in the development environment.
But lets say I have 300 of these forms from a converted solution, I don’t want to go to the run button in Servoy Eclipse and have to select each one to run individually to create the form (a one time task). So I was hoping to generate a top-level piece of code which would just run several hundred of these .js files at one time.
[Of course this doesn’t address the issue of whether each one of those 300 layouts should be converted into a Servoy form. This is just an automation task I am performing right now. With some planning and analysis, it may become evident that forms could be combined together, deleted etc. ]

Hi David,

dsimpson:
Robert,
Thanks for the warm welcome and the assistance. I now understand the label creation technique.

So when I try to run this form creation js code, I am clicking on the green/white triangle run button in Servoy Eclipse at the top of the toolbar (to the right of the debugger button). Clicking on the pull down menu displays a list of .js files I have opened, and I select the file from the list.

That green/white triangle button is part of the Eclipse environment that Servoy Developer is now a plugin of. I am not sure if Servoy is able to disable that button but that is not part of Servoy itself.
You should use the following buttons to launch the rich- or web client.

This should get you a lot further.

As for creating js files and form objects in the workspace (that’s in my view what you’re actually want to do) I suggest you talk directly to the Servoy devs about this. Of course you can do some reverse engineering but why not start at the source.

Hope this helps.