August 22, 2007

Data Binding Concepts

Filed under: — admin @ 7:36 pm

Data bindings are simply links between a UI component and some data. The data binding implements everything that is needed to retrieve the data from a data source and update the UI component, plus all that is needed to store any input made in the UI component by the user. The data bindings work in an orchestrated way so that what is displayed to the user is consistent with what is in the datastore.

Data Binding In Depth

Carousel applications use the Model-View-Controller (MVC) pattern to separate the key concerns in building an application. A key principal of this separation is that the model can be implemented without overdue concern for the presentation layer or user interface. Keeping the model simple makes it easy to implement business logic.
image

The separation of the model also means that the business logic need have little concern for the modalities or peculiarities of the user interface or the user interaction within the application.

Of course the model cannot be completely divorced from the user interface as occasionally interaction is required, say for instance if the model requires special input or needs to signal an error. Carousel achieves the separation of concerns espoused by the MVC architecture by implementing a loose coupling between the data model and the user interface.

On the data or model side of the architecture Carousel provides a rich data model that can be addressed via XML and XPath like references. This model can be composed of a wide variety of data and the data can be used in a variety of ways depending on the needs of the user interface and application.

Typically the data model will consist of data from a number of data sources such as static data defined in flat files, tables mapped in from a database, server side data obtained via service calls and configuration information.

Carousel also saves its own data to the model, for example saving the component state data to the xui_state node so that things like list selections indices can be accessed via the mode or used for master details linking.

Your application may also save data to the model as it needs. The model grows with your application and its content is highly configurable. For example each node within the model can have multiple child nodes and each node can be a rich type, not just the basic types built into Java. Tables themselves are good examples of these composite objects, consisting of multiple rows and with rows consisting of multiple fields.

The diagram below shows how various data sources might be mapped into the hierarchy and how an individual object can be a composite of other objects. The diagram also serves to show the hierarchical arrangement of data which we will see being used in the next section on data binding.

Source : Sourceforge.net


An Introduction to XML Data Binding in C++

Filed under: — admin @ 8:32 pm

XML processing has become a common task that many C++ application developers have to deal with. Using low-level XML access APIs such as DOM and SAX is tedious and error-prone, especially for large XML vocabularies. XML Data Binding is a new alternative which automates much of the task by presenting the information stored in XML as a statically-typed, vocabulary-specific object model. This article introduces XML Data Binding and shows how it can simplify XML processing in C++.

Introduction

A typical C++ application that has to manipulate the data stored in XML format uses one of the two common XML access APIs: Document Object Model (DOM) or Simple API for XML (SAX). DOM represents XML as a tree-like data structure which can be navigated and examined by the application. SAX is an event-driven XML processing API. The application registers its interest in certain events, such as start element tag, attribute, or text, which are then triggered during the parsing of an XML instance. While DOM has to read the whole document into memory before the application can examine the data, SAX delivers the data as parsing progresses.

Anyone who has had to handle a large XML vocabulary using DOM or SAX can attest that the task is hardly enjoyable. After all, both DOM and SAX are raw representations of the XML structure, operating in generic elements, attributes, and text. An application developer often has to write a substantial amount of bridging code that identifies and transforms pieces of information encoded in XML to a representation more suitable for consumption by the application logic. Consider, for example, a simple XML document that describes a person:

<person>
<name>John Doe</name>
<gender>male</gender>
<age>32</age>
</person>

If we wanted to make sure the person’s age is greater than some predefined limit, with both DOM and SAX we would first have to find the age element and then parse the string representation of 32 to obtain the integer value that can be compared. Another significant drawback of generic APIs is string-based flow control. In the example above, when we search for the age element we pass the element name as a string. If we misspell it, we (or a user of our program) will most likely only discover this bug at runtime. String-based flow control also reduces code readability and maintainability. Furthermore, generic APIs lack type safety because all the information is represented as text. For example, we can compare the content of the gender element to an invalid value without any warning from the compiler:

DOMElement* gender = …

if (gender->getTextContent () == “man”)
{

}

In recent years a new approach to XML processing, called XML Data Binding, has emerged thanks to the progress in XML vocabulary specification languages (XML schemas). The main idea of XML Data Binding is to skip the raw representation of XML and instead deliver the data in an object-oriented representation that models a particular vocabulary. As a result, the application developer does not have to produce the bridging code anymore because the object model can be used directly in the implementation of the application logic. In the example above, instead of searching for the age element and then manually converting the text to an integer, we would simply call the age() function on the person object that already returns the age as an integer. The name XML Data Binding comes from the observation that the object representation is essentially bound to and becomes a proxy for the data stored in XML.

The vocabulary-specific object representation along with other support code such as parsing and serialization functions are generated by a data binding compiler from an XML schema. A schema is a formal specification of a vocabulary that defines the names of elements and attributes, their content, and the structural relationship between them. The majority of XML Data Binding tools use the W3C XML Schema specification language due to its object-oriented approach to the vocabulary description as well as its widespread use. The following fragment describes the XML vocabulary presented above using W3C XML Schema:

<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>

<xs:simpleType name=”gender_t”>
<xs:restriction base=”xs:string”>
<xs:enumeration value=”male”/>
<xs:enumeration value=”female”/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name=”person_t”>
<xs:sequence>
<xs:element name=”name” type=”xs:string”/>
<xs:element name=”gender” type=”gender_t”/>
<xs:element name=”age” type=”xs:short”/>
</xs:sequence>
</xs:complexType>

<xs:element name=”person” type=”person_t”/>

</xs:schema>

Even if you are not familiar with XML Schema, it should be fairly straightforward to figure out what is going on here. The gender_t type is an enumeration with the only valid string values being “male” and “female”. The person_t type is defined as a sequence of the nested name, gender, and age elements. Note that the term sequence in XML Schema means that elements should appear in a particular order as opposed to appearing multiple times. Finally, the globally-defined person element prescribes the root element for our vocabulary. For an easily-approachable introduction to XML Schema refer to XML Schema Part 0: Primer.

Similar to the direct XML representation APIs, XML Data Binding supports both in-memory and event-driven programming models. In the next sections we will examine the complexity of performing common XML processing tasks using DOM and SAX compared to in-memory and event-driven XML Data Binding. The DOM and SAX examples in this article are based on Apache Xerces-C++ open-source XML parser with character conversions omitted to keep the code focused. The XML Data Binding examples are based on CodeSynthesis XSD open-source XML Schema to C++ data binding compiler.

Source : Artima


Basic Data Binding Concepts

Filed under: — admin @ 8:35 pm

Regardless of what element you are binding and the nature of your data source, each binding always follows the model illustrated by the following figure:
Basic data binding diagram

As illustrated by the above figure, data binding is essentially the bridge between your binding target and your binding source. The figure demonstrates the following fundamental WPF data binding concepts:

  • Typically, each binding has these four components: a binding target object, a target property, a binding source, and a path to the value in the binding source to use. For example, if you want to bind the content of a TextBox to the Name property of an Employee object, your target object is the TextBox, the target property is the Text property, the value to use is Name, and the source object is the Employee object.
  • The target property must be a dependency property. Most UIElement properties are dependency properties and most dependency properties, except read-only ones, support data binding by default. (Only DependencyObject types can define dependency properties and all UIElements derive from DependencyObject.)
  • Although not specified in the figure, it should be noted that the binding source object is not restricted to being a custom CLR object. WPF data binding supports data in the form of CLR objects and XML. To provide some examples, your binding source may be a UIElement, any list object, a CLR object that is associated with ADO.NET data or Web Services, or an XmlNode that contains your XML data. For more information, see Binding Sources Overview.

As you read through other software development kit (SDK) topics, it is important to remember that when you are establishing a binding, you are binding a binding target to a binding source. For example, if you are displaying some underlying XML data in a ListBox using data binding, you are binding your ListBox to the XML data.

