Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
visionx:data_modeling_and_representation [2020/06/08 12:10] cduncan [Use a View as Data Source] |
visionx:data_modeling_and_representation [2020/06/08 12:16] cduncan [Set data read-only] |
||
---|---|---|---|
Line 410: | Line 410: | ||
We can use a view in the VisionX data object wizard just like any table. | We can use a view in the VisionX data object wizard just like any table. | ||
- | In the VisionX lower pane, select the "NEW table" tab and press the (+) button to open the wizard. In the wizard, select "Use existing data from database tables" and confirm with "Next >", keep the selection "Use Application Database User" and, again, confirm with "Next >". You can now select the view as data source. Note that views have a different icon: | + | In the VisionX lower pane, select the "NEW table" tab and press the (+) button to open the wizard. In the wizard, select "Use existing data from database tables" and confirm with "Next >", keep the selection "Use Application Database User" and, again, confirm with "Next >". You can now select the view as datasource. Note that views have a different icon: |
{{:visionx:data_modeling_and_representation:views_storages_step1.png?nolink|View as datasource: Select view}} | {{:visionx:data_modeling_and_representation:views_storages_step1.png?nolink|View as datasource: Select view}} | ||
Line 422: | Line 422: | ||
Per default, the view is set as "Writeback Table". This means, that the application will try to save changes on the data object's data in the view itself (which works fine for updateable views or views using INSTEAD OF triggers). | Per default, the view is set as "Writeback Table". This means, that the application will try to save changes on the data object's data in the view itself (which works fine for updateable views or views using INSTEAD OF triggers). | ||
- | ==== Define the writeback table ==== | + | ==== Define the Writeback Table ==== |
- | Of course we can name another table or view as the target relation for an INSERT, UPDATE, or DELETE. Let's choose the table "assets". Change the "Writeback Table" to "assets" (1) and the "from" clause to "v_assets_localized" (2) and confirm your changes with "Finish".. | + | Of course, we can name another table or view as the target relation for an INSERT, UPDATE, or DELETE. Let's choose the table "assets". Change the "Writeback Table" to "assets" (1), the "from" clause to "v_assets_localized" (2), and confirm your changes with "Finish". |
{{:visionx:data_modeling_and_representation:views_storages_step3.png?nolink|View as datasource: Edit writeback table}} | {{:visionx:data_modeling_and_representation:views_storages_step3.png?nolink|View as datasource: Edit writeback table}} | ||
- | Whenever we execute an insert or delete on the data object now, the row will actually become inserted into or deleted from the table ASSETS. Given that the columns of the view and the writeback table are named equally, any UPDATES on that columns will also target the ASSETS table. | + | Whenever we execute an insert or delete on the data object now, the row will actually be inserted into or deleted from the table ASSETS. Given that the columns of the view and the writeback table are named equally, any UPDATES on that columns will also target the ASSETS table. |
This is the generated code for the views server-side storage (after [[#creating_an_additional_automatic_link_reference|creating an additional Automatic Link Reference]] between V_ASSETS_LOCALIZED and LOCATIONS): | This is the generated code for the views server-side storage (after [[#creating_an_additional_automatic_link_reference|creating an additional Automatic Link Reference]] between V_ASSETS_LOCALIZED and LOCATIONS): | ||
Line 457: | Line 457: | ||
} | } | ||
</code> | </code> | ||
- | We can use any of the upper data storages ("Assets" or "VAssetsLocalized") for our data object "Assets". I designed this screen, to contain all relevant information about the asset, the employee currently holding the asset and that employee's department. Therefore I created data objects for the tables LOCATIONS and EMPLOYEES and linked it to the "Assets" data object by setting [[#master_references|Master References]]. Moreover I created a data object for the table DEPARTMENTS and made "EMPLOYEES" the Master Table for it. The resulting assets screen looks like this: | + | We can use any of the upper data storages ("Assets" or "VAssetsLocalized") for our data object "Assets". I designed this screen to contain all relevant information about the asset, the employee currently holding the asset, and that employee's department. Therefore, I created data objects for the tables LOCATIONS and EMPLOYEES and linked them to the "Assets" data object by setting [[#master_references|Master References]]. Moreover, I created a data object for the table DEPARTMENTS and made "EMPLOYEES" the master table for it. The resulting assets screen looks like this: |
{{:visionx:data_modeling_and_representation:views_storages_step7.png?nolink|Storage as data source: Desktop app Assets}} | {{:visionx:data_modeling_and_representation:views_storages_step7.png?nolink|Storage as data source: Desktop app Assets}} | ||
- | Anyway, I do not want all that information to be editable in this screen. Let's set some of the data read-only. | + | However, I do not want all that information to be editable in this screen. Let's set some of the data as readonly. |
- | ===== Set data read-only ===== | + | ===== Set Data as Read-Only ===== |
- | Select the assets screen in designer mode and press the "Customize" button (1) at the top left corner. In the lower part of the popup, VisionX suggest some of the events provided by the currently selected control. We want that the data is set read-only in this screen immediately after the screen is created, let's therefore click on "Create On Load" (2). | + | Select the assets screen in designer mode and press the "Customize" button (1) at the top left corner. In the lower part of the popup, VisionX will suggest some of the events provided by the currently selected control. We want that the data is set to read-only in this screen immediately after the screen is created. let's. therefore. click on "Create On Load" (2). |
{{:visionx:data_modeling_and_representation:views_storages_step5.png?nolink|Set data read-only: On Load}} | {{:visionx:data_modeling_and_representation:views_storages_step5.png?nolink|Set data read-only: On Load}} | ||
- | The "Edit Action" window opens. The text in the tab page "Description" will be copied to the documentation of the source code. Let's select the tab page "Action" (1) to specify what shall be done whenever the screen is loaded. Press the drop down list button (2) to see all predefined commands. To avoid scrolling through the list I filter the list by entering "disable" in the editor (3) and press the drop down list button again. Select "Disable Edit in table" (3). | + | The "Edit Action" window opens. The text in the tab page "Description" will be copied to the documentation of the source code. Let's select the tab page "Action" (1) to specify what shall be done whenever the screen is loaded. Press the dropdown list button (2) to see all predefined commands. To avoid scrolling through the list, I filter the list by entering "disable" in the editor (3) and press the drop down list button again. Select "Disable Edit in table" (3). |
> **See**: For detailed information on all available VisionX Actions and how to use them, check out the [[:visionx:actions|documentation]]. | > **See**: For detailed information on all available VisionX Actions and how to use them, check out the [[:visionx:actions|documentation]]. | ||
Line 475: | Line 475: | ||
{{:visionx:data_modeling_and_representation:views_storages_step6.png?nolink|Set data read-only: Select command}} | {{:visionx:data_modeling_and_representation:views_storages_step6.png?nolink|Set data read-only: Select command}} | ||
- | Next we have to specify the data object, that shall not be editable; we choose "[Table: Departments]". To add another action for the same event, drag and drop a command from the right pane to the action table. Let's select "Disable Edit in table" again, this time for "[Table: Employees]". | + | Next, we have to specify the data object that shall not be editable; we choose "[Table: Departments]". To add another action for the same event, drag and drop a command from the right pane to the action table. Let's select "Disable Edit in table" again, this time for "[Table: Employees]". |
- | I still want to be able to change the employee, that is the current holder of the asset. Therefore I bind the editor "Last Name" to the column "Last Name" of the "Localized Assets" storage (which is editable). In designer mode, select the editor and press the "Customize" icon (1). Open the Binding drop-down list (2) and choose "[Localized Assets.Last Name]" (3) as binding for that editor. | + | I still want to be able to change the employee that is the current holder of the asset. Therefore, I bind the editor "Last Name" to the column "Last Name" of the "Localized Assets" storage (which is editable). In designer mode, select the editor and press the "Customize" icon (1). Open the Binding dropdown list (2) and choose "[Localized Assets.Last Name]" (3) as binding for that editor. |
{{:visionx:data_modeling_and_representation:views_storages_step8.png?nolink|Set data read-only: Change editor binding}} | {{:visionx:data_modeling_and_representation:views_storages_step8.png?nolink|Set data read-only: Change editor binding}} | ||
- | Done! My asset screen is ready to use, without writing even one line of Java code: | + | Done! My asset screen is ready to use without writing even one line of Java code: |
{{:visionx:data_modeling_and_representation:views_storages_step9.png?nolink|Set data read-only: result web}} | {{:visionx:data_modeling_and_representation:views_storages_step9.png?nolink|Set data read-only: result web}} |