Develop Model, View Template, and Action

Creating Model

Model sets the data that must be processed on the screen. Components can be placed according to the Model field value and data can be represented by binding with the Grid component by registering it as the column of the Dataset object. The Model is not used alone and it is used in connection with the View template. When connecting the Model to the View component, the View template is selected and the content is created according to the logic written in the View template.

Registering a model type service

1

Select the [TypeDefinition> Services] item in Project Explorer.

2

Add the service to the User Service item. Select "model" for the Type item and set the PrefixID.

You can also import Model Group, Model Service, and Model data from services set as URL, ServiceList, and DataSchema when registering a model type service. See link below.

Querying the Model service

Adding Model Service items

To create a new Model, the QuickCode panel must be enabled.

1

Select the menu [QuickCode > View > QuickCode] item.

2

Select the Model tab when the QuickCode panel is displayed.

3

Right-click the model type service item added in TypeDefinition to launch the context menu and select [Insert > Model Service] to add Model Service.

4

Right-click the Model Service item to launch the context menu and select [Insert > Model] to launch the Model Wizard.

Creating Model in Model Wizard

1

Enter Model ID and Name.

If you enter the ID item value, the Name item value is entered as the same value. The value of the Name field can be changed to any other value.

2

Finish 버튼을 클릭하면 Wizard 창이 닫히고 Model, Model Service 설정 화면이 표시됩니다.

3

Add field attribute information to be added in the model setting screen.

Click the [+] button at the right end of the Model setting screen and check the 'uselabel' item among the expanded list (Predefined Attribute).

The built-in Field Attribute cannot be deleted. Labels are dimmed to distinguish them from user-added attributes.

4

Click the [+] button on the left of the Model setting screen to add a Field List item.

The Field Type value can be modified after adding the item. The Field Type value does not have a function by itself, but rather refers to which component or function to apply to the corresponding field value when configuring the screen in the View template.

5

Click the Save icon in the menu to save the settings. Double-click the Model item in the QuickCode panel Model tab to display the Model and Model Service setting screen again.

Importing User Attribute List from View Template

If you write the fn_GetFieldUserAttributeList function within the View Template code, you can get the set User Attribute list.

1

Click the [+] button at the right end of the Model setting screen and check the 'Add Attributes' item from the expanded list.

2

Click the settings icon at the far right of the Edit User Attributes window and launch the Add User Attribute window.

3

From the Target List list, select a View Template to import User Attributes from.

4

Check only the User Attribute items to be added to the Attribute List.

5

Click the right arrow button to add the selected User Attribute item to the User Attribute List area.

6

If you click the [OK] button in the Add User Attribute window, you can check the items to be added in the Edit User Attributes window.

7

If you click the [OK] button in the Edit User Attributes window, you can see that the User Attribute has been added to the Model setting screen.

Setting up the Model Service

In the model service editing state, you can set service-related properties in the properties window. Set ID, Name, Url property values.

Check the model information source code

If you change the tab at the bottom of the Model setting screen to 'Source', the generated source code is displayed. You can edit the source code directly and change the bottom tab to "Items" to see the modifications.

Creating View Template

Creating View Template in View Template Wizard

When creating a project, if you check the 'Use QuickCode' item and select 'Install > Sample', the view template used for the tutorial is copied to the viewtemplate folder. You can check the script by double-clicking the View template item. The example does not use the sample View template, but creates a new View template.

1

Select the [Add] item in the QuickCode menu to run View Template Wizard. You can also run View Template Wizard by selecting the menu [File > New > View Template] item without opening the QuickCode panel.

2

Enter Name.

3

Select or enter View Type.

There are four types of built-in types: "FreeForm", "GridView", "ListView", and "Tutorial", and you can add them by directly entering other values. View Type values added directly are displayed as a list when View Template Wizard is executed. Enter "ViewSample" as the View Type item value to distinguish it from the sample.

If you do not want to add an example code in the form of a comment that can be referenced when creating a View Template, change the 'Include Example' item value to false. If true is selected, a View Template is created with example code as shown below.

4

Click the [Finish] button and then create the View template. The created View template can be checked in the QuickCode panel View Template tab.

Creating a View Template with a Designed View Component

View templates can be created with a pre-designed View component screen. The code within the fn_GetViewGenerationResult function is automatically generated based on the View component screen.

1

Design the View component screen in the desired form.

2

With the View component selected, select the menu [QuickCode > Design > Create View Template] item.

3

The View Template Wizard will run. Enter items such as Name and ViewType.

