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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Model View Controller• For reference information, see the section “Data Model Classes.”6.1.2 %ZEN.DataModel.AdaptorThere are many times where it is convenient to use a persistent object as a data model. To make this easy to accomplish,<strong>Zen</strong> provides the %ZEN.DataModel.Adaptor interface. Adding this an additional superclass to a persistent class will makeit possible to use the persistent class as a data model. This data model makes available to a data controller any and allproperties that it contains. This option is useful when you want to expose every property in an existing class.An example of this might be a class that you are using in an inventory or parts control application, wherein each productmight be described by a class with a large number of properties. If you want to place all of these properties onto a formautomatically without writing another class, you can simply cause the product class to extend %ZEN.DataModel.Adaptor.Following that, <strong>Zen</strong> simply generates the form for you, as later topics will explain. The drawback of this choice is that yourdata and form are very closely linked. If you want some flexibility, you should subclass the object data model class andimplement the internal interface. This is the classic trade-off of convenience versus flexibility.For more information about using %ZEN.DataModel.Adaptor, consult the following sources:• For step by step instructions, see the section “ with an Adaptor Data Model.”• For code examples, use Studio to view the classes ZENMVC.Address and ZENMVC.Person in the SAMPLES namespace.• For reference information, see the section “Data Model Classes.”6.2 ControllerA data controller manages the communication between a data model and a data view. A data controller is any subclass of%ZEN.Auxiliary.dataController. Through class inheritance, every data controller is also a <strong>Zen</strong> component, as the followingfigure shows. This convention permits you to place a data controller on a <strong>Zen</strong> page.154 <strong>Using</strong> <strong>Zen</strong> <strong>Components</strong>

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

Saved successfully!

Ooh no, something went wrong!