Sample code to build a translation tool for Adam

A new sample code project has been released: TranslateTool.

This application allows translators to quickly edit translations in Adam. Users with the permission to create translations can add new ones as well.

Some usability features have been implemented in this sample project:

  • Keyboard shortcuts to allow users to navigate easily through translations without having to switch between mouse and keyboard.
     
  • In-line editing by clicking on a translation item which is automatically saved when enter is pressed or when the input box looses focus (using AJAX calls).
     
  • Filter on columns to narrow down the result set.

About the code

Retrieving data

The main setup for the application is straight forward: just a standard ASP.NET grid view which connects to an AdamDataSource control to get its data, In this case Adam Translation objects are shown..

Adam version 4.4 does not yet contain a DataProvider for Translation objects (it was scheduled for a later release). This isn't a problem, because the AdamDataSource framework is extensible. AdamDataSource controls use a DataProvider that handle data access on their behalf and of course, you can create your own DataProvider.

In the sample code, you'll find the class TranslationDataProvider, which implements the requirements for a DataProvider. Take a look at that class when you create your first custom DataProvider, it is a good starting point..

Filtering

Because the standard ASP.NET grid view control does not support filtering on columns, a custom implementation of filtering is provided in the sample project.

To achieve this goal, we created a TranslationField control, which inherits from DataControlField. This control adds a filter textbox to the column header and maintains its state.

Any values typed in the filter box is picked up and used when the AdamDataSource is retrieves its data (see the BuildingSelectExpression event handler in Default.aspx).

Updating data

The sample project automatically saves changes made to Translation objects, which is done using an AJAX call to the server.

To achieve this, the TranslationField control renders for every translation a TranslationCell control. This class is a nested class of the TranslationField  control and it implements the ICallbackEventHandler interface..In the accompanying JavaScript (TranslationField.js), the AJAX call back to the server is launched when a change to a translation is detected. When the server receives this AJAX call, the TranslationField load, update and save the Translation by using the Adam engine API. So, no rocket science there :-).

Last thoughts

We hope this sample code gives you more insight on how to use the Adam DataSource framework.

The main issues we encountered when developing this the sample project were linked to the special needs for this application which are not provided by ASP.NET (automatic update of changes, filtering, dialog box...). The code would have been a lot simpler with a more advanced or commercial control set bought from a 3rd party vendor (like Telerik, DevXPress, ComponentArt, Infragistics, ...), but this project shows how you can accomplish similar features with standard ASP.NET controls.

Note: When downloading the sample code, make sure you've updated the registration name in the web.config before you run it.

Sample Code

The article contains sample code project(s).
You must be logged in to view or download sample code.
Sign in now

Comments

Friday, 06 November 2009Ingo Wolff says
I think this might be interesting, however though changing the defaultRegistration name in Web.config, I am still not able to log in. What else is there to do?
Leave a comment
You must be logged in to post comments.
Sign in now
 
 
Technical
Business
rss feed