The 1000 steps program to MDriven Chapter 10

This is Chapter 10. If you want to start from the beginning, you can start here. See also: Chapter 9 (the previous chapter).

Here is the Chapter 10 video: https://youtu.be/2K5YHBVyhyA

Video 10: MDrivenEducationVideo Chapter 10: Creating a Report

Title Content Time(Segment Start)
Introduction Introduction Introduction
Fixing errors Handling errors, locating them, and fixing them Fixing errors at 0:06
LinkRoleName Link classes, changing LinkRoleName, and fixing the errors the change creates. LinkRoleName at 05:52
New ViewModel Creating a new ViewModel New ViewModel at 16:22
Creating a Report Creating a report; creating the template URL Creating a Report at 23:07
Adding data Creating a report and adding data to the report document Adding data at 34:13

Correcting Errors (if you have them), Setting LinkRole Names on Association Classes, and Creating Open-document Reports

302. Create some intentional errors, for example, by renaming the CartransferOwnershipDocuments to CartransferOwnershipDocument. Save and practice following the error leads from the red dots, and fix the error.

303. Create some intentional errors, for example, by changing the expression of a class action on Car. Save and practice finding the error from the red dots. Fix the errors, save, and ensure you have a clean model with no errors.

304. Find the link class HistoricOwnership. Select the association and change from <Default> to HistoricOwnerships (with a plural s) in the LinkRoleName on both Association ends for the associations. Save and check for errors.

305. Fix the errors by clicking on them and updating the expressions to reflect the new name HistoricOwnership -> HistoricOwnerships.

306. Drop the ShowCar action that does not have a ViewModel to show.

307. Create a New ViewModel called ProperCarView. Set the Class to Car, Set Requires Root.

308. Add a Class Action to bring the ProperCarView up.

309. Show the RegistrationNumber in the PropertCarView by adding a column.

310. Also, add the State, BrandOfCar, and CarOwner - make them static to avoid editing.

311. Add the multilink for CarTranserOwnershipDocuments as a grid.

312. Add columns in this grid, Seller, Buyer, and remove the AsString default column.

313. Start the web prototype. Search cars and open the PropertCarView on a Car that has CarTranserOwnershipDocuments.

314. Add a Class action: ProduceDocument, and give the ExecuteExpression the value of self.opendocumentreportshow(CarTransferOwnershipDocument.ViewModels.TheTemplateForCarTransferOwnershipDocumentReport). Expect the error due to not having the TheTemplateForCarTransferOwnershipDocumentReport ViewModel yet.

315. Create a TheTemplateForCarTransferOwnershipDocumentReport ViewModel. Set the class to CarTransferOwnershipDocument and check the Requires Root box.

316. Right-click the menu in the ViewModel tree. Add the columns needed for a report. Expect the TemplateUrl and ReportFileName ViewModelColumns.

317. Verify that the action that was faulty before now finds the TheTemplateForCarTransferOwnershipDocumentReport.

318. In the TheTemplateForCarTransferOwnershipDocumentReport ViewModel, click on the UsePlacingHints to hide the UI part of the ViewModel.

319. In the FileMenu ShowCurrentModelDirectory, check the model file name: "Start.modlr". Create a folder named Start_AssetsTK and read about AssetsTK on the Wiki.

320. Create a folder - Content in Start_AssetsTK. Start Word, click on a new document, and write: "this will be my template." Save as ODT format in Start_AssetsTK/Content and call the file: ThisWillBeMyTemplate.odt

  • Alternatively, select the Turnkey Live-editor, and in the pop-up window, look for the "AssetsTK Sync" tab on the right and click on it. On the extreme left, you should see a "Start_AssetsTK" folder. Right-click and open it. Follow the instructions above to create the Content folder and document.

321. Close Word in order to avoid file lock while MDrivenDesigner tries to access it.

322. Check that your app URL is starting with http://localhost:... Test http://localhost:<port>/content/ThisWillBeMyTemplate.odt - Ensure that you can access the template (you must use the port number you use).

323. In the ViewModel for the template, in the Template URL, set the string value 'http://localhost:<port>/content/ThisWillBeMyTemplate.odt'

324. Set the ReportFileName expression to 'TheSalesReportForCar'+self.Car.RegistrationNumber+'.odt'

325. Test the ProduceDocument action and ensure that you get a document with the name from the registration number.

326. In the template odt, add %meta%. Save and close. Resave the model to upload. Test the ProduceDocument again and verify that you can see the expanded properties from the %meta% tag.

327. Head back to ViewModel for the template and add Buyer, Seller, RegistrationNumber, and Brand (self.Car.Brand.Name).

328. Test the ProduceDocument action again. Copy the expanded ViewModel data names from the document and paste them into the original document. This will be expanded into data.

329. Write a text in the template and mix in the tags: The buyer named %Buyer% has purchased the car %RegistrationNumber% of type %Brand% from %Seller%

330. Turn off spellcheck in the document so that the tags are not distorted in the resulting file. Save and close Word. Save the model.

331. Test the ProduceDocument action again. Ensure you get a document with tags expanded to data according to the definition in your template ViewModel.

File:ModelAfterChapter10.zip

Next Chapter:

The_1000_steps_program_to_MDriven_Chapter_11

This page was edited 33 days ago on 04/12/2024. What links here