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

Notification

Icon
Error

How to generate an object details form
xomega
#1 Posted : Saturday, September 22, 2012 6:18:26 PM(UTC)
xomega



If you need to create a WPF, Silverlight or an ASP.NET form for displaying and/or editing details of a certain object, for which the data will be read from and saved to the back end via service operations that are defined in your Xomega service model, then you can easily generate such form from the model using one of the corresponding Xomega generators.

The following steps can guide you through this process.
  1. Define service operations in the Xomega model for creating, reading and updating the primary object on the form as well as all child objects. You can build it from scratch or, if it is largely based on the fields of a specific object, you can take the create, read and update operations after generating the Model CRUD Operations for the object and customize them as necessary by adding or removing parameters.
  2. Specify the primary Xomega UI data object for the input structures of the operations that update the object data and output structures of the operations that read the object data, e.g. MyFormObject.
  3. Specify any child UI data objects for the output/input structures used to read/update data in the child tables or sub-objects on the form.
  4. Generate the Xomega UI the objects.
  5. Open properties of the proper details form generator located in the WPF, Silverlight or ASP.NET subfolders of the Presentation Layer generator folder.
  6. Set the Output Path parameter to where you want the generated form files to be output. Use the {File} placeholder to to make the file name based on the corresponding operation name. You can also use the {Module/} placeholder to place the files in different folders based on the modules of the corresponding objects, for example ../MyProject.Client.WPF/Gen/_{File}.xaml.
  7. Set the Form Namespace parameter to the namespace that should be used by the form.
  8. You can also set the Form Name parameter to make the generated form use a specific name rather than generating it based on the object's full name.
  9. In order to generate only the details form based on a specific operation, you can set the Details Object parameter to the name of your primary data object, e.g. MyFormObject.
  10. Right click on the model file that contains your read/update operations and select the Generate > WPF/Silverlight/ASP.NET Details Form from the context menu to run the generator. This will generate a details form for each data object defined in the file, unless you specified the Details Object for your operation as in the previous step, in which case you don't have to run the generator for a specific file but can rather run it for the whole project.
  11. Add the generated forms to your UI project. For the ASP.NET forms right click on the form and select the Convert to Web Application from the context menu to generate the designer code files for the form.
  12. Review the generated form. If the model needs to be updated to fix any issues with the form, then make the necessary changes in the model and regenerate the form following the steps described above.
  13. To start manually customizing the form, you want to rename the file and potentially move it to the right place first, so that your changes wouldn't be lost the next time the details form generator will be run.

The sample below demonstrates how create, read and update operations on an error log object are used to define the primary data object, which allows generating an object details form for the viewing and editing individual errors. It also allows displaying a list of comments for each error by adding a child data object based on the read comments operation.
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 list="true">
            <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.