Ext.Ajax on steroids [AuthorizedAjax]

In the company I work for we use ExtTop, the Windows-like desktop environment which provides icons, taskbar and start menu. It is a single page web application. You can open all the windows you want, but you will never reload the page.

We want to log users off after one hour of inactivity. If your user session is destroyed and you try to open a form, you should be warned that you cannot continue and you will be invited to log in again.

That’s very simple. For each Ext.Ajax request, you should check that you are still in, if not, open a login form and if the server accepts your credentials, continue. For each request. For each request. For each request. [...]

That repetition sucks. What could we do?

  • copy and paste all the code, in every Ext.Ajax.request()
  • create a detectIfLoggedOf() function and call it in every success() callback of Ext.Ajax.request()
  • define a new Ext.Ajax that do everything.

Since you should spend your time writing a strong web application, let’s discard option 1 and 2. AuthorizedAjax is option 3.

Please keep in mind this is more a proof of concept rather than a real implementation. There is no documentation (yet?). See the example and read it’s configuration file.

How it works
Your server must send special headers if something unusual happens (for example, the user is not logged in or the ACL system denied the access). Then you tell AuthorizedAjax how the server can answer, and what to do in that cases.

If the server will not send any special header, AuthorizedAjax will behave as Ext.Ajax – otherwise, something (configurable) will be executed.

Conclusion
I repeat, this is just a proof of concept of a domain specific language. “Dear system, this case may happen, and in that case you will do this” (action-reaction). A DSL applied to something more complex is powerful – it allows everyone to configure a system, just knowing how the system works and nothing about programming.

This entry was posted in Domain specific languages, ExtJS extensions. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>