ASP.NET provides a server control for verification: CompareValidator verifies comparisons between two control inputs, and RangeValidator checks if the user's input is between the specified upper and lower limits; RegularExpressionValidator control checks if the input is defined with a regular expression. Pattern match (Social Security, email address, phone number, postal code, etc.); RequiredFieldValidator control ensures that the user will not skip an input; the CustomValidator control creates a custom server and client verification code. Will explain later.
The Java Web framework usually comes out of the verification rule and placed in a verification rule file. Apache Struts provides two ways to verify. One is the Validate method for overloading the org.apache.struts.Action.Actionform class, one is to define the validator plug-in file, validator-rules.xml. Apache Cocoon also provides similar verification rule files. A later illustration.
ASP.NET example
From the .NET framework document, the rest is omitted, and only the part of the RegularExpressionValidator is retained. In this example, the ControlTovAlidate property of the Control for the regularExpressionValidator1 is TextBox1, so RegulaRexpressionValidator1 is responsible for verifying whether TextBox1 meets the regular expression "/ d {5}" - 5 numbers.
Runat = "server" />
td>
ID = "RegularExpressionValidator1"
ControlTovAlidate = "TextBox1"
ValidationExpression = "/ d {5}"
DISPLAY = "static"
EnableClientScript = "false"
ErrorMessage = "Zip code Must Be 5 Numeric Digits"
Runat = "server" />
td>
An example of Apache Struts
The following example is extracted from the user document of Apache Struts. The Validation mechanism provided by Apache Struts is very powerful, enabling conditional verification based on other input domains, that is, if another or several input domains meet the appropriate case, verify that the current domain meets a certain condition.
The following example is the file in the teaching program of Apache Cocoon. Verify the ID and NAME two domains. At the same time, this file defines the binding between page elements and database data. The next section will explain this problem.
constraint-set>
constraint-set>
Personnel Connection>
keys>
values>
TABLE>
root>
Database Driven Page
As shown in the last section of the last section, many web development frameworks provide direct binding of page elements and database fields.
The .NET framework contains three controls that make a large amount of data: Repeater control, DataList control, and DataGrid controls. These three controls use similar data binding procedures, bind to DataSet, SqlDataReader or DataView. The following code example is extracted from the .NET Framework document, showing how the DataSet returned by the SQL database query is binded to the DataGrid control.
// Create a connection to the "Pubs" SQL Database Located on The // Local Computer.
SqlConnection myconnection = new SqlConnection ("Server = localhost;"
"Database = PUBS; Trusted_Connection = YES");
// Connect to the SQL Database Using A SQL SELECT Query TO GET ALL
// The data from the "authors" table.
Sqldataadapter mycommand = new sqldataadapter ("SELECT"
"* From authors", myconnection;
// CREATE AND FILL A DATASET.
DataSet DS = New DataSet ();
MyCommand.Fill (DS);
// bind mydatagrid to the dataset. Mydatagrid is theid for the
// DataGrid Control in The HTML Section.
DataView Source = New DataView (ds.tables [0]);
MyDataGrid.datasource = Source;
MyDataGrid.databind ();
}
script>
<% - Display The DataGrid Information in The Body of The Page. -%>
Simple Select to a DataGrid Control
font> h3>
<% - Display The Data IN a DataGrid. -%>
Width = "700"
Backcolor = "# ccccff"
Bordercolor = "Black"
Showfooter = "false"
Cellpadding = 3
Cellspacing = "0"
Font-name = "verdana"
Font-size = "8pt"
Headerstyle-backcolor = "# aaaadd"
EnableViewState = "false"
/>
body>
Html>
Multilingual support
Multi-language support strategies basically take a model similar to the Trial Dictionary. First, a ratio example is given, for example, we have English Dictionary, English Dictionary, Ontario Dictionary, English-French Dictionary, for an English word, each dictionary has a word corresponding language, meet the needs of users of different languages. We call the English word to be checked as Key, all the dictionary is called resource file, and the words of the corresponding language, that is, the content of the user should be displayed. ,
The above mode is simple and common, no longer listing example code, and only a brief description is described below. The .NET framework manages the different regional resources used in the application through an important resource management class System.Resources.ResourceManager. The calling party can access specific regional resources using both GetObject and getString methods. The parameters of these two methods include a key, and a local language information. The .NET resource file suffix is a DLL.
Apache Struts project class org.apache.struts.util.MessageResources's GetMessage method provides a similar function. The Apache Struts project provides an extended HTML TAG - Message, which also plays a multi-language support, localization. Struts's resource file suffix is Properties, format Follow the format of the Java Properties file.
The Apache Cocoon project provides a type called I18N TRANSFORMER for multilingual support. Commonly used markers such as and . Cocoon's multi-language support strategy is the same as before, the application method is similar, but the implementation is not the same - Cocoon uses XSLT to implement multi-language support. Cocoon's resource file suffix is XML, format Follow the XML format. It seems that the XML will be implemented, and it is not Cocoon.