Code Generator

Labels
AJAX(112) App Studio(7) Apple(1) Application Builder(245) Application Factory(207) ASP.NET(95) ASP.NET 3.5(45) ASP.NET Code Generator(72) ASP.NET Membership(28) Azure(18) Barcode(2) Barcodes(3) BLOB(18) Business Rules(1) Business Rules/Logic(140) BYOD(13) Caching(2) Calendar(5) Charts(29) Cloud(14) Cloud On Time(2) Cloud On Time for Windows 7(2) Code Generator(54) Collaboration(11) command line(1) Conflict Detection(1) Content Management System(12) COT Tools for Excel(26) CRUD(1) Custom Actions(1) Data Aquarium Framework(122) Data Sheet(9) Data Sources(22) Database Lookups(50) Deployment(22) Designer(177) Device(1) DotNetNuke(12) EASE(20) Email(6) Features(101) Firebird(1) Form Builder(14) Globalization and Localization(6) How To(1) Hypermedia(2) Inline Editing(1) Installation(5) JavaScript(20) Kiosk(1) Low Code(3) Mac(1) Many-To-Many(4) Maps(6) Master/Detail(36) Microservices(4) Mobile(63) Mode Builder(3) Model Builder(3) MySQL(10) Native Apps(5) News(18) OAuth(9) OAuth Scopes(1) OAuth2(13) Offline(20) Offline Apps(4) Offline Sync(5) Oracle(11) PKCE(2) Postgre SQL(1) PostgreSQL(2) PWA(2) QR codes(2) Rapid Application Development(5) Reading Pane(2) Release Notes(183) Reports(48) REST(29) RESTful(29) RESTful Workshop(15) RFID tags(1) SaaS(7) Security(81) SharePoint(12) SPA(6) SQL Anywhere(3) SQL Server(26) SSO(1) Stored Procedure(4) Teamwork(15) Tips and Tricks(87) Tools for Excel(2) Touch UI(93) Transactions(5) Tutorials(183) Universal Windows Platform(3) User Interface(338) Video Tutorial(37) Web 2.0(100) Web App Generator(101) Web Application Generator(607) Web Form Builder(40) Web.Config(9) Workflow(28)
Archive
Blog
Code Generator
Monday, June 27, 2011PrintSubscribe
Globalization and Localization

Code On Time web application generator creates standard ASP.NET web projects and web sites, which take full advantage of ASP.NET globalization infrastructure. Globalization in ASP.NET has been perfected by Microsoft to allow creation of web applications that work with all cultures and languages. The building blocks are there and our web application generator puts them together to offer a great solution for your globalization and localization needs.

image

Globalization

Code On Time applications offer full support for world cultures, including date and time, calendar, numeric, and currency formats. Your application code may use one culture for the server side business logic and a different culture for presentation.

Globalization settings are configured in the project wizard on the page titled Globalization and Localization. The screen shot below shows this page in a new project.

image

Culture and UI Culture drop down lists are automatically configured to match the locale of your computer. The screen shot above shows both inputs set to en-US, English (United States) .

The selections in these drop downs are the primary culture set of your application where Culture is governing the culture used in the code executed on the server and UI Culture is controlling the user interface culture aspects of the application.

If you are not planning to create applications for other locales then do not make any changes and simply click Next to continue project configuration.

If you are developing an application for a locale that is different then the one selected in Culture and UI Culture then make sure to change the selections accordingly.

Unlimited edition of web application generator allows specifying multiple culture sets.

You can define multiple culture sets by selecting  combinations in Culture / UI Culture drop downs and pressing Add Cultures button.

For example, if you are developing a line-of-business application that is expected to have users primarily in United States then you may anticipate that users from two neighbor countries Canada and Mexico may need to be supported as well. In this age of glo,bal commerce it should not be surprising that the business users of your web application may need to interact with partners from a far away country such as Taiwan.

Given the example above your application must support English, French, Spanish, and Traditional Chinese. The screen shot below shows the configuration of the corresponding supported culture sets.

image

You can also enter the support culture sets directly into the textbox as follows:

en-US, en-US; es-MX, es-MX; en-CA, en-CA; fr-CA, fr-CA; zh-TW, zh-TW;

Multiple culture sets are separated by semicolon or line breaks. Culture is separated from UI Culture by a comma within each culture set definition. If both Culture and UI Culture are the same then enter just one culture. UI Culture may be non-specific and defined by two letters of the language (fr, es, en).

This particular example assumes that users in different locales do not share the server culture.

This is all that is necessary to ensure that your application will correctly present and process date, time, calendars, numbers, and currency values in one or more locales.

Localization

Code On Time web application generator performs automatic localization of all standard application resources in the languages matched to the UI cultures. Our elegant localization system makes supporting multiple localized resources exceptionally simple and accessible.

Localization is one of the most complex aspects of application development. Various text fragments are typically dispersed in static application files such as pages, menus, reports, help system. Text messages are also emitted by business rules to report all sorts of errors and instructions to the end users of a web application.

ASP.NET does provide standard means of externalizing application resources and creating localized versions of each resource file. A developer must maintain all resource files in sync and embed references to specific resources whenever a fragment of text needs to be referenced.  In fact a developer has to translate their entire application in the language of resource IDs that are subsequently translated into actual text written in the natural language. If your application is AJAX-based then you need to employ additional resource DLLs to ensure that localized text resources are available to the client scripts, which makes the localization process even more complex. Resource files in ASP.NET web applications have XML format, which requires users to exercise great care when changing them.

We have decided to eliminate the complexity from this necessity.

Every generated Code On Time application includes several kinds of files commonly found in many hand-coded ASP.NET web applications:

  • Ajax Client Library resources (*.js files)
  • Data Controller Descriptors (*.xml files)
  • Web Pages (*.aspx files)
  • User Controls (*.ascx files)
  • Site Maps (*.sitemap files) B
  • Core Library and Business Logic (*.cs or*.vb files)

We use a refreshingly simple and consistent method of localizing the application source code. If you open the generated application source code in Visual Studio or Windows Explorer then you will find a collection of text files that include the names of UI cultures supported in your web application.

The screen shot shows the partial contents of the root folder of a generated application that supports cultures listed in the discussion of a globalization example above.

image

The screen shot shows ClientLibrary.*.txt, Resources.*.txt, and Web.Sitemap.*.txt groups of text files.

The first group defines the localized Client Library resources for all supported locales.

The second group defines localized resources used in the business rules and core library of the generated application.

The third group defines a collection of localized resources found in the Web.Sitemap, the file that describes the navigation hierarchy of the application.

You will find a few other clusters of localized resources if you browse the contents of the project. Notice that all of these clusters are associated with a specific static source file of your project much like Web.Sitemap and its satellite resources.

Let’s take a look inside.

Here is the first three lines from ClientLibrary.en-US.txt.

^About^About^About^

^ActionBarActionsHeaderText^Actions^ActionBarActionsHeaderText^

^ActionBarCancelActionHeaderText^Cancel^ActionBarCancelActionHeaderText^

Next example shows the first three lines from ClientLibrary.fr-CA.txt.

^About^À propos^About^

^ActionBarActionsHeaderText^Actions^ActionBarActionsHeaderText^

^ActionBarCancelActionHeaderText^Annuler^ActionBarCancelActionHeaderText^

This snippet shows the first three lines from ClientLibrary.zh-TW.txt.

^About^關於^About^

^ActionBarActionsHeaderText^動作^ActionBarActionsHeaderText^

^ActionBarCancelActionHeaderText^取消^ActionBarCancelActionHeaderText^

You have probably noticed the pattern that includes localization brackets on both sides of a localized resource. A localization bracket must start and end with “^” and may contain any combination of alphanumeric characters, such as ^About^, ^Label1^, and ^23^. We call the combination of matching brackets and text between them a localization token.

Here is an example of localization tokens SiteHome, HomePath, and HomeDesc found in Web.Sitemap.

  <siteMapNode url="~/Default.aspx" title="^SiteHome^Home^SiteHome^" description="">
    <siteMapNode title="^HomePath^Home^HomePath^" 
description="^HomeDesc^Application home page^HomeDesc^"
url="~/Pages/Home.aspx" />

Sample code using localization token RecordChangedByAnotherUser is shown next. Method Replace of class Localizer automatically adds “^” to the localization token name and wraps it around the text fragment. This class is the core class of your application. You may find yourself using Localizer.Replace if you need to write a custom business logic in a multi-lingual web application.

if (result.RowsAffected == 0)
{
    result.RowNotFound = true;
    result.Errors.Add(Localizer.Replace("RecordChangedByAnotherUser", 
"The record has been changed by another user.")); }

You can see that the localization token name is present along with the default text fragment in both use cases. This makes it much easier to understand the intended result. Your web application will remove the localization token at runtime and try to find the resource associated with the token in a file matched to the current web request UI culture. If the localized resource is found then it is used in place of the default value. If the exact match of a specific culture such as “fr-CA” is not found then the localizer will try to see if there is a file that matches a non-specific culture “fr”.

All resource text fragments of the core server and client libraries are written in English. Your can replace them if you change the localization files with the corresponding culture. For example, if your culture is en-US then change the files that end with *.en-US.txt to replace the default English fragments. Do not change the corresponding source code files directly.

If you change the value between localization brackets and save the file then you have effectively changed the localized text representation of the corresponding physical resource of your web application. Simply run your application and observe your changes to resource files in action.

If you application is based on a Visual Studio solution file (if you are developing a Web App Factory, Azure Factory, or SharePoint Factory project) then you will need to compile your application.

Files ClientLibrary.*.txt are not a part of your application. The web application generator will use the contents of these files to customize the JavaScript library of your application. If you change any definitions in ClientLibrary.*.txt file set then make sure to re-generate your project for the changes to take effect. Make sure to hit Refresh button of your browser to ensure that the most current version of localized resources is loaded in the web browser window.

Other localization file sets found in your project must be deployed along with the application.

Localization files found in the class libraries of your project (applies to Web App Factory, Azure Factory, SharePoint Factory) will have the culture component in the file name using “_” instead of “-“.

Here is a brief description of all standard localization files sets.

File Set Folder Description
ClientLibrary.*.txt ~/ JavaScript Client Library resources.
Resources.*.txt ~/ Resources used in the core application classes and business rules of application.
Web.Sitemap.*.txt ~/ Text and description of navigation nodes presented in application menu.
aspnet_Membership.xml.*.txt ~/Controllers Membership manager resources.
aspnet_Roles.xml.*.txt ~/Controllers Role manager resources.
TableOfContents.ascx.*.txt ~/Controls Text fragments used in the standard table of contents that presents the site map as a tree.
Welcome.ascx.*.txt ~/Controls Text fragments used in the welcome message.
Home.aspx.*.txt ~/Pages Resources definitions found in the home page.
Membership.aspx.*.txt ~/Pages Resource definitions found in the membership manager page.
Template.xslt.*.txt ~/Reports Resource definitions used in RDLC report template.

Modified localization files are preserved by web application generator. If a new localization token is introduced in the core library and you have an existing application that does not have such a token then the code generator will insert the token in the file with value equal to the default text fragment from the code generation library.

Multiple Cultures / Languages

Your application may support any number of user interface languages with the same code base. The application framework offers easy-to-use localization of static resources and simple API to render localized messages produced by your custom business rules.  We have shown examples of localized static resources and business rules in the previous topic.

This capability is available in the Unlimited edition of Code On Time.

Automatic Translation

Wrap localization brackets around any text. Web application code generator will perform full translation in all languages supported by your application.

For example, the screen shot below shows the list of fields in Customers data controller. You can see that the field labels in the third column from the right have been changed to include localization brackets. Numerical and named tokens such as ^ContName^ and ^3^ are being used for localization.

image

We have also changed various text properties of Customers page in designer.

image

The following versions of Customers screen are presented if we generate our application and select languages corresponding to fr-CA and zh-TW cultures.

image

image

If you inspect the generated application then you will notice the following new culture sets that were created by Code On Time web application generator.

Localization files for ~/Pages/Customers.aspx

image
Localization files for ~/Controllers/Customers.xml

image

Feel free to open any of these text files to refine the localized text fragments. Generated applications monitor localization files and will start using the fresh content when you save the changes.

Language Detection

Code On Time web applications will automatically detect the supported culture. If the client browser culture is supported by your  app then the appropriate localized resources are utilized to render the pages without any user involvement.

Web browsers send language preferences to web servers with each request. Culture manager of the generated web application will automatically match a supported culture set with the languages accepted by the user’s browser. If a match is found then the culture set is automatically selected.

If the matching culture is not found then the application will use the default culture set of your application that was selected on Globalization and Localization page of project wizard.

Language Selector

Membership bar offers a list of languages supported in your application with native names presented to application users. Language selection is automatically memorized and maintained with a sliding expiration.

Language selector complements automatic language detection.

We Need Your Help

Automatic translation of localized resources is performed via Google Translate. The result of translation may not meet your expectations and we apologize for that.

We need your help with creating high quality localized standard resources. If you do make changes to any of the localized files listed below then please contribute your translations to benefit the developer community. You will find additional instructions in ClientLibrary.*.txt files in the root of your applications.

We are looking for assistance with the following files:

  • ClientLibrary.*.txt
  • Resources.*.txt
  • Web.Sitemap.*.txt
  • aspnet_Membership.xml.*.txt
  • aspnet_Roles.xml.*.txt
  • TableOfContents.ascx.*.txt
  • Welcome.ascx.*.txt
  • Home.aspx.*.txt
  • Membership.aspx.*.txt
  • Template.xslt.*.txt

Your contribution will be included in the general distribution of the code generation library. We will post the names of contributors on our blog with a link to contributor’s website if requested.

Tuesday, March 15, 2011PrintSubscribe
MySQL, IIS Express 7.5, Search Bar Improvements

The latest release of Code On Time generator includes significant new features and bug fixes.

Major Features

  • Code On Time generator now fully supports MySQL. Generate sophisticated web applications with native membership support, amazing end user capabilities such as live Excel data feeds, RSS, and on-the-fly reports.
     
  • In an effort to simplify product installation and to offer up-to-date development experience we have integrated support for IIS Express 7.5 in the web application generator. Code On Time generator will automatically use IIS Express to run and test generated applications. IIS Express can be installed on any Windows computer starting with XP and can run side-by-side with the production version of IIS bundled in many versions of Windows.
     
  • Search bars are now enhanced to support the new Search property of data fields. The search bars will no longer display “Hidden” data fields in the field options. The following values of the Search property allow precise control of the search bar behavior:
    • Default – if the field is no hidden then it is allowed to be displayed in the search bar options. Up to three fields are automatically presented on the search bar by default.
    • Required – the field must be presented on the search bar and cannot be left blank. If at least one field is marked as Required or Suggested then only required and suggested fields are displayed in the search bar.
    • Suggested – the field is automatically presented in the search bar when a search bar is activated.
    • Allowed – the field is allowed to be displayed in the search bar. This value may be useful to expose the “hidden” fields in the search bar.
    • Forbidden – the field is not allowed to be displayed in the search bar even if the field is present in the grid / data sheet / tree view.

Bug Fixes and Minor Improvements

  • The application will correctly hide the tab in a form if there are no visible categories.
     
  • Method SqlText.Execute has been renamed to SqlText.ExecuteScalar
     
  • SqlText class has been enhanced with several static methods that make it easy to execute an SQL statement with parameters. The name of the methods are Execute, ExecuteNonQuery, and ExecuteScalar. For example,
    object[] values = MyCompany.Data.SqlText.Execute(
        "select CompanyName, ContactName from Customers where CustomerID = @CustomerID", 
        "ANTON");
    will return Company Name and Contact Name of a customer with ID = “ANTON”.
     
  • An exception raised when registering an activation code has been fixed.
  • Table of Contents user control now adjusts targets of TreeNode elements if the URL is of a page is spelled as “_blank:….” or starts with any other standard browser window name.
     
  • Business rules now support “array” filters. If you enter a view filter as “CustomerID in @CustomerIDList” and implement property CustomerIDList as an array or any enumerable property then the application will expand the filter into “CustomerID in (@p1, @p2,@p3)” if the property is returning three values.
     
  • Code generator will automatically remove read-only flag if detected when generated the project protected by a source control system.
     
  • Membership Business Rules were refactored. All methods are now virtual and can be overridden when needed.
     
  • The bug with conflict detection when read-only fields are present in a view has been resolved.
     
  • Mandatory boolean fields now automatically display first option “(select)” instead of “N/A”.
     
  • If the property ItemsStyle of a mandatory boolean field is set to “CheckBox” then field will correctly render as a check box.
     
  • The speed of metadata processing when generating a project for the first time or when refreshing the metadata to reflect changes in the database is now significantly improved.
     
  • Export as CSV  will use the List Separator of the client UI culture instead of a fixed “comma” character.
     
  • If a form view has more than one column then the form will automatically take enough of real estate of the screen to fit the contents of the form into available space.
     
  • All boxes displayed in the search bar now feature an additional CSS class signifying the purpose of the box. The classes are Summary, TaskList, About, and See Also. This makes it possible to permanently hide the boxes from the UI when needed.
     
  • An exception is no raised if there is an error in the code formula. Previously the application silently ignored the runtime error making it difficult to detect the problem.
     
  • Summary box automatically trims words that are too long to fit in the side bar. This was frequently happening to email addresses and other “long” text sequences with spaces.

Coming Soon

