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).

Video 10: Creating OpenDocument Reports

To make your experience smooth, we set the main tags mentioned in the video to the right bar menu of this mini-player. Choose an interesting subtitle on the list and immediately get to the exact theme navigation item place in the video. Now you can pick any topic to be instructed on without watching the whole video.

Steps 302 - 331 Introduction Fixing Errors LinkRoleName ProperCarView Adding a New ViewModel Creating a Report Template Testing the ProduceDocument action

Chapter 10: Correcting Errors (if you have them), Setting LinkRole Names on Association Classes, and Creating OpenDocument 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 and set Requires Root.

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

309. Show the RegistrationNumber in the ProperCarView 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 and Buyer, and remove the AsString default column.

313. Start the web prototype. Search cars and open the ProperCarView 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. (also see the Turnkey Live Editor below)

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 called 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
    321. Close Word to avoid file lock while MDriven Designer tries to access it.

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

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

Solving issues

If downloading the template doesn't work, doublecheck the model name. The name of the "AssetsTK" folder is based on the model name, except the ".modlr" part. If the model file is called "MyStart.modlr", then the folder name should be "MyStart_AssetsTK". Avoid additional dots and other special characters in the model name.

Using the Turnkey Live Editor avoids these problems by creating the correct folder name, but the video doesn't use that editor.

Turnkey Live Editor
Alternatively, select the Turnkey Live Editor Turnkey Live Editor small icon.png found in the top menu of the MDriven Designer:
  1. In the pop-up window, look for the purple tab named "AssetsTK Sync" on the right and click on it.
  2. When it unfolds, look to the extreme left to see a "Start_AssetsTK" folder (Or "whatever name your model is_AssetsTK).
  3. Right-click on the folder and select "Open".
  4. Follow the instructions above to create the Content folder and Word document and retry downloading the template.


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

325. Test the ProduceDocument action and ensure you get a document with the name from the RegistrationNumber.

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 12 days ago on 04/12/2024. What links here