4

Click the [Finish] button and create a View template. In the created View template code, you can see that the code within the fn_GetViewGenerationResult function is automatically generated.

Editing View Template Script

When you create the View template in View Template Wizard or double-click the View template item in the QuickCode panel, a file called [File Name].xviewgen is opened in the edit window. You can edit the script to implement the desired function.

Basic interface functions are written and the necessary information is provided in comments.

In the View template, you need to create 2 functions. The fn_GetViewAttributeList function is used to check whether additional supported functions are processed, regardless of the Model information. In the example, it asks whether to create the button and creates the button UI according to the user’s choice. The fn_GetViewGenerationResult function returns information to form the screen UI for 3 types of information, including the Model selected by the user in the Nexacro Studio.

The following describes what parameters are received from the fn_GetViewAttributeList function and the fn_GetViewGenerationResult function, as well as what types of values should be returned.

fn_GetViewGenerationResult

This is the function that returns the View contents object created based on the values of parameters (fieldarray, contents, generationattr). The parameters used and values returned by the fn_GetViewGenerationResult function use the JSON-formatted object.

Syntax

fn_GetViewGenerationResult(fieldarray, contents, generationattr)

Parameters

Parameter

Type

Description

fieldarray

Object

Model Field information

contents

Object

View information

generationattr

Object

View Generation property information

Return

Type

Description

String

Returns the contents-type object excluding referenceinfo as the character string.

Please refer to fn_GetViewGenerationResult Return Value JSON Format for a detailed description of the return value JSON format.

fieldarray Parameter JSON Format

This is the selected Model information. The default value is the field value when creating the model, and it is transmitted along when Attribute such as "uselabel" is added.

{
	"modelinfo": {
		"serviceid": "mdlSample",
		"serviceurl": ""
	},
	"fieldcount": "2",
	"fields": [
		{
			"id": "name",
			"label": "Name",
			"fieldtype": "FreeText",
			"datatype": "STRING",
			"datasize": "80",
			"uselabel" : "true"
		},
		{
			"id": "company",
			"label": "Company",
			"fieldtype": "FreeText",
			"datatype": "STRING",
			"datasize": "80",
			"uselabel" : "true"
		}
	]
}

contents Parameter JSON Format

This is the View component information to connect Model. You can place the component based on the actual width and height (referenceinfo) at which the component can be placed, excluding the Border area of the View component. The component is placed in consideration of the actual size and spacing of each component and font size.

If the View component already has the model information connected or if there is another component, then the Model information is added, and if the Dataset object is included, then the Objects information is added. Other information related to the View component is transmitted together.

{
	"View": {
		"tag": "View",
		"referenceinfo": {
			"realwidth": "490",
			"realheight": "90"
		},
		"attribute": {
			"id": "View00",
			"taborder": "0",
			"text": "View00",
			"viewdataset": "viewdataset",
			"left": "0",
			"top": "0",
			"width": "500",
			"height": "100",
			"border":"5px solid darkkhaki"
		},
		"Model": [],
		"Objects": [
			{}
		],
		"Bind": [
			{}
		],
		"InitValue": [
			{}
		],
		"Script": {}
	}
}

generationattr Parameter JSON Format

This is the ViewAttribute setting information. Each item is the value returned from the fn_GetViewAttributeList function, and the item value is the set value in the View Template Attributes step when connecting Model.

{
	"attributes": {
		"use_triggerbutton": "true"
	}
}

Return Value JSON Format

This is the View contents value created based on the values of parameters (fieldarray, contents, generationattr) in the View template.

