Mgen spa Engineering 2 tutorial (Part 1): Discuss the Interface Generation option (spaobjectoption) and spa object (spaobject)

Source: Internet
Author: User

Back to the tutorial directory

In part 2 and Part 3, I once talked about the Interface Generation Options and spa objects. However, at that time, the reader was not very familiar with the SPA project, and now the reader was very familiar with the SPA project. In this section, we will further strengthen the knowledge we have learned.

Directory

  • 1. Interface Generation Options
  • 2. Spa objects

 

Returned directory
1. Interface Generation Options

The validationtrigger enumeration in the interface generation options is easy to understand:

Propertychanged: indicates that the control is verified immediately after it is changed.

Lostfocus: Indicates verification after the control loses focus

Explicit: indicates that the verification is not automatically performed, and the developer manually performs the verification (later in the tutorial)

 

The combination of onloadvalidation and objectoption enumeration has different effects.

Onloadvalidation has two values:

None: the verification is not performed after the interface is displayed.

Required: Verify after the interface is displayed

 

Objectoption also has two values:

New: the value of the generated interface control is empty.

Edit: The generated interface control reads the attribute values of the core.

 

Let's look at this type:

// + Using mgen. spa;

// + Using mgen. spa. controls;

// + Using mgen. spa. validators;

Class myspatype

{

[Spaheader ("key1")]

[Textboxstringcontrol]

[Stringrequiredrule]

Public String text {Get; set ;}

 

Public myspatype ()

{

TEXT = "mgen ";

}

}

 

This type has only one property text. After creation, the value is "mgen", the control is a text box, And the validators are stringrequiredrule that cannot be empty.

 

The following is the combination of onloadvalidation and objectoption.

Onloadvalidation. required and objectoption. New-the data is empty and there is a verification error:

Onloadvalidation. required and objectoption. Edit-the data is not empty. No verification error is returned:

Onloadvalidation. None and objectoption. New-verification is not performed if the data is null.

Onloadvalidation. None and objectoption. Edit-the data is not empty and verification is not performed.

 

Returned directory
2. Spa objects

This part was originally in the UI generation and hello World section 2nd of the tutorial. However, the reader just learned about the page generation and is reading the Hello world code, it may affect readers to understand some simple concepts. So I moved it here. At this time, the tutorial has already reached Part 1 without knowing it. The reader has a very good understanding of the SPA project, so I would like to emphasize the use of this spa object (spaobject type:

 

The spa object (spaobject type) represents the data of the interface object generated and is bound to a data object. For example, in this Code:

VaR myobject = new myspatype ();

VaR opt = new spaobjectoption (

New validationoption (

Validationtrigger. propertychanged,

Onloadvalidation. required,

Objectoption. Edit ),

New defaultresprovider (typeof (RES )),

Res. Title );

VaR spaobject = spamanager. GetObject (myobject, OPT );

 

New spawindow (spaobject). showdialog ();

 

The final spa object, that is, the spaobject variable, is tightly bound to the Data Object (myobject variable.

Developers can use this spa object to create spawindow multiple times to edit the myobject multiple times. (You do not need to create a spa object multiple times in this process)

However, developers cannot display a spa object in multiple spawindows at the same time. (This is meaningless)

 

In addition, because the spa object represents the data in the bound object interface, if the developer:

> You want to change the language of the corresponding data interface.

> You want to generate an interface for another object.

You must re-generate the interface for the corresponding object (call the spamanager. GetObject method again ).

 

Tip:

In fact, the spa object is the viewmodel of the mvvm programming mode.

 

Finally, we recommend that developers generate a spa object each time they display the interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.