Tags:
create new tag
, view all tags
-- PedroRio - 16 Dec 2010

Object Modelling - XEO Library

In this chapter you'll learn how to create the XEO Library entities as XEO Models. We'll begin by modeling the simplest entity of the application: The Book Author.

Modeling an entity to an Object Model - The author

Before that, however, you want to group all XEO Object Models in the same XEO Package, for that you'll use the XEO Package Wizard in XEO Studio. Go to the "File" menu, choose "New" and select "XEO Package". A new window will open to allow you to choose the package name (follow the XEO convention and name it LIB$1.0) and give it a small description such as "XEO Library Object Models", leaving the Parent Package field blank (you won't use subpackages in the Library project), see figure OM.1 for details.

XEO Package Wizard

Figure OM.1 - XEO Package Creation Wizard

Next you need to use the new XEO Model wizard to create the new XEO Model. Go to the "File" menu, select "New" and choose "XEO Object Model". In the "XEO Package" field choose the "Lib$1.0" package just created and in the "Name" field type "LIB_Author" (in this project, all XEO Models will be prefixed with "LIB_"), enter a description of the XEO Model and leave all other fields with their default values (see figure OM.2).

XEO Object Model Wizard

Figure OM.2 - XEO Object Model Wizard

Open the XEO Model, this will open the Object Model Editor, which has three different views: Edit, Design and Source. Edit is the graphical editor for the XML Language, Design is Eclipse's XML editor, and Source is the XML source code. The Object Model Editor (in design mode) is depicted in figure OM.3. It's designed as a master-detail interface. The left panel has all the main properties of an Object Model (Model properties, Attributes, Events, OPL, Methods) while the right panel (Detail Area) displays the properties of the given element chosen from the left panel.

XEO Object Model Editor

Figure OM.3 - XEO Object Model Editor, for the Author Model

Creating an Attribute

With the LIB_Author Object Model open, add an attribute. Back in the XEO Library introduction, the author entity was defined as only having one attribute (its name). The name will be a textual value, thus, you need to add a "Text" attribute to LIB_Author. Click the "Plus" green button in the Attributes section of the left panel of the editor and from the list choose "Text". This will add the attribute to the list and open the detail panel with the newly created attribute.

In the "name" field, write "name" and for the label type "Name" (Or "Author Name") this is the label that'll be used in edit viewers for form fields. You can write a description (documentation) of the attribute and set the length with a maximum of 80 characters (see figure OM.3a). The "name" field is the name which we'll use when dealing with the Java API when interacting with this particular attribute (it's also the name that will be used to create the column in the database table corresponding to this XEO Model).

LIB_Author name attribute

Figure OM.3a - Editing attribute name

As soon as you save the model, the XEO Builder will execute to create the required structures for your Object Model.

Before diving into the rest of the XEO Models, you can see you how fast you can start your applications, in the next section called XEO in Action!

XEO in Action - A quick overview!

With what you have so far, you can create a Main viewer to your application that'll allow you to list every author in the application as well as create/edit new ones. First you must create the Main viewer, by going to the "File" menu, press "New" and choose "XEO Web Viewer"; from the list that appears choose "Main Viewer" and press "Next". In the next window type "Main" in the Name field, leave the "Create new Profile" box checked and type "Library" as the profile name and "Library Profile" as the description (see the procedure depicted in figure OM.4, bellow). This will create your Main viewer and create a XEO Profile (which will be used later for other purposes).

Creating the Main Viewer

Figure OM.4 - Create new Main Viewer and Profile

With this step you now have a Main Viewer, only requiring a List and Edit Viewer to be able to list author instances and create new ones (as well as edit existing ones). You'll learn more about how to create List/Edit Viewers later in the documentation, for now you'll use a useful feature in XEO Studio to create a prototype list/edit/lookup viewer, based on the LIB_Author XEO Model. This feature is called XEO Scaffolding and it will basically analyze XEO Models and create viewers accordingly; XEO Scaffolding is a way to speed up development by quickly generating viewers based on the XEO Model's metadata (you can choose to override/merge new attributes in existing ones). In order for you to see a menu with the "Authors" you need to check the option "Add to Main Viewer" and select the Main Viewer you just created (Main.xvw): %TODO% - Update the Scaffolding image.

Scaffolind Author Viewer

Figure OM.4a - Scaffolding XEO Viewers for the LIB_Author Object Model.

Go back to the web browser (if you're still logged in, terminate session by pressing the Logout button in the lower left corner of the main viewer)
and again go to the Login.xvw page, enter SYSUSER/ABC and confirm. Notice that you'll not be taken to the "Main_admin.xvw" page immediately but a combo box will appear (depicted in figure OM.4b), allowing you to choose your profile (more in this later, but remember that while generating the Main_Library viewer you checked the "Create new Profile" option). Choose the "Library Profile" and confirm again, in this way you'll be taken to the Main.xvw viewer, in which you'll see few entries one of them being the "Author" entry (last element of the tree) as depicted in figure OM.4c. If you click on the "Author" entry a new tab will open with the (empty) list of Authors in your application (this uses the List viewer created through scaffolding earlier). A "New" button also exists to allow creating a new instance of an author (using the Edit viewer created through the scaffolding as well).

Profile Choice

Figure OM.4b - Profiles in Login Page


List Authors

Figure OM.4c - Main viewer with author entry in main viewer and author list viewer open

Press the "New" button and a new tab will open. This tab will have the fields to edit (in this case, create a new one) an instance of an author and has a toolbar to deal with common operations with a specific instance (save, save and close the tab, delete the current instance, validate the fields and check properties). You'll notice that in tab titles there are some broken image links and the new author tab has a number of the title (figure OM.4d); those values can be changed and the images can be set so that a nice icon appears in the tab title (we'll see that later in the documentation).

New Author

Figure OM.4d - Edit Viewer for the Author

If you write a name, for example "John Doe" and press the "Save and Close" button (The button with the small floppy drive with a with cross in red background icon, second from the left) you will have created your very first XEO Model instance. In the List viewer the changes are not reflected automatically, but if you press the little refresh button (see red circle in figure OM.4e) the data is refreshed and the author is displayed (figure OM.4e).

Created Author

Figure OM.4e - List Viewer After Data Reload

Before going back to modeling other entities, you'll see how to add custom behavior to a Model.

XEO in Action! - Simple Behavior customization

Just to show you some of things XEO can do to help you create your application, you'll now make the name of the Author a required field (i.e. you cannot save an author if you don't fill its name. It would not make sense in the Library application anyway, because an Author only has one attribute which is its name).

