wiseguy wrote:It would be useful if one could run multiple clients from a single computer without using more than one license (e.g. use same form within a solution to compare record data). This could be a problem with a terminal server, but maybe Servoy could detect it was running on a terminal server and act accordingly?
Jan Aleman wrote:wiseguy wrote:It would be useful if one could run multiple clients from a single computer without using more than one license (e.g. use same form within a solution to compare record data). This could be a problem with a terminal server, but maybe Servoy could detect it was running on a terminal server and act accordingly?
Have you tried Servoy's multi-window and multi-instance (create new form instance) functionality for that? What you describe works with that. Limitations would be: multi-transactions (that still needs multiple clients) and you need to 'think' about your globals as they are shared.
Jan Aleman wrote:Have you tried Servoy's multi-window and multi-instance (create new form instance) functionality for that?
/**
* Tracks the number to add on to the form name when a new instance is created.
* Remains zero in all but the first form instance.
*
* @type Number
*
* @properties={typeid:35,uuid:"6454390C-71D2-436D-8B19-618EAB2EE46E",variableType:4}
*/
var formInstance = 0;
/**
* Stores the original form name that the current instance is based on.
* This value is reset for a new form instance in the newWindow method.
*
* @type String
*
* @properties={typeid:35,uuid:"27C1DA59-8F13-4234-809C-BB35E3AD1F59",variableType:-4}
*/
var origFormName = this._formname_;
/**
* Stores all of the named tabs and their related form names so that
* their objects can be referenced consistently regardless of the form instance
* (e.g. forms[this.tabs["myTab"]].elements.myObject.enabled = true).
*
* @type Object
*
* @properties={typeid:35,uuid:"0694F1D2-0F34-47AA-AB80-FB105CD44790",variableType:-4}
*/
var tabs = new Object();
/**
* Creates a new instance of the current form in a new window.
*
* @properties={typeid:24,uuid:"B38A5440-11CD-48C8-A6CB-714277E45B7D"}
*/
function newWindow()
{
// Use original form to keep track of next form instance number.
var instance = ++forms[this.origFormName].formInstance;
// Clone the current form.
var curFormName = this._formname_;
var form = solutionModel.getForm(curFormName);
var newFormName = this.origFormName + instance.toString(); // Get name for new instance.
/**
* @type JSForm
*/
var newForm = solutionModel.cloneForm(newFormName, form);
// Reference original form for future instance number retrieval.
forms[newFormName].origFormName = this.origFormName;
// Make a clone of a tab and add to cloned form.
for (var elementName in forms[curFormName].elements)
{
var element = forms[curFormName].elements[elementName];
if (element.getElementType() == "TABPANEL")
{
for(var tabIndex = 1; tabIndex <= element.getMaxTabIndex(); tabIndex++)
{
var tabFormName = element.getTabFormNameAt(tabIndex);
var tabForm = solutionModel.getForm(tabFormName);
tabFormName += instance; // Get name for new instance
solutionModel.cloneForm(tabFormName, tabForm);
var tabName = element.getTabNameAt(tabIndex);
var tabText = element.getTabTextAt(tabIndex);
var tabRelationName = element.getTabRelationNameAt(tabIndex);
forms[newFormName].elements[elementName].removeTabAt(tabIndex); // Remove the original instance of the tab since it will still be used by the original form.
forms[newFormName].elements[elementName].addTab(forms[tabFormName],tabName,tabText,null,null,null,null,tabRelationName,tabIndex - 1);
// Update form name in "tabs" object to point to new instance of tab form.
if (tabName != null)
{
forms[newFormName].tabs[tabName] = tabFormName;
}
}
}
}
// Show the new form, making the new window name match the new form name.
forms[newFormName].controller.show(newFormName);
forms[newFormName].elements.tabPanel1.tabIndex = 1;
// TODO: Figure out why the new form doesn't stay open when this instance is closed.
}
/**
* Callback method when form is (re)loaded.
*
* @param {JSEvent} event the event that triggered the action
*
* @properties={typeid:24,uuid:"CC1CCD5A-2711-46F4-822D-079A399C8F2A"}
*/
function onLoad(event)
{
// Load named tabs into "tabs" form variable.
for (var elementName in elements)
{
var element = elements[elementName];
if (element.getElementType() == "TABPANEL")
{
for(var tabIndex = 1; tabIndex <= element.getMaxTabIndex(); tabIndex++)
{
var tabName = element.getTabNameAt(tabIndex);
// Add instance reference for tab.
if (tabName != null)
{
var tabFormName = element.getTabFormNameAt(tabIndex);
this.tabs[tabName] = tabFormName;
}
}
}
}
}
getTabElement("myTabPanel", "myTab", "myElementOnTabForm").enabled = true;
/**
* @type String
*
* @properties={typeid:35,uuid:"4EACB2B2-9B6F-4471-BE06-0A4BAECC0A57"}
*/
var _origFormName = '';
/**
* @type Number
*
* @properties={typeid:35,uuid:"6454390C-71D2-436D-8B19-618EAB2EE46E",variableType:4}
*/
var _formInstance = 0;
/**
* Creates a new instance of the current form in a new window.
* @return {Boolean} True if successful.
*
* @properties={typeid:24,uuid:"B38A5440-11CD-48C8-A6CB-714277E45B7D"}
*/
function newWindow()
{
// Use original form to keep track of next form instance number.
/**@type Number*/
var instance = ++forms[_origFormName]._formInstance;
// Clone the current form.
/**@type String*/
var newFormName = _origFormName + instance.toLocaleString(); // Get name for new instance.
/**@type JSForm*/
var origForm = solutionModel.getForm(_origFormName);
/**@type JSForm*/
var newForm = solutionModel.cloneForm(newFormName, origForm);
// Declare remaining variables
/**@type JSTabPanel[]*/
var tabPanels = newForm.getTabPanels();
/**@type JSTab[]*/
var tabs;
/**@type String*/
var newTabFormName;
/**@type JSForm*/
var newTabForm;
// Create a new instance for all tab forms.
for (var tabPanelNum = 0; tabPanelNum < tabPanels.length; tabPanelNum++)
{
tabs = tabPanels[tabPanelNum].getTabs();
for (var tabNum = 0; tabNum < tabs.length; tabNum++)
{
newTabFormName = tabs[tabNum].containsForm.name + instance; // Get name for new instance
newTabForm = solutionModel.cloneForm(newTabFormName, tabs[tabNum].containsForm);
tabs[tabNum].containsForm = newTabForm;
}
}
// Show the new form, making the new window name match the new form name.
forms[newFormName].controller.show(newFormName);
// TODO: Figure out why the new form doesn't stay open when this instance is closed.
return true;
}
/**
* Callback method when form is (re)loaded.
*
* @param {JSEvent} event the event that triggered the action
* @return {Boolean} True if successful.
*
* @properties={typeid:24,uuid:"269F4D95-3838-45FB-848A-71820A46AE9D"}
*/
function onLoad(event)
{
// Get solutionModel instance of the form.
/**@type JSForm*/
var form = solutionModel.getForm(controller.getName());
// Setup solutionModel compatible variable if needed.
if (form.getFormVariable("_origFormName") === null)
{
form.newFormVariable("_origFormName", JSVariable.TEXT).defaultValue = '"' + controller.getName() + '"';
controller.recreateUI();
this._origFormName = controller.getName(); // Set value since defaultValue doesn't take effect until new instances.
}
// return _super.onLoad(event);
return true;
}
/**
* @param {String} tabPanelName The tab panel that contains the tab.
* @param {String} tabName The tab that contains the element.
* @param {String} elementName The name of the element to retrieve.
* @return {JSComponent} The element or undefined if element is not found.
*
* @properties={typeid:24,uuid:"D6B28F5D-2832-4C1D-8293-91CF965EC673"}
*/
function getTabElement(tabPanelName, tabName, elementName)
{
/** @type JSTabPanel */
var tabPanel;
/** @type JSTab */
var tab;
/** @type JSForm */
var tabForm;
/** @type JSComponent */
var element;
tabPanel = solutionModel.getForm(controller.getName()).getTabPanel(tabPanelName);
if (tabPanel)
{
tab = tabPanel.getTab(tabName);
if (tab)
{
tabForm = tab.containsForm;
if (tabForm)
{
element = forms[tabForm.name].elements[elementName];
if (element)
{
return element;
}
}
}
}
return undefined;
}
hsummerhays wrote:update: Be sure to base the namedFoundSet property of the form or superform to "separate". :end update
Users browsing this forum: No registered users and 19 guests