{
	"View": {
		"tag": "View",
		"attribute": {
			"id": "View00",
			"taborder": "0",
			"text": "View00",
			"viewdataset": "viewdataset",
			"left": "85",
			"top": "43",
			"width": "437",
			"height": "110"
		},
		"Model": [
			{
				"fieldid": "name",
				"Components": [
					{
						"tag": "Static",
						"attribute": {
							"id": "Static0",
							"text": "Name",
							"left": 0,
							"top": 0,
							"width": 60,
							"height": 20,
							"font": "normal bold 15pt/normal"
						}
					},
					{
						"tag": "Edit",
						"attribute": {
							"id": "Edit0",
							"left": "Static0:5",
							"top": 0,
							"width": 100,
							"height": 20,
							"font": "normal bold 15pt/normal"
						}
					}
				]
			},
			{
				"fieldid": "company",
				"Components": [
					{
						"tag": "Static",
						"attribute": {
							"id": "Static1",
							"text": "Company",
							"left": 0,
							"top": 30,
							"width": 60,
							"height": 20,
							"font": "normal bold 15pt/normal"
						}
					},
					{
						"tag": "Edit",
						"attribute": {
							"id": "Edit1",
							"left": "Static1:5",
							"top": 30,
							"width": 100,
							"height": 20,
							"font": "normal bold 15pt/normal"
						}
					}
				]
			},
			{
				"fieldid": "",
				"Components": [
					{
						"tag": "Button",
						"attribute": {
							"id": "btn_Trigger",
							"right": 0,
							"top": 0,
							"width": 70,
							"height": 20,
							"text": "Search"
						}
					}
				]
			}
		],
		"Objects": [
			{
				"tag": "Objects",
				"Objects": [
					{
						"tag": "Dataset",
						"attribute": {
							"id": "viewdataset"
						},
						"Dataset": [
							{
								"tag": "ColumnInfo",
								"ColumnInfo": [
									{
										"tag": "Column",
										"attribute": {
											"id": "name",
											"type": "STRING",
											"size": "80"
										}
									},
									{
										"tag": "Column",
										"attribute": {
											"id": "company",
											"type": "STRING",
											"size": "80"
										}
									}
								]
							},
							{
								"tag": "Rows",
								"Rows": [
									{
										"tag": "Row"
									}
								]
							}
						]
					}
				]
			}
		],
		"Bind": [
			{
				"tag": "Bind",
				"Bind": [
					{
						"tag": "BindItem",
						"attribute": {
							"id": "item0",
							"compid": "Edit0",
							"propid": "value",
							"datasetid": "viewdataset",
							"columnid": "name"
						}
					},
					{
						"tag": "BindItem",
						"attribute": {
							"id": "item1",
							"compid": "Edit1",
							"propid": "value",
							"datasetid": "viewdataset",
							"columnid": "company"
						}
					}
				]
			}
		]
	}
}

fn_GetViewAttributeList

This is the function that returns the property information required to create View.

Syntax

fn_GetViewAttributeList()

Return

Type

Description

String

Returns the View Template Attributes list object as the character string.

When returning the null value, the additional property setting is not processed in View Generation Wizard.

Return Value JSON Format

{
	"attributecount": 1,
	"attributes": [
		{
			"id": "use_triggerbutton",
			"edittype": "Boolean",
			"defaultvalue": "true",
			"description": "Create a button for data inquiry (true/false)"
		}
	]
}

When the edittype value is "Enum", it can be processed as follows.

{
    "attributecount": "1",
    "attributes": [
        {
            "id": "gridtype",
            "edittype": "Enum",
            "defaultvalue": "Single Line",
            "enumlist": [
                "Single Line",
                "Multi Line"
            ],
            "description": "Specifies the generation type of grid."
        }
    ]

If the edittype value is "Layout", it can be processed as follows.

{
    "attributecount": "1",
    "attributes": [
        {
            "id": "view_layout",
            "edittype": "Layout",
			"userproperties": {
				"propertycount": "1",
				"properties": [
					{
						"id": "gap",
						"edittype": "Number",
						"defaultvalue": 5
					}
				]
			}
        }
    ]

fn_GetFieldUserAttributeList

This is the function that returns the User Attributes information to be added as the Model field when creating Model.

The View template that did not define the fn_GetFieldUserAttributeList function is not displayed in the View Template List when adding the Model field.

Syntax

fn_GetFieldUserAttributeList()

Return

Type

Description

String

Returns the User Attributes list object to be added as the Model field as the character string.

When returning the null value, the Attribute List is not displayed.

Return Value JSON Format

{
	"attributecount": 1,
	"attributes": [
		{
			"id": "editable",
			"edittype": "Boolean",
			"defaultvalue": "true",
			"description": "Sets whether the field data can be edited."
		}
	]
}

View Template Sample

In the example, we create two View templates. viewSampleForm creates the search condition UI according to the Model information or UI that represents detailed information of the item selected in the Grid component. viewSampleGrid represents the Grid component according to the Model information.

In the sample below, Object, Array are used to create the JSON return value format, and you can write the code with only the strings as shown below.

...
var strDataset1 = "{";
strDataset1 += "\"tag\": \"Dataset\",";
strDataset1 += "\"attribute\": {\"id\": \"viewdataset\"},";
strDataset1 += "\"Dataset\": [";
strDataset1 += "{\"tag\": \"ColumnInfo\",";
strDataset1 += "\"ColumnInfo\": [";
...

In the sample code, all the codes were added inside the function, but the method of creating a separate function by dividing each object included in the return value and combining the result values may be slightly cleaner.

viewSampleForm

Create the Edit component according to the field information, and if the uselabel additional property is "true", then place the Static component in front of the Edit component. The fn_GetViewAttributeList function returns the item called use_triggerbutton and determines whether to create Button.

Create the Dataset object with the id of viewdataset and then bind it to the Edit component value property.

fn_GetViewGenerationResult = function (fieldarray, contents, generationattr) {
    var vResult = "";
	var json_contents = JSON.parse(contents);
	var json_fieldarray = JSON.parse(fieldarray);
	var json_generationattr = JSON.parse(generationattr);
	
	var View = new Object(); // JSON Object	
	var tempInfo;
	var tempPostion;
	
	var ModelArray = new Array();
	var ModelInfo;
	
	var ComponentArray;
	var ObjectsArray = new Array();
	var ObjectArray = new Array();
	var DatasetArray = new Array();
	var ColumnArray = new Array();
	var BindsArray = new Array();
	var BindArray = new Array();

	for (var i in json_fieldarray.fields) {
		ModelInfo = new Object();
		ComponentArray = new Array();
		ModelInfo.fieldid = json_fieldarray.fields[i].id;
		
		tempInfo = new Object();
		tempInfo.tag = "Column";
		tempInfo.attribute = new Object();
		tempInfo.attribute.id = json_fieldarray.fields[i].id;
		tempInfo.attribute.type = json_fieldarray.fields[i].datatype;
		tempInfo.attribute.size = json_fieldarray.fields[i].datasize;
		ColumnArray.push(tempInfo);
		
		if(json_fieldarray.fields[i].uselabel == "true") {
			tempInfo = new Object();
			tempInfo.tag = "Static";
			tempInfo.attribute = new Object();
			tempInfo.attribute.id = "Static"+i;
			tempInfo.attribute.text = json_fieldarray.fields[i].label;
			tempInfo.attribute.left = 0;
			tempInfo.attribute.top = i*30;
			tempInfo.attribute.width = 60;
			tempInfo.attribute.height = 20;
			tempInfo.attribute.font = "normal bold 15pt/normal";
			ComponentArray.push(tempInfo);
		}
		
		tempInfo = new Object();
		tempInfo.tag = "Edit";
		tempInfo.attribute = new Object();
		tempInfo.attribute.id = "Edit"+i;
		tempInfo.attribute.left = "Static"+i+":5";
		tempInfo.attribute.top = i*30;
		tempInfo.attribute.width = 100;
		tempInfo.attribute.height = 20;
		tempInfo.attribute.font = "normal bold 15pt/normal";
		ComponentArray.push(tempInfo);
		
		tempInfo = new Object();
		tempInfo.tag = "BindItem";
		tempInfo.attribute = new Object();
		tempInfo.attribute.id = "item"+i;
		tempInfo.attribute.compid = "Edit"+i;
		tempInfo.attribute.propid = "value";
		tempInfo.attribute.datasetid = "viewdataset";
		tempInfo.attribute.columnid = json_fieldarray.fields[i].id;
		BindArray.push(tempInfo);	
		
		ModelInfo.Components = ComponentArray;
		ModelArray.push(ModelInfo);		
	}
	tempInfo = new Object();
	tempInfo.tag = "ColumnInfo";
	tempInfo.ColumnInfo = ColumnArray;
	DatasetArray.push(tempInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Rows";
	tempInfo.Rows = new Array();

	var RowInfo = new Object();
	RowInfo.tag = "Row";
	tempInfo.Rows.push(RowInfo);
	DatasetArray.push(tempInfo);

	tempInfo = new Object();
	tempInfo.tag = "Dataset";
	tempInfo.attribute = new Object();
	tempInfo.attribute.id = "viewdataset";
	tempInfo.Dataset = DatasetArray;
	ObjectArray.push(tempInfo);
	
	tempInfo = new Object();	
	tempInfo.tag = "Objects";	
	tempInfo.Objects = ObjectArray;
	ObjectsArray.push(tempInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Bind";
	tempInfo.Bind = BindArray;
	BindsArray.push(tempInfo);
	
	if(json_generationattr.attributes.use_triggerbutton == "true") {
		ModelInfo = new Object();
		ComponentArray = new Array();
		ModelInfo.fieldid = "";
		
		tempInfo = new Object();
		tempInfo.tag = "Button";
		
		var buttonwidth = 70;
		tempInfo.attribute = new Object();
		tempInfo.attribute.id = "btn_Trigger";
		tempInfo.attribute.right = 0;
		tempInfo.attribute.top = 0;
		tempInfo.attribute.width = buttonwidth;
		tempInfo.attribute.height = 20;
		tempInfo.attribute.text = "Search"
		ComponentArray.push(tempInfo);
		ModelInfo.Components = ComponentArray;
		ModelArray.push(ModelInfo);
	}	

	tempInfo = new Object();
	tempInfo.tag = "View";
	tempInfo.attribute = json_contents.View.attribute;
	tempInfo.Model = ModelArray;
	tempInfo.Objects = ObjectsArray;
	tempInfo.Bind = BindsArray;

	View.View = tempInfo;
	var vResult = JSON.stringify(View);
    return vResult;
};

fn_GetViewAttributeList = function () {
	var attrArray = new Array();
	var attrObj = new Object();
	attrObj.id = "use_triggerbutton";
	attrObj.edittype = "Boolean";
	attrObj.defaultvalue = "true";
	attrObj.description = "Create a button for data inquiry (true/false)";
	attrArray.push(attrObj);
	
	var attr = new Object();
	attr.attributecount = attrArray.length;
	attr.attributes = attrArray;
	
	var strJson = JSON.stringify(attr);
	trace("RE : "+strJson);	
	return strJson;
};

viewSampleGrid

Create the Grid component and the Dataset object according to the field information and then bind the Dataset object to the Grid component. The fn_GetViewAttributeList function is not used.

fn_GetViewGenerationResult = function (fieldarray, contents, generationattr) {
    var vResult = "";
	var json_contents = JSON.parse(contents);
	var json_fieldarray = JSON.parse(fieldarray);
	//var json_generationattr = JSON.parse(generationattr);
	
	var View = new Object(); // JSON Object	
	var tempInfo;
	
	var ModelArray = new Array();
	var ModelInfo = new Object();
	ModelInfo.fieldid = "";

	var ComponentArray = new Array();
	var ObjectsArray = new Array();
	var ObjectArray = new Array();
	var DatasetArray = new Array();
	var ColumnArray = new Array();
	
	var GridColumnsArray = new Array();
	var GridRowsArray = new Array();
	var GridBandHeadArray = new Array();
	var GridBandBodyArray = new Array();


	for (var i in json_fieldarray.fields) {
		if(ModelInfo.fieldid != "") {
			ModelInfo.fieldid += ",";
		}
		ModelInfo.fieldid += json_fieldarray.fields[i].id;
		
		tempInfo = new Object();
		tempInfo.tag = "Column";
		tempInfo.attribute = new Object();
		tempInfo.attribute.id = json_fieldarray.fields[i].id;
		tempInfo.attribute.type = json_fieldarray.fields[i].datatype;
		tempInfo.attribute.size = json_fieldarray.fields[i].datasize;
		ColumnArray.push(tempInfo);
		
		tempInfo = new Object();
		tempInfo.tag = "Column";
		tempInfo.attribute = new Object();
		tempInfo.attribute.size = "80";
		GridColumnsArray.push(tempInfo);

		tempInfo = new Object();
		tempInfo.tag = "Cell";
		tempInfo.attribute = new Object();
		tempInfo.attribute.col = i;
		tempInfo.attribute.text = json_fieldarray.fields[i].label;
		GridBandHeadArray.push(tempInfo);		
		
		tempInfo = new Object();
		tempInfo.tag = "Cell";
		tempInfo.attribute = new Object();
		tempInfo.attribute.col = i;
		tempInfo.attribute.text = "bind:"+json_fieldarray.fields[i].id;
		tempInfo.attribute.edittype = "text";
		GridBandBodyArray.push(tempInfo);
	}
	var GridInfo = new Object();
	GridInfo.tag = "Formats";
	GridInfo.Formats = new Array();
	var formatInfo = new Object();
	formatInfo.tag = "Format";
	formatInfo.attribute = new Object();
	formatInfo.attribute.id = "default";
	formatInfo.Format = new Array();
	
	tempInfo = new Object();
	tempInfo.tag = "Columns";
	tempInfo.Columns = GridColumnsArray;
	formatInfo.Format.push(tempInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Row";
	tempInfo.attribute = new Object();
	tempInfo.attribute.band = "head";
	tempInfo.attribute.size = "24";
	GridRowsArray.push(tempInfo);
	tempInfo = new Object();
	tempInfo.tag = "Row";
	tempInfo.attribute = new Object();
	tempInfo.attribute.size = "24";
	GridRowsArray.push(tempInfo);	

	tempInfo = new Object();
	tempInfo.tag = "Rows";
	tempInfo.Columns = GridRowsArray;
	formatInfo.Format.push(tempInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Band";
	tempInfo.attribute = new Object();
	tempInfo.attribute.id = "head";
	tempInfo.Columns = GridBandHeadArray;
	formatInfo.Format.push(tempInfo);	
	
	tempInfo = new Object();
	tempInfo.tag = "Band";
	tempInfo.attribute = new Object();
	tempInfo.attribute.id = "body";	
	tempInfo.Columns = GridBandBodyArray;
	formatInfo.Format.push(tempInfo);	
	GridInfo.Formats.push(formatInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Grid";
	tempInfo.attribute = new Object();
	tempInfo.attribute.id = "Grid"+i;
	tempInfo.attribute.left = 0;
	tempInfo.attribute.top = 0;
	tempInfo.attribute.right = 0;
	tempInfo.attribute.bottom = 0;
	tempInfo.attribute.binddataset = "viewdataset";
	tempInfo.Grid = new Array();
	tempInfo.Grid.push(GridInfo);
	ComponentArray.push(tempInfo);		
		
	tempInfo = new Object();
	tempInfo.tag = "ColumnInfo";
	tempInfo.ColumnInfo = ColumnArray;
	DatasetArray.push(tempInfo);
	
	tempInfo = new Object();
	tempInfo.tag = "Rows";
	tempInfo.Rows = new Array();

	var RowInfo = new Object();
	RowInfo.tag = "Row";
	tempInfo.Rows.push(RowInfo);
	DatasetArray.push(tempInfo);

	tempInfo = new Object();
	tempInfo.tag = "Dataset";
	tempInfo.attribute = new Object();
	tempInfo.attribute.id = "viewdataset";
	tempInfo.Dataset = DatasetArray;
	ObjectArray.push(tempInfo);
	
	tempInfo = new Object();	
	tempInfo.tag = "Objects";	
	tempInfo.Objects = ObjectArray;
	ObjectsArray.push(tempInfo);
	
	ModelInfo.Components = ComponentArray;
	ModelArray.push(ModelInfo);

	tempInfo = new Object();
	tempInfo.tag = "View";
	tempInfo.attribute = json_contents.View.attribute;
	tempInfo.Model = ModelArray;
	tempInfo.Objects = ObjectsArray;

	View.View = tempInfo;
	var vResult = JSON.stringify(View);
    return vResult;
};

fn_GetViewAttributeList = function () {
	return null;
};

Creating Action

This step is to set the function that will actually operate on the screen created using the Model and the View template. When a specific event occurs in the object specified as Trigger, the specified action is processed. In the example, when the button is clicked in the search window, the data is displayed in the Grid component. According to the Action property value for data search, the Alert dialog box is displayed if the specific property value is selected when the data search is successful.

Action is created in the form of the user module and is then installed in Nexacro Studio.

You can create the Action module by creating the Invisible Object project in the Nexacro module developer beta.

Creating Action Module Project

1

Run the Nexacro module developer beta.

If you did not create the shortcut when installing Nexacro Studio, then run the "nexacromoduledeveloper.exe" file in the installation folder.

2

Select the menu [File > New > Project] to run Project Wizard.

3

Select Invisible Object from the Module item.

4

Enter Project Name and click the [Next] button.

5

Enter Object ID. Object ID is set to the Action object name.

In the example, "TestQueryAction" is entered as Object ID. ClassName is automatically populated when Object ID is entered. Change the value of the FinalClass property to true and the value of the Contents property to false.

6

Click the [Finish] button.

The project is created. Detailed option settings are not set in this example. The detailed properties of the object can be set at any time after project creation.

Adding Action Object

When creating the project, one default object is created and the object to deploy in the same module must be added.

1

Select the menu [File > New > Invisible Object] to run Invisible Object Wizard.

2

Enter Object ID.

The name of the Action object to add is "TestAlertAction". Change the value of the FinalClass property to true and the value of the Contents property to false.

3

Click the [Finish] button.

Editing Action Object Property

1

Select the TestQueryAction and TestAlertAction object MetaInfo items in the Project Explorer and modify the property values below in the properties window.

subgroup: Action
registration: allow

2

Save your changes.

Editing Action Object Script

1

Double-click the Action object script file to be edited in Project Explorer or select the [Edit] item from the context menu.

2

Modify the script file according to the Action object.

The Action script inherits and implements nexacro.Action. The basic structure is as follows and the run function is executed when the event occurs. The necessary information is collected and processed within the run function.

The information needed in the script can be accessed using the Action object property and method.

Action Object Properties, Methods, & Events

(function(nexacro) {
    "use strict";

	if (!nexacro)
		return;
	if (nexacro.TestQueryAction)
		return nexacro.TestQueryAction;

	var TestQueryAction = function(id, parent)
	{
        nexacro.Action.call(this, id, parent);
	};	
		
	var _pTestQueryAction = nexacro._createPrototype(nexacro.Action, TestQueryAction);		
	TestQueryAction.prototype = _pTestQueryAction;
	_pTestQueryAction._type_name = "TestQueryAction";
	_pTestQueryAction.uservalue = null;	
	
	_pTestQueryAction.destroy = function ()
	{
		nexacro.Action.prototype.destroy.call(this);
		this.uservalue = null;
    };

	_pTestQueryAction.set_uservalue = function (v)
	{
		if (v && this.uservalue!== v)
		{		
			this.uservalue= v;
		}
	};

	_pTestQueryAction.run = function ()
	{
	};

    nexacro.TestQueryAction = TestQueryAction;
    return TestQueryAction;
}) (nexacro);

The script used for TestQueryAction, TestAlertAction is as follows.

TestQueryAction Script

When the trigger occurs (when the button is clicked) the run function is called. By calling the _getArgumentList function, the sum of the Contents information transmitted as the parameter and the column value saved in the viewdataset object are returned, and after checking the XML file for data loading with the value entered in samplefilename, the transaction method is executed. In the example, since the XML file is called directly, the value transmitted to the parameter is output using the trace method and not used.

$r_title(TestQueryAction.js)
(function(nexacro) {
    "use strict";

	if (!nexacro)
		return;
	if (nexacro.TestQueryAction)
		return nexacro.TestQueryAction;

	var TestQueryAction = function(id, parent)
	{
        nexacro.Action.call(this, id, parent);
	};	
		
	var _pTestQueryAction = nexacro._createPrototype(nexacro.Action, TestQueryAction);		
	TestQueryAction.prototype = _pTestQueryAction;
	_pTestQueryAction._type_name = "TestQueryAction";		
	
	_pTestQueryAction.samplefilename = ""; // XML file name	
	_pTestQueryAction.alerttype = false; // TestAlertAction condition
	_pTestQueryAction.targetobj = null;

	_pTestQueryAction.destroy = function ()
	{
		nexacro.Action.prototype.destroy.call(this);
        this.samplefilename = null;
		this.alerttype = null;
        this.targetobj = null;		
    };
    
	_pTestQueryAction.set_samplefilename = function (v)
	{
		if (v && this.samplefilename !== v)
		{		
			this.samplefilename = v;			
		}
	};
	
	_pTestQueryAction.set_alerttype = function (v)
	{
		if (v && this.alerttype !== v)
		{		
			this.alerttype = v;			
		}
	};	
	
    _pTestQueryAction.set_targetobj = function (v)
	{
		if (v && this.targetobj !== v)
		{
			this.targetobj = v;	
		}
    };	


	_pTestQueryAction._getArgumentList = function (strType)
	{
		var argumentlist = this.getContents(strType);
		if (!argumentlist) {
			return;
		}
		if(strType == "model")
		{
			for (var i = 0; i < argumentlist.length; i++)
			{
				var tempDataset = this.parent.lookup(argumentlist[i].viewid).getViewDataset();
				argumentlist[i].value = tempDataset.getColumn(tempDataset.rowposition, argumentlist[i].fieldid);
			}
		}
		return argumentlist;
	};

	_pTestQueryAction.run = function ()
	{
		var targetview = this.getTargetView();
		var viewdataset = targetview.viewdataset;
		var argumentlist = "";

		var modellist = this._getArgumentList ("model");
		var extralist = this._getArgumentList ("extra");
		var outdataset = viewdataset + "=ds_" + viewdataset;

        var callbackfn = "fn_callback";

        if (modellist)
        {
            for (var i = 0; modellist.length > i; i++)
            {
                if (modellist[i].value)
                {
                    argumentlist += modellist[i].name + "=" + modellist[i].value;
                    argumentlist += " ";
                }
            }
        }
		
        if (extralist)
        {
            for (var i = 0; extralist.length > i; i++)
            {
                if (extralist[i].value)
                {
                    argumentlist += extralist[i].name + "=" + extralist[i].value;
                    argumentlist += " ";
                }
            }
        }		
		
		// transaction callback function (onsuccess, onerror event)
		var targetaction = this;
		targetview.form[callbackfn] = function (strSvcID, nErrorCode, strErrorMag)
		{
			if (nErrorCode >= 0)
			{
				targetaction.error = "callback-success";
				targetaction.on_fire_onsuccess();
			}
			else
			{
				targetaction.error = "callback-error";
				targetaction.on_fire_onerror();
			}	
		}

		argumentlist += "dsname=" + viewdataset + " ";
		argumentlist.trim();
		var serviceurl = "Sample::"+this.samplefilename+".xml";
		trace("argumentlist: "+argumentlist);
		trace("outdataset: "+outdataset);
		trace("serviceurl: "+serviceurl);

		targetview.form.transaction("TEST", serviceurl, "", outdataset, argumentlist, callbackfn);
    };		
    
    nexacro.TestQueryAction = TestQueryAction;

    return TestQueryAction;
    
}) (nexacro);

TestAlertAction Script

In the TestAlertAction script, the message property value is included as the alert method parameter and is then executed when the run function is executed.

$r_title(TestAlertAction.js)
(function(nexacro) {
	"use strict";

	if (!nexacro)
		return;
	if (nexacro.TestAlertAction)
		return nexacro.TestAlertAction;
		
	var TestAlertAction = function(id, parent)
	{
		nexacro.Action.call(this, id, parent);
	};
		
	var _pTestAlertAction = nexacro._createPrototype(nexacro.Action, TestAlertAction);		
	TestAlertAction.prototype = _pTestAlertAction;
    _pTestAlertAction._type_name = "TestAlertAction";		
        
    _pTestAlertAction.message = "";

	_pTestAlertAction.destroy = function ()
	{
		nexacro.Action.prototype.destroy.call(this);
        
        this.message = null;
    };

    _pTestAlertAction.set_message = function (v)
	{
		this.message = v;			
	};

    _pTestAlertAction.run = function ()
	{
        alert(this.message);
	};		
	
	nexacro.TestAlertAction = TestAlertAction;

	return TestAlertAction;

}) (nexacro);

Editing Action Object Meta-Info Property

To deploy and use Action as the module, the meta-info file must be created.

1

Double-click the Action object MetaInfo item to be edited in Project Explorer or select the [Edit] item from the context menu.

2

Modify the details of the targetview property.

The parent, targetview properties are the default properties of nexacro.Action and are displayed as default values in meta-info when creating the Action object. Select the targetview item and then modify the information in the property window.

Group: Action
Edit Type: ViewObjList

3

Click the [+] button in the [Property] tab to add the property of the Action object.

When editing the Action script, if you use the Add menu to add the property, then the information is also added to meta-info, but if you directly edit the script, then you need to add it to the meta-info information.

For the TestQueryAction object, add two properties as shown below.

Name: samplefilename
Group: Misc.
Edit Type: String

Name: alerttype
Group: Misc.
Edit Type: Boolean
Default Value: false

For the TestAlertAction object, add one property as shown below.

Name: message
Group: Misc. 
Edit Type: String

The targetview property is not used in the TestAlertAction object. Select the property and then change the Unused item to true.

The contents set in the meta-info file are processed as follows in Controller Wizard when connecting Action.

group

You can specify the group name shown in Controller Wizard. This is auxiliary information that is provided so that the user can easily recognize the property.

edittype

In the ObjectInfo tag, set edittype to "action".

<ObjectInfo ... edittype="action" ...

You can set the user input type by specifying edittype when setting each property. The function to select from the list without entering the value as the text is also supported. The types of edittype that can be used in Action are as follows.

edittype

Description

String

Enters character strings.

Number

Enters numbers.

Boolean

Selects true, false values.

ModelServiceID

Provides the Model list.

ViewObjList

Provides the list of the View components that can be used in the current Form. Setting the refreshinfo item together will affect sub-items when the selected list is changed.

ViewChildObjList

Provides the list of components or objects contained in the View component selected in ViewObjList.

Creating Action Module File

1

Select [Deploy > Module Package] from the menu.

2

Check the path to create the module file and then click the [Next] button.

Enter information such as the Version as necessary.

3

Click the [Deploy] button to create the xmodule file.