labs / tiddlers / content / labs / lab03 / _Labs_03_Using the Product Data

Open your ProductEditor dialog and switch to the source code using the the <

> button in the bar the top of the file.

  1. Add a field to the dialog that is an instance of the DAO class. Don't forget to initialise the field.

  2. Modify the save button click handler in the dialog so that it uses the DAO field to save the product that is being created by calling the saveProduct method on the DAO instance.

  3. Add a dispose call after saving the product. Users are used to seeing a window close when they are finished entering data into it.

  4. Test the system by running it. Add a new product. You won't see much happen at this point, but at least the system shouldn't crash when you click the <

    > button.

  5. Now would be a good time to commit and close the issue since you have completed the 'add a new product' feature.

    Generally, you should close issues when you are think that you are finished with them. This allows you to treat the issues view on GitBucket as a 'to do' list. You can always reopen an issue at a later date if you need to.

A note on error handling: We do not expect you to make this dialog bullet-proof at this point. If the user enters invalid data (or no data) then the system will likely throw an error --- that is OK. There will be a later lab that covers input validation and exception handling where we show you how to make the dialog resilient to user errors.