To establish a binding, you use the Binding object. The rest of this topic discusses many of the concepts associated with and some of the properties and usage of the Binding object.
Direction of the Data Flow

As mentioned previously and as indicated by the arrow in the figure above, the data flow of a binding can go from the binding target to the binding source (for example, the source value changes when a user edits the value of a TextBox) and/or from the binding source to the binding target (for example, your TextBox content gets updated with changes in the binding source) if the binding source provides the proper notifications.

Continue reading on MSD


Component Data Binding

Filed under: — admin @ 8:38 pm

DataBinding is core to XPComponents, all components directly support data binding, no classes to include, nothing to enable, its all there built in from the ground up.

The XP Components provide a powerful feature rich DataBinding architecture
Data binding in its traditional sense means associating some underlying data with one or more user interface elements. The data provides the information to display. The user interface elements render the information in the appropriate format.

The XP Data Architecture extends the traditional idea of data binding in a number of ways. You can bind a property of a user interface element to a property of any object, or to an attribute of an XMLNode.

The data binding can be unidirectional (in either direction) or bidirectional. For example, traditional data binding has the information in the data source flow to its bound user interface element. Alternatively, the information in the user interface element can flow back to the data source. Bidirectional data binding, of course, supports information flow in each direction and enables user input via user interface element to update the data in the data source.

Data binding can also be static (one time only) or dynamic. With static data binding, the information transfer occurs when you initially create the data binding. Subsequent changes to values in the data do not affect the value in the user interface element. Dynamic data binding allows changes to data in the data source to propagate to the User Interface element and vice versa.

Data binding also supports transformation of the data as it flows to and from the data source and user interface elements. This transformation enables the application author to add UI semantics to the data.

Some typical transformations might be the following:

  • Displaying negative numbers in red and positive numbers in black *Displaying images based on a contact being online or offline *Creating dynamic bar charts by binding a rectangle’s height to a stock price *Animating the position of an image by binding its coordinates to a property of a object
  • Data binding is also fundamentally asynchronous. A user interface element receives an event when a new data source binds to the element. In addition, as a data source collects its data, it fires events to indicate that its contents have changed.

One can data-bind to any object or XMLNode, and hence one can easily data-bind to various data models. A number of built-in data source classes are provided that allow you to easily and declaratively bring data asynchronously into an application. There are specific data sources for XML, Objects. The data source model is extensible, so you can create your own custom data source classes when necessary.

Source : ePresenterPlus


Data Binding an Enum with Descriptions

Filed under: — admin @ 8:42 pm

Every once in a while I need to bind an enumerated type to a Windows Forms control, usually a ComboBox. There are lots of articles here on The CodeProject that present various ways to do this, each with their own pros and cons. However, they are generally more complicated than necessary, and in some cases, require a lot of work on either the developer implementing the enum, the developer using it, or both.

The Simple Way

The simplest is to use the Enum.GetValues() method, setting its result to the DataSource property of the ComboBox. If you have the following enum:

public enum SimpleEnum
{
Today,
Last7
Last14,
Last30,
All
}

You can bind it to a ComboBox like this:

ComboBox combo = new ComboBox();
combo.DataSource = Enum.GetValues(typeof(SimpleEnum));

While this does work, there are a couple of problems:

  1. There is no support for localization.
  2. There is no support for more readable descriptions.

Binding with Descriptions

Fortunately, there is a relatively easy way to meet these requirements using a little bit of Reflection and decorating the enum values with an attribute. You don’t need a lot of generic classes, custom classes, or custom type descriptors…just two static methods that are both less than 10 lines of code.

The first step is to add a description attribute to your enum. For simplicity, you can use the System.ComponentModel.DescriptionAttribute class, but I would recommend deriving your own EnumDescriptionAttribute.

Collapse

/// <summary>
/// Provides a description for an enumerated type.
/// </summary>
[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field, AllowMultiple = false)]
public sealed class EnumDescriptionAttribute : Attribute
{
private string description;

/// <summary>
/// Gets the description stored in this attribute.
/// </summary>
/// <value>The description stored in the attribute.</value>
public string Description
{
get
{
return this.description;
}
}

/// <summary>
/// Initializes a new instance of the
/// <see cref=”EnumDescriptionAttribute”/> class.
/// </summary>
/// <param name=”description”>The description to store in this attribute.</param>
public EnumDescriptionAttribute(string description)
: base()
{
this.description = description;
}
}

Now that we have our description attribute, we need to decorate the enum with it:

public enum SimpleEnum
{
[EnumDescription(”Today”)]
Today,

[EnumDescription(”Last 7 days”)]
Last7,

[EnumDescription(”Last 14 days”)]
Last14,

[EnumDescription(”Last 30 days”)]
Last30,

[EnumDescription(”All”)]
All
}

Using a custom attribute allows you to keep the human readable description in the code where the enum is defined. It also allows you to retrieve localized versions of the description. In order to do that, you simply need to change the way the attribute works to lookup the appropriate string in the string resources.

The next part is what actually does all of the work. As I mentioned, both of these functions are less than 10 lines of code. The easiest way to work with these functions is to create a static (or sealed, if you aren’t using .NET 2.0 or later) class that holds these two static functions.

/// <summary>
/// Provides a static utility object of methods and properties to interact
/// with enumerated types.
/// </summary>
public static class EnumHelper
{
/// <summary>
/// Gets the <see cref=”DescriptionAttribute” /> of an <see cref=”Enum” /> type value.
/// </summary>
/// <param name=”value”>

The <see cref=”Enum” /> type value.</param> /// <returns>A string containing the text of the /// <see cref=”DescriptionAttribute”/>.</returns> public static string GetDescription(Enum value) { if (value == null) { throw new ArgumentNullException(”value”); } string description = value.ToString(); FieldInfo fieldInfo = value.GetType().GetField(description); EnumDescriptionAttribute[] attributes = (EnumDescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(EnumDescriptionAttribute), false); if (attributes != null && attributes.Length > 0) { description = attributes[0].Description; } return description; } /// <summary> /// Converts the <see cref=”Enum” /> type to an <see cref=”IList” /> compatible object. /// </summary> /// <param name=”type”>The <see cref=”Enum”/> type.</param> /// <returns>An <see cref=”IList”/> containing the enumerated /// type value and description.</returns> public static IList ToList(Type type) { if (type == null) { throw new ArgumentNullException(”type”); } ArrayList list = new ArrayList(); Array enumValues = Enum.GetValues(type); foreach (Enum value in enumValues) { list.Add(new KeyValuePair<Enum, string>(value, GetDescription(value))); } return list; } }

As you can see, the GetDescription method uses a little bit of Reflection to retrieve the EnumDescription attribute on the specified enum value. If it doesn’t find the attribute, it simply uses the value name. The ToList method returns an IList of KeyValuePair<Enum, string> instances that hold the enum value (the key) and the description (the value). If you aren’t using .NET 2.0 or later, you will need to use DictionaryEntry instead of KeyValuePair<TKey, TValue>.

In order to bind the ComboBox, you now need to do the following:

ComboBox combo = new ComboBox();
combo.DataSource = EnumHelper.ToList(typeof(SimpleEnum));
combo.DisplayMember = “Value”;
combo.ValueMember = “Key”;

You now have a ComboBox whose values are your enum type values and whose display are the string specified in the EnumDescription attribute. This works with any control that supports data binding, including the ToolStripComboBox, although you will need to cast the ToolStripComboBox.Control property to a ComboBox to get to the DataSource property. (In that case, you will also want to perform the same cast when you are referencing the selected value to work with it as your enum type.)

Source : Code Project


HTML Definition

Filed under: — admin @ 8:59 pm

HTML (Hypertext Markup Language) is the set of markup symbols or codes inserted in a file intended for display on a World Wide Web browser page. The markup tells the Web browser how to display a Web page’s words and images for the user. Each individual markup code is referred to as an element (but many people also refer to it as a tag). Some elements come in pairs that indicate when some display effect is to begin and when it is to end.

HTML is a formal Recommendation by the World Wide Web Consortium (W3C) and is generally adhered to by the major browsers, Microsoft’s Internet Explorer and Netscape’s Navigator, which also provide some additional non-standard codes. The current version of HTML is HTML 4.0. However, both Internet Explorer and Netscape implement some features differently and provide non-standard extensions. Web developers using the more advanced features of HTML 4 may have to design pages for both browsers and send out the appropriate version to a user. Significant features in HTML 4 are sometimes described in general as dynamic HTML. What is sometimes referred to as HTML 5 is an extensible form of HTML called Extensible Hypertext Markup Language (XHTML).


History of HTML

Filed under: — admin @ 9:23 pm

In 1986, a new ISO standard (ISO 8879) was released which aimed to make platform and display differences irrelevant to the delivery and rendering of documents. This standard detailed the language called the Standard Generalized Markup Language (SGML.)

Tim Berners-Lee and the Genesis of the WWW

In 1989, Tim Berners-Lee created a proposal for a hypertext document system to be used within the CERN community. Although based in Switzerland, CERN members were scattered throughout the globe and project turnover was often high. Collaboration over long distances, getting new project members quickly up to speed and preservation of information in the face of frequent member turnover were the driving factors in the development of the proposed system. This system, which Berners-Lee later named “The World-Wide Web” in October of 1990, outlined several important components necessary to realize the vision and which, in a nutshell, defines the nature of the WWW today:

  1. It must be cross-platform
  2. Must be able to use many existing informational resource systems while also allowing new information to be easily added
  3. A transport mechanism was necessary to move documents across networks [evolved into HTTP]
  4. An identification scheme for addressing both local and remote hypertext documents [evolved into URL addressing]
  5. A formatting language for the hypertext documents. This was not explicitly mentioned, but was part and parcel of presenting the information received [evolved into HTML]

The Development of HTML

Berners-Lee developed and defined the HTML language, which was created and defined using SGML, during the development cycle for the first Web browser/editor from October to December 1990. The first version of the browser initially ran only on the NeXT platform and was only processing text files, but it was a start. Berners-Lee later put the code and specifications for the project (including HTML) on the Internet in the summer of 1991. During the next few years the system introduced by Berners-Lee caught on in the Internet community - and the ‘web’ of documents available was steadily growing. A common library of code was available to programmers to easily create the needed capabilities to access web documents. Browsers quickly became available for a wide variety of platforms. As the number of implementations grew, the variety did also. The HTML language originally specified by Berners-Lee had developed and extended far beyond its initial form and no real standard had yet been developed. For a further discussion of how the first HTML standard finally developed, please see the HTML 2.0 history page.

Source : Eskimo


Basic HTML

Filed under: — admin @ 9:25 pm

This is an introduction of the very basics of HyperText Mark-up Language. H-T-M-L are initials that stand for HyperText Markup Language (computer people love initials and acronyms — you’ll be talking acronyms ASAP). Let me break it down for you:

# Hyper is the opposite of linear. It used to be that computer programs had to move in a linear fashion. This before this, this before this, and so on. HTML does not hold to that pattern and allows the person viewing the World Wide Web page to go anywhere, any time they want.

# Text is what you will use. Real, honest to goodness English letters.

# Mark up is what you will do. You will write in plain English and then mark up what you wrote. More to come on that in the next Primer.

# Language because they needed something that started with “L” to finish HTML and Hypertext Markup Louie didn’t flow correctly. Because it’s a language, really — but the language is plain English.

Source : HTMLgoodies


HTML Advantages

Filed under: — admin @ 9:27 pm

If compatibility with user habits, expectations and multiple platforms is the goal, then HTML is the only approach to delivering a web application.

The term is browser

After all, it is a browser, not a menu system. Many approaches to delivering terminal session on the Web use web technology as a menu only. Once the user has clicked on the link that connects to the host, a dedicated window appears containing yet another standard terminal emulator. his approach fails in exploiting many of the benefits that have made the web such a success. When a user is launched into an environment not based on HTML, the user interface changes.

Consistent and effective

elivering host sessions using HTML provides the user with a consistent interface and provides developers a highly effective medium for presenting information. As millions of Web devotees have demonstrated, HTML works. Given that much of the flow of information is out of hosts, isn’t it preferable to deliver it in the most effective medium?

Ideal for expanding cryptic screens

ne of the major usability problems with the fixed format host screen is that over time, many applications have sacrificed prompts and other textual user cues in favor of more data. As business and organizational processes add new informational requirements, the data expands and the “fluff” is pushed off of the limited screen real estate. Unfortunately, that fluff is the difference between an easily understood display and a cryptic mass of data requiring training manuals and frequent help from co-workers.

The freedom of a text markup environment

One of the first things an HTML author learns is that once a good information presentation pattern is established, the size of the page can expand well past the constraints of the user’s screen. The dynamic formatted characteristics of browsers coupled with the dynamic scrolling of the page frees developers from prior contraints which applied to graphical user interfaces as well. For rapidly reformatting information screens for superior understanding and reduced training requirements, HTML offers the best medium to developers.


August 23, 2007

Machine Understandable information: Semantic Web

Filed under: — admin @ 11:39 am

The Semantic Web is a web of data, in some ways like a global database. The rationale for creating such an infrastructure is given elsewhere [Web future talks &c] here I only outline the architecture as I see it.

The basic assertion model

When looking at a possible formulation of a universal Web of semantic assertions, the principle of minimalist design requires that it be based on a common model of great generality. Only when the common model is general can any prospective application be mapped onto the model. The general model is the Resource Description Framework.

See the RDF Model and Syntax Specification

Being general, this is very simple. Being simple there is nothing much you can do with the model itself without layering many things on top. The basic model contains just the concept of an assertion, and the concept of quotation - making assertions about assertions. This is introduced because (a) it will be needed later anyway and (b) most of the initial RDF applications are for data about data (”metadata”) in which assertions about assertions are basic, even before logic. (Because for the target applications of RDF, assertions are part of a description of some resource, that resource is often an implicit parameter and the assertion is known as a property of a resource).

As far as mathematics goes, the language at this point has no negation or implication, and is therefore very limited. Given a set of facts, it is easy to say whether a proof exists or not for any given question, because neither the facts nor the questions can have enough power to make the problem intractable.

Applications at this level are very numerous. Most of the applications for the representation of metadata can be handled by RDF at this level. Examples include card index information (the Dublin Core), Privacy information (P3P), associations of style sheets with documents, intellectual property rights labeling and PICS labels. We are talking about the representation of data here, which is typically simple: not languages for expressing queries or inference rules.

RDF documents at this level do not have great power, and sometimes it is less than evident why one should bother to map an application in RDF. The answer is that we expect this data, while limited and simple within an application, to be combined, later, with data from other applications into a Web. Applications which run over the whole web must be able to use a common framework for combining information from all these applications. For example, access control logic may use a combination of privacy and group membership and data type information to actually allow or deny access. Queries may later allow powerful logical expressions referring to data from domains in which, individually, the data representation language is not very expressive. The purpose of this document is partly to show the plan by which this might happen.

Source : W3C


« Previous PageNext Page »

 
 
ERP systemen
Alle ERP-systemen op een rij, compleet met ERP-nieuws en ERP-software informatie.
www.ERPcentraal.nl
ERP systemen
Alle ERP-systemen op een rij.
www.erpmatrix.nl


Quick Links
Our Friends
Cool Places
Visit also
About Us