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.
TypeDefinition에서 서비스 추가하기
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.
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
데이터 유형에 따라 IOType 항목값을 설정합니다.
조회 조건처럼 사용자가 입력하거나 선택한 데이터를 서버에 전송하는 용도의 경우에는 "input", 조회 결과를 보여주는 용도의 경우에는 "output"을 선택합니다.
3
Finish 버튼을 클릭하면 Wizard 창이 닫히고 Model, Model Service 설정 화면이 표시됩니다.
4
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.
5
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.
6
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.
7
Model을 복사해서 조회 결과를 처리할 Model을 만듭니다.
Model을 선택하고 컨텍스트 메뉴에서 [Copy] 항목을 선택합니다.
컨텍스트 메뉴에서 [Paste] 항목을 선택해 새로운 Model 항목을 만들고 저장합니다. 그리고 속성창에서 id, iotype, name을 수정한 후 다시 저장합니다.
User Attribute 추가하기
Predefined Attribute에 원하는 항목이 없는 경우에는 User Attribute를 추가할 수 있습니다.
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
View 템플릿을 만드는 2가지 방법
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.
View 템플릿에서는 아래와 같은 함수를 구현해주어야 합니다.
함수명 | 필수 여부 | 설명 |
---|---|---|
fn_GetViewGenerationResult | O | Model 정보에 따라 화면 UI 구성을 위한 정보를 반환합니다. |
fn_GetViewAttributeList | O | View 생성에 필요한 추가 속성 정보를 반환합니다. 함수를 사용하지 않는다면 null을 반환하도록 합니다. |
fn_GetFieldUserAttributeList | X | User Attributes 처리를 위한 정보를 반환합니다. User Attributes를 사용할 경우에만 작성합니다. |
다음 내용에서는 각 함수에서 받는 매개변수는 어떤 형태이고 반환해야 하는 값은 어떤 형태인지 살펴보겠습니다.
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
- Model name (Service ID)serviceurl
- Service URL
fieldcount
- fields countfields
id
- Model Field IDlabeltext
- Model Field Labelfieldtype
- Model Field Field Typedatatype
- Model Field Data Typedatasize
- Model Field Data Sizeuselabel
- Added Attribute
{ "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
- Tag Name (View)referenceinfo
realwidth
- Width of the View component, excluding the Border arearealheight
- Height of the View component, excluding the Border area
attribute
- Properties set in the View componentid
taborder
text
viewdataset
left
top
width
height
Model
Objects
Bind
InitValue
Script
{ "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
[attribute name]
- ViewAttribute Setting Value
{ "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
- Tag Name (View)attribute
- Properties set in the View component (the Contents parameter value if not modified)Model
- Sets the component list for each field as an arrayfieldid
- When referencing multiple fields, like the Grid component, enter them separated by commas (,), and then enter the empty value for components without field information.Components
InitValue
Objects
Bind
Script
{ "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": "ds_company" }, "Dataset": [ { "tag": "ColumnInfo", "ColumnInfo": [ { "tag": "Column", "attribute": { "id": "code", "type": "STRING", "size": "80" } }, { "tag": "Column", "attribute": { "id": "data", "type": "STRING", "size": "256" } } ] }, { "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
- Number of attributesattributes
id
- Value displayed as the View Template Attributes item in View Generation Wizardedittype
- Boolean/String/Number/Enum/ViewObjList/Layoutdefaultvalue
- Default value when edittype is Enumenumlist
- Array of values when edittype is Enumuserproperties
- Set custom property when edittype is Layoutdescription
- Description displayed when the item is selected in View Generation Wizard
{ "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
fn_GetFieldUserAttributeList 함수는 2가지 기능을 지원합니다.
Model 생성 시 Model 필드로 추가할 User Attributes 정보를 반환합니다.
Model 적용 시 User Attributes 정보를 Model 필드로 추가합니다.
Model 생성 시 User Attributes 처리
Model 생성 시 [Add User Attribute] 설정에서 fn_GetFieldUserAttributeList 함수를 가진 View Template 목록을 Target List에 표시하고 View Template을 선택하면 추가할 수 있는 User Attributes 정보를 표시합니다.
Model 적용 시 User Attributes 처리
View 컴포넌트에 Model 적용 시 선택한 View Template에 fn_GetFieldUserAttributeList 함수가 있다면 User Attributes 정보를 Model 필드에 추가합니다.
Model에서 정의한 User Attribute와 id가 같은 경우에는 Model에서 정의한 User Attribute를 적용합니다.
Syntax
fn_GetFieldUserAttributeList()
Return
타입 | 설명 |
---|---|
String | Model 필드로 추가할 User Attributes 목록 오브젝트를 문자열로 반환합니다. null 값을 반환하면 Attribute List를 표시하지 않습니다. |
Return Value JSON Format
attributecount
- Number of attributesattributes
id
- Value displayed as the User Attributes itemedittype
- Boolean/String/Number/Enum/ViewObjListdescription
- Description displayed when selecting the Model field item
{ "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.
Model에 따라 Dataset 오브젝트를 생성하고 생성된 Dataset 오브젝트는 viewdataset 속성값으로 설정됩니다. 그리고 Edit 컴포넌트 value 속성에 바인딩합니다.
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 = "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); 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.
(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.
_getArgumentList 함수를 호출해서 매개변수로 넘겨진 Contents 정보와 viewdataset 속성으로 설정된 Dataset 오브젝트에 저장된 컬럼값을 합친 값을 반환받고 samplefilename에 입력된 값을 가지고 데이터 로딩을 위한 XML 파일을 확인한 후 transaction 메소드를 실행합니다.
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.