Open the LIB_Author Object Model in XEO Studio and select the "name" attribute. Go to the "Required" section and from the drop down menu choose "BOL" ( Business Object Language) and in the text field that appears, write "true" (see figure OM.4f for details) and save the Object Model. XEO Studio will invoke the builder to process these changes.

Author Required Attribute

Figure OM.4f - Adding a requirement condition to the name attribute of Author


If you now return the Author List Viewer and press the "New" Button, the result will be like the one depicted in figure OM.4g. Since the field is required it should not be possible to save this instance and if you press the "Save" Button, you'll be presented with the screen depicted in figure OM.4h. This section was just to show how easy it is to build these applications using XEO, more to come in the following sections.

Author Required Field

Figure OM.4g - Author Edit Viewer with Name attribute required

Required Field Error

Figure OM.4h - Error message when saving Author without name


XEO Library - Modeling the Entities:

With the Author created, you can create the remaining XEO Models of the application.

Topic attachments
I Attachment ActionSorted ascending Size Date Who Comment
PNGpng AuthorRequiredAttribute.png manage 18.3 K 2010-12-17 - 12:22 PedroRio Author Required Attribute
PNGpng AuthorRequiredField.png manage 6.8 K 2010-12-17 - 13:57 PedroRio Author Required Attribute Viewer
PNGpng CreatedAuthor.png manage 9.6 K 2010-12-17 - 12:02 PedroRio New Author in List
PNGpng CreatingMainViewer.png manage 43.6 K 2010-12-17 - 10:59 PedroRio Creating the Main Viewer
PNGpng LibAuthorFirstAttribute.png manage 13.4 K 2010-12-16 - 17:52 PedroRio Lib_Author name attribute
PNGpng ListAuthors.png manage 5.0 K 2010-12-17 - 11:02 PedroRio List Authors Viewer
PNGpng NewAuthor.png manage 6.6 K 2010-12-17 - 11:12 PedroRio New Author
PNGpng ProfileChoice.png manage 17.8 K 2010-12-17 - 11:01 PedroRio Profile Choice
PNGpng RequiredFieldError.png manage 9.6 K 2010-12-17 - 13:59 PedroRio Required Field Error
PNGpng ScaffoldAuthorViewers.png manage 57.6 K 2010-12-17 - 11:00 PedroRio Scaffolding Viewers
PNGpng XEOObjectModelEditor.png manage 12.5 K 2010-12-16 - 17:28 PedroRio  
PNGpng XEOObjectModelWizard.png manage 15.6 K 2010-12-16 - 17:03 PedroRio  
PNGpng XEOPackageWizard.png manage 14.0 K 2010-12-16 - 15:47 PedroRio  
Topic revision: r10 - 2012-08-07 - PedroRio
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar