Click here to Skip to main content
6,593,923 members and growing! (12,880 online)
Email Password   helpLost your password?
Web Development » Applications & Tools » Tools with source code     Intermediate License: The Code Project Open License (CPOL)

Web-Application Framework - Catharsis - Part II

By Radim Köhler

Catharsis web-app framework
C#, Windows, ASP.NET, Architect, Dev, Design
Posted:15 Sep 2008
Updated:9 Dec 2008
Views:15,033
Bookmarked:25 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
7 votes for this article.
Popularity: 3.84 Rating: 4.54 out of 5
1 vote, 14.3%
1

2

3
1 vote, 14.3%
4
5 votes, 71.4%
5

Introduction

This article is the second step in a Catharsis documented tutorial.  Catharsis is web-application framework gathering best-practices, using ASP.NET MVC (preview 5), NHibernate 2.0. All needed source code you can find here.

Catharsis-title.png

No. Chapter No. Chapter No. Chapter
New solution  VI  CatharsisArchitecture XI  (Controller layer - undone)  
II  Home page observation VII  Entity layer  XII  (UI Web layer - undone) 
III  Roles and users VIII  Data layer XIII  Tracking, PAX design pattern
IV  Localization, translations IX  Business layer XIV  Catharsis Dependency Injection (DI, IoC) 
Enter into Catharsis, new Entity (Model layer - undone)   XV  (Code Lists - undone)    

Breaking Release 0.9.5 available

Catharsis release 0.9.5 is available at: http://www.codeplex.com/Catharsis. You should download and install it immediately. The features of framework was radically extended - built in Excel export, Uploading and downloading of any type files, Paging on the Detail level...

Also the UI layout (including Home Page) was improved and provides more stuff and looks smarter. This article should quickly take you through the Catharsis base pages areas.

Catharsis.png 

Home Page Observation  

Catharsis - as framework - provides ‘kick-off’ page layout, which is (thanks to ASP.NET world) based on MasterPage. At this point it is very important to say:

I do know – I am not good designer! (but I'd like to be...) ! And therefore I do provide all source-code, and expect from you to adjust it. To make these improvements as simple as possible, every logical area is placed in separate WebControl, and depends on CSS settings. Just play with …

Home page quick summary 

Home page layout could be separated into few independent areas. For our purposes they could be named: 

  1. Current action information
  2. Actions
  3. User information
  4. Localization switch
  5. Navigation
  6. Main Content
  7. Paging on list level (pages) & on detail level (entity)

HomePage.png

As said above, all these areas are based on web-controls, which are placed on a MasterPage. They are smart ones, they are Presenters. They are provided with information stored in Model (MVC pattern) and will always display what you have decided to show (What you have just stored for user in the Model)

Do not hesitate and move controls, rebuild master page, change CSS, but for tutorial purposes I will expect the built-in design. Be sure that whenever you'll place these Presenters, they will display information stored in the Model, and that is what we want.

Current Action Information 

When navigating application, users are calling controllers and their actions (by clicking buttons, anchors) Current controller and action are always displayed at this area. Both terms are localized, which allows you to be more user-friendly. Controller name is send to GetLocalized() method, which is available on every control, and if the translation is found, it is also displayed. Home is at this example converted to Home page.

GetLocalized() is one of the essences of Catharsis. Any string, which should be localized, should be called through that method. Translations then can be done on the run, on the Translations controller.

GetLoclized() is now also available on ever string! It means that you can type "yourString".GetLoclized() and the framework does the rest

Actions

MVC provides separation of concern on two levels. Firstly there are controllers, which could be seen as the ‘area-responsible’ handlers. There could be controller for languages, translations, suppliers, contracts, persons …

The second level is represented by actions, which are request-response based (adding, changing, deleting, finding, listing …).

HomePage2.png 

Actions 

Some actions should be displayed to user as the list of possible ‘navigation links’. On entity controllers there are common actions of that type: Search, List and New.

But which actions will be available for user are dependent only on you – developer. The ‘action web-control’ just takes the list of ActionLinks nested in the Model and displays them.

Buttons  

(They are placed bellow Main content area.) 

On a home page are missing the buttons actions. They are usually visible when editing and their typical background is Save, Update, Cancel … Some are provided by Catharsis as default (you'll see). Any other you can add (To Buttons list in the Model).

User Information 

User information contains User name (as saved in the storage), currently selected role and selected display language.

User names are maintained in the runtime by Catharsis UI. You can add and remove them, and also append roles, which user can use.

Current Role 

In comparison with ASP.NET Roles there is a big difference in Catharsis. User can have many roles (at least one). But access is evaluated only against CurrentRole. User can select, which role is CurrentRole from his role-set, for example by clicking on a link in ‘User information area’. Catharsis than checks the access rights comparing list of allowed roles (or disabled) for current action and Users.CurrentRole.

This reduces mishmash (user can see only what ‘The role’ should see). If you design your application to have let say two roles ‘Translator’ and ‘RegisteredUser’ you can give them different access. User, who is in both roles, then can see only translation if in Translator role, and is not disturbed with other possible navigation and actions. You (and your users) will like it ...

Localization 

No more .resx files, which are horrible to edit and distribute to translator. Catharsis provides localization based on objects (translations) stored in Database. The great advantage is that you can localize in a runtime. What it exactly means?
Adding new languages

 Yes, you can add new languages in runtime for your localization purposes. Just add the language using Catharsis UI and provide its LocalName (Ceština for Czech …). From that moment, user can switch into that new language and translations gains new input box for it.

You probably expect that user can also switch language by setting keyboard in a browser; that more specific language ‘en-GB’ can use ‘en’ phrase when ‘en-GB’ is not provided; that if phrase is not found the default translation is used; that if nothing is find at all, that at least the searched keyword is returned.

Well, that’s exactly how Catharsis behaves.

Try to add language, try to add or change a phrase, you will see … GetLocalized() can be used for everything, including the error messages translation

Localization is more then translation - adjusting

In Europe (where I am from) we much often meet requirements for translation (multilingual UI). Catharsis localization is not only about translation. Even if you are using let's say. English, it can help you a lot with adjusting texts and messages on UI. 

For example 'Business rules', which are not met, must be explained to user. Messages like 'Cannot delete' are not clear enough. Catharsis allows you to call for a 'localized' or 'adjusted' error string in the way: “CannotDelete {0} {1} {2}”. You (or smart users) then can provide a message like ”Item '{0}' cannot be deleted. It still used ({1} times) in the {2} entity”

Navigation  

Work-Flow can be seen from two sights. There is inner movement on a controller (list, search, detail, update …) and outer one represented by navigating among controllers. User can add subject, than basic contract, then detail contract … or user can be filling some questionnaire step by step in a ‘wizard-mode’. All of that could be done by Navigation links.

Catharsis has Presenter which takes NavigationLinks from the Model and display them. It’s upon you to fill in correct links to the Model…

Main Content  

Nothing special. The main area of your just growing application...

Detail View

Detail was extended with paging buttons (and Access keys) which allows you to directly move to next entity. Do you like shortcuts?

Shift + Alt + F => goes to Search (the focus is on the first input button, you can type)

Shift + Alt + S => Search the results -> on the List you select any entity

Shift + Alt + E => on List will start the export to Excel! Direct for all filtered entities!

On Entity detail View:

Shift + Alt + E => Start to edit

Shift + Alt + S == save

Shift + Alt + W (Go to next)

Shift + Alt + E => start to edit

...

Shift + Alt + 1 => Select Tab with Navigation TreeView

Shift + Alt + 2 => Second tab with actions
 

Entity2.png

List View

You can sort any Entity using the shared control ListWC. You can even sort by Subject.Address.City.NativeName if you want. using Shift + Alt + E you will ran the Export to Excel action (if you have MS office installed, Excel will be opened)Sorting.png

 And many many more

Enjoy Catharsis!  

Radim Köhler

Source code

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Radim Köhler


Member
Web developer since 2002, .NET since 2005

Competition is as important as Cooperation.

___
Occupation: Web Developer
Location: Czech Republic Czech Republic

Other popular Applications & Tools articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralBest Localization Plug-in for Visual Studio. PinmemberAlexander Nesterenko22:46 17 Dec '08  
Generallinks to other articles in the series PinmemberCIDev12:07 1 Oct '08  
GeneralRe: links to other articles in the series PinmemberRadim Köhler7:24 2 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 9 Dec 2008
Editor: Deeksha Shenoy
Copyright 2008 by Radim Köhler
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project