Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to define UI data objects based on service operations
xomega
#1 Posted : Saturday, September 8, 2012 4:56:55 PM(UTC)
xomega



The structure of the UI data objects that serve as a view model, which the UI view controls get bound to, is pretty close to the structure of the UI forms. However, in a multi-tiered application, most of their properties are retrieved from a service layer call and possibly saved using another service call. Therefore, their structure can be very well approximated by the structure of the corresponding service layer operations that are used by that form.

Xomega takes full advantage of this concept and helps you define and generate the UI data objects based on the underlying service model. This may help create rather complete UI data objects, which can be extended and customized further in the code as needed. You can also model relationships between parent and child objects, which will be reflected in the generated objects.

Below are the steps you can take to define such UI objects in the Xomega model.
  1. Find the primary structure in the Xomega service model for the object. It can be either a standalone structure or part thereof, or any part of the input or output structure of an existing service operation. Typically the primary structure would contain the object's key and/or represent the result of reading the object from the service/database.
  2. Make sure that the module element that contains your structure declares a prefix for the "http://www.xomega.net/framework" namespace, e.g. xmlns:xfk="http://www.xomega.net/framework"
  3. Make sure that each type used by parameters in the primary structure is mapped to the proper Data Property.
  4. Add the xfk:data-object element inside of the config element for the primary structure.
  5. Specify the class name for the UI data object by setting the class attribute.
  6. Add the xfk:summary child element to provide the description of the data object.
  7. If you would like to specify another UI data object defined in the model as a child object of this data object, then add the xfk:add-child element nested inside the xfk:data-object element and set its attributes as follows.
  8. Set the class attribute to the class name of the child object by selecting it from the list.
  9. Specify the unique name for the child object within its parent object by setting the name attribute accordingly.
  10. If the child object should be a collection of objects, i.e. a child table, then set the list attribute to true.
  11. Repeat the previous four steps for any other child objects that you want to add to the current data object.

To combine additional parameters from other structures in the model into your current data object, you can perform the following steps.
  1. Add the xfk:add-to-object element inside of the config element for the additional structure that you want to combine into your data object.
  2. Set the class attribute to the class name of the UI data object that you want to add the structure parameters to by selecting it from the list. Parameters with the same name from different structures the data object is comprised of will result in the same Data Property. For example, if an operation to read a data object has a certain parameter, then to save the corresponding Data Property the operation to update the data object should have a parameter with the same name.

After you have defined your objects like this, you can generate the corresponding classes and verify that they build and have the proper structure.

The following sample illustrates these steps.
Code:
<module xmlns="http://www.xomega.net/omodel" xmlns:xfk="http://www.xomega.net/framework">
  <structs>
    <struct name="error log key" object="error log">
      <param name="temporary key" type="temporary key"/>
      <param name="error log id" required="false"/>
      <config>
        <xfk:data-object class="ErrorLogObject">
          <xfk:add-child class="ErrorComment" list="true" name="invoice"/>
          <xfk:summary>A data object for the view model of the Error Details form.</xfk:summary>
        </xfk:data-object>
      </config>
      <doc>
        <summary>Error Log key structure.</summary>
      </doc>
    </struct>
  </structs>
  <objects>
    <object name="error log">
      <fields>
        <field name="error log id" type="error log" key="serial" required="true"/>
        <field name="error time" type="date time" required="true"/>
        <field name="user name" type="string128" required="true"/>
        <field name="error number" type="integer" required="true"/>
        <field name="error severity" type="integer"/>
        <field name="error state" type="integer"/>
        <field name="error procedure" type="string126"/>
        <field name="error line" type="integer"/>
        <field name="error message" type="string4000" required="true"/>
      </fields>
      <operations>
        <operation name="create">
          <output struct="error log key"/>
        </operation>
        <operation name="read">
          <input struct="error log key"/>
          <output>
            <param name="error log id"/>
            <param name="error time"/>
            <param name="user name"/>
            <param name="error number"/>
            <param name="error severity"/>
            <param name="error state"/>
            <param name="error procedure"/>
            <param name="error line"/>
            <param name="error message"/>
            <config>
              <xfk:add-to-object class="ErrorLogObject"/>
            </config>
          </output>
        </operation>
        <operation name="read comments">
          <input struct="error log key"/>
          <output>
            <param name="comment" type="memo"/>
            <param name="time" type="date time"/>
            <param name="user name"/>
            <config>
              <xfk:data-object class="ErrorComment"/>
            </config>
          </output>
        </operation>
        <operation name="update">
          <input>
            <param name="temporary key" type="temporary key"/>
            <param name="error log id"/>
            <param name="error time"/>
            <param name="user name"/>
            <param name="error number"/>
            <param name="error severity"/>
            <param name="error state"/>
            <param name="error procedure"/>
            <param name="error line"/>
            <param name="error message"/>
            <config>
              <xfk:add-to-object class="ErrorLogObject"/>
            </config>
          </input>
        </operation>
      </operations>
    </object>
  </objects>
</module>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Copyright © 2009-2022 Xomega.Net. All rights reserved.