12.07.2015 Views

Using Zen Components - InterSystems Documentation

Using Zen Components - InterSystems Documentation

Using Zen Components - InterSystems Documentation

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

with an Object Data Model7. Refresh your <strong>Zen</strong> page MyApp.MyNewPage in the browser.Your and now produce identical results.6.7.3 Step 3: Automatic Control SelectionWhen you use instead of , it is no longer necessary to add data view components (controls) to theform, item by item, as described in the section “Binding a to an Object Data Model.” automaticallyextracts this information from the data model at compile time.The following exercise demonstrates the use of a by adapting your page class from previous exercises so thatit uses a different data model. When you complete the exercise and display the page, a new form will appear whose controlsare clearly different from those in previous exercises:1. Return to Studio in the SAMPLES namespace.2. Choose Tools > Copy Class.3. The Class Copy dialog displays. Enter:• Copy Class — MyApp.PatientModel• To — MyApp.EmployeeModel• Select the Replace Instances of Class Name check box.• Click OK.The new class definition for MyApp.EmployeeModel displays in Studio.4. Edit MyApp.EmployeeModel so that it has the following three properties only:Property Name As %String;Property Salary As %Numeric;Property Active As %Boolean;5. Edit the methods inside MyApp.EmployeeModel to work with the new properties:Method %OnLoadModel(pSource As ZENDemo.Data.Employee) As %Status{Set ..Name = pSource.Name}Set ..Salary = pSource.SalarySet ..Active = pSource.ActiveQuit $$$OKAnd:Method %OnStoreModel(pSource As ZENDemo.Data.Employee) As %Status{Set pSource.Name = ..Name}Set pSource.Salary = ..SalarySet pSource.Active = ..ActiveQuit $$$OK6.Choose Build > Compile or Ctrl-F7 or theicon.7. Choose Tools > Copy Class.8. The Class Copy dialog displays. Enter:• Copy Class — MyApp.MyNewPage• To — MyApp.MyOtherPage• Select the Replace Instances of Class Name check box.<strong>Using</strong> <strong>Zen</strong> <strong>Components</strong> 171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!