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.

Data Model Classesbut now the client-side display list consists of the server-side display values in the local language. Any client-side logic forthis control must expect these values.As an example, suppose a property in an MVC data model class uses VALUELIST and DISPLAYLIST as follows:Property Sex As %String(VALUELIST=",1,2", DISPLAYLIST=",Male,Female");In this case, the logical value of Sex will be 1 or 2. This is what will be stored in the database and this is what server-sidelogic will use. An MVC form will only see the display values. Specifically it will see something like this:radioSet.valueList = "Male,Female"radioSet.displayList = $$$Text("Male,Female")Note:For more about localization, the DOMAIN parameter, and $$$Text macros, see the “<strong>Zen</strong> Localization” chapterin Developing <strong>Zen</strong> Applications.6.9.5 Object Data Model Callback MethodsWhen you create an object data model, you subclass %ZEN.DataModel.ObjectDataModel and provide implementations forits server-side callback methods. The following table describes these methods in detail. You first encountered several ofthese methods in the exercise “Constructing a Model” during “Step 2: Object Data Model”. For these methods theExample column contains the word “Yes.”Table 6–4: Object Data Model Callback MethodsMethod%OnDeleteModel%OnDeleteSource%OnGetPropertyInfo%OnInvokeAction%OnLoadModel%OnNewSource%OnOpenSource%OnSaveSourceExample—Yes——YesYesYesYesThis Callback Method is Invoked When...The data model is deleted.This method is implemented by the subclassesof the data model class, if they exist.The data model is deleted. If implemented, it is responsible for deletingthe object that has the given id and returning the status code resultingfrom that operation.The %GetPropertyInfo method invokes it. See the discussion followingthis table.A user-defined, named action is invoked on this model object. See thediscussion following this table. This method is implemented by thesubclasses of the data model class, if they exist.<strong>Zen</strong> does the actual work of loading values from the data source into thedata model object. The only data to load is the data that is actually seenby the user. This is the place to perform any aggregation or otheroperations on the data before storing it.A data model needs a new instance. If implemented, it opens a new(unsaved) instance of the data source object used by the data model,and return its reference.A data model is opened. If implemented, it opens an instance of the datasource object used by the data model, and returns its referenceThe data model is saved. If implemented, it is responsible for savingchanges to the data source. It saves the given source object and returnthe status code resulting from that operation. Before returning the statuscode, it sets the data model’s %id property to the identifier for the sourceobject.<strong>Using</strong> <strong>Zen</strong> <strong>Components</strong> 183

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

Saved successfully!

Ooh no, something went wrong!