Many new exciting features are coming soon.

  • Data Sheet view will be available in Premium and Unlimited editions of the product to provide a spreadsheet-style data entry.
     
  • Data Pivot capability will allow creating powerful data entry views with side-by-side presentation of categorized values.
     
  • Dynamic Access Control List will be available soon in Unlimited edition. Enterprise class dynamic security system will be available to control access to data on a user and role level without modifying application code.
     
  • Support for Sybase SQL Anywhere is being prepared for release.
      
  • Date Time Picker will be automatically displayed when data format string of a field is G or g.
     
  • New “Purpose” property will be introduced in the fields to allow specifying the business purpose of the field, such as Modified On, Created By, Membership User Name, Phone Number, etc. The code generator will automatically create the necessary business rules to support the expressed purpose of the field.
     
  • Azure Factory code generation project is being finalized and will be available to create applications working with Microsoft SQL Azure.
     
  • Extended support for file uploading is finally coming to conclusion. It will be possible to capture File Name, File Size, File Content Type, and to redirect file storage / retrieval to an external location. Azure Factory applications will use this capability to store uploaded files and annotations in Azure tables.
     
  • Tree View will complement Grid View, Data Sheet, Form, and Chart.
Tuesday, February 8, 2011PrintSubscribe
Reporting Enhancements, Search By Hidden Fields, etc.

Numerous enhancements to Code On Time web application generator were released with this update.

Reporting

Hidden fields are now available in the search bar. Previously the hidden fields were searchable through “quick find” only.

Dynamic report template has received multiple improvements in ASP.NET 4.0 version of the generated applications.

New option “Word Document” is now available in Report menu on action bar of views. The option will produce a Microsoft Word version of the report. All reports are being rendered by Microsoft Report Viewer component. There is a long standing bug confirmed by Microsoft - the page footer from the first page of the Word document duplicates to the other pages of the report. This makes the new reporting option less exciting.

User defined filters are now displayed on reports. This is a unique feature available only with Code On Time applications.

Aggregate functions defined on data fields of a view are now reproduced on dynamic reports as well.

New view property Report Label allows specifying a title that must print on dynamic reports. Previously the label property of a view was used for the same purpose.

“Report” action command now supports extended arguments. For example, command argument “mytemplate.xslt,grid2” will print a dynamic report with the data supplied by grid2. Command argument “CusotmerList.rdlc",customerGridView” will print a static report based on a custom RDLC template using cusotmerGridView view as a source of data.

Business Rules

Read-only fields are now being transferred along with the writable fields from the client to the server, which allows accessing this data in business rules. Previous implementation was ignoring read-only fields including fields that were not accessible to the user due to role restrictions. This is a big change.

The values are passed as instances of FieldValue class. This class provides new ReadOnly property. If the value of the property is set to True then the field is ignored by the application framework when INSERT, UPDATE, and DELETE statements are being constructed.

The Controller class has been refactored. The entire functionality of the data controller implementation has been moved to DataControllerBase class. The Controller class has been declared as a partial class based on DataControllerBase. This allows creating custom partial implementation of Controller class that may override virtual methods of the base such as CreateConnection. This may be useful if you wish to supply an alternative method to produce a connection string for your application at runtime.

Client Library

Client library now features new shortcut that can be used to locate user interface elements rendered by client library.

The prototype of the function is presented below.

function $dvget(controller, view, fieldName, containerOnly)

The last parameter can be used to find a DOM element that includes the header, value, and error elements of the corresponding data field if the value of the parameter is set to true. Otherwise the function will return the actual physical DOM element that holds the value of the data field.

Framework

New and long awaited field property ItemsDataView now complements ItemsDataController and allows specifying a lookup view other than grid1 in the lookup fields.

New view property Group allows sharing of user-defined filters. For example, declare two views grid1 and grid2 in a data controller. Run the application and apply filters to grid1. Select grid2 in the view selector and observe that filters are absolutely independent. Set property Group on both views to X and observe that filters assigned in one view will be “transferred” to the second view.

New view property Show In Selector allows declaring views that are not selectable in view selector (the box on the right hand side of the action bar). Simply uncheck the check box to hide the view from the selector.

New data view property Show Quick Find allows hiding the “quick find” box from the grid views of a data controller on a page.

New data view property Show Search Bar allows hiding the search bar controls from the grid views of a data controller on a page.

Code Generator

The code generator has been enhanced to display the page with release notes when updates are being installed.

The code generator will hint if Microsoft SQL Express is not available on the computer when ASP.NET Membership option is enabled in the project.

The code generator will detect the physical location of Visual Studio / Visual Web Developer if the IDE is installed into a custom location.

Future Enhancements

We are getting ready to release support for My SQL and Sybase as data sources of Code On Time projects.

Enhanced image/file processing with automatic support for content type, content length, file name, and custom location for uploaded content is coming soon.

New “basket” lookup style is being worked on as well. This will be a combination of “check box list” and “lookup” functionality.

The date time picker will be introduced to allow selecting time component of dates in AJAX fashion.

Tree view will offer a great mechanism of working with hierarchies.

Azure Factory project will allow deployment of the generated apps to the cloud.