application.createNewFormInstance()

Questions, tips and tricks and techniques for scripting in Servoy

application.createNewFormInstance()

Postby bobbydtma » Thu Jan 21, 2010 6:56 pm

We are using application.createNewFormInstance() quite extensively now to create multiple instances of our solution. I want to confirm my theory on what this function does because we are also using solution model to make form changes during run-time. Does createNewFormInstance() create a mirror image of the original design form (base form)? We have some forms that make changes to the base form using solution model. Then we use forms.baseForm.controller.recreateUI() and the changes made to the base form seem to automatically update the instance form created through createNewFormInstance() without having to call forms.newInstance.controller.recreateUI. Is my assumption correct?
------------------------------------------
Bobby Drake
Software Engineer
TMA Systems, LLC
http://www.tmasystems.com
Servoy 5.2.1
DB: Oracle 10g, SQL Server 2005
OS: Vista 64
User avatar
bobbydtma
 
Posts: 20
Joined: Wed May 06, 2009 8:09 am
Location: Tulsa, OK, USA

Re: application.createNewFormInstance()

Postby Gary R. Schaecher » Fri Jan 22, 2010 1:29 am

I also noticed after we switched over to application.createNewFormInstance from solutionModel.cloneForm, that now the events on webClient forms are no longer firing. Not sure how using this function breaks the webClient forms? We are testing more and will create another case tomorrow.

Gary
Gary R. Schaecher
TMA Systems, LLC
www.tmasystems.com
Gary R. Schaecher
 
Posts: 72
Joined: Sat Jan 06, 2007 11:01 pm

Re: application.createNewFormInstance()

Postby jcompagner » Mon Jan 25, 2010 12:40 pm

that clone form issue is fixed for the next beta.

about your createNewFormInstance thats just an extra runtime ui instance of a solutions model form object.
So if you change the solution models form object then those new form ui instances are just the same as a normal ui instance of that form. They should also just be recreated or destroyed/created

It cant be that those ui instances are just showing the changes you made to the solution models form. Thats impossible.
It can be that the stale form check doesnt work for those forms, so you think that it is ok. But in reality they are not up to date with the solutions model form.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8884
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: application.createNewFormInstance()

Postby martinh » Wed May 05, 2010 9:32 am

Is there a difference in the use of a form between:

Code: Select all
application.createNewFormInstance('baseForm', 'targetForm');


and

Code: Select all
var _js_baseForm = solutionModel.getForm('baseForm')
var _js_targetForm = solutionModel.newForm('targetForm', _js_baseForm.serverName, _js_baseForm.tableName, _js_baseForm.styleName, false, _js_baseForm.getBodyPart().height, _js_baseForm.width)
_js_targetForm.extendsForm = _js_baseForm
_js_targetForm.useSeparateFoundSet = true // Optional
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: application.createNewFormInstance()

Postby mboegem » Wed May 05, 2010 11:18 am

Yes there is, as far as I know:

Code: Select all
application.createNewFormInstance('baseForm', 'targetForm');

does clone a form only in memory, but it won't be part of the current blueprint of your solution.
trying to get:
Code: Select all
solutionModel.getForm('targetForm')

will return 'null'

Code: Select all
    var _js_baseForm = solutionModel.getForm('baseForm')
    var _js_targetForm = solutionModel.newForm('targetForm', _js_baseForm.serverName, _js_baseForm.tableName, _js_baseForm.styleName, false, _js_baseForm.getBodyPart().height, _js_baseForm.width)
    _js_targetForm.extendsForm = _js_baseForm
    _js_targetForm.useSeparateFoundSet = true // Optional

Will add a form to the current blueprint of your solution.
It will behave like any other form, with any other code.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1817
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: application.createNewFormInstance()

Postby jcompagner » Thu May 06, 2010 10:53 am

The thing you should define is where the "difference" is...

Because the 2 methods do different things, by using the blueprint or not like Mr. Boegem explained
But from an end users perspective, so what the actual result is in a client, there is no much difference, it will see the same thing that also behaves the same.

at runtime the 2 forms both exists. (only not in the solution model)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8884
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Methods

Who is online

Users browsing this forum: No registered users and 7 guests