开发者

Pros and cons of writing complete view logic of a web application in a javascript library (ExtJS)?

I am a newbie in web development using javascript libraries. But I recently saw a J2EE web application that uses ExtJS extensively (say 90%) for rendering the web pages. The web pages in question are either simple forms or grids (tabular reports). The JSPs are fairly threadbare and simply de开发者_高级运维legate to the ExtJS framework (using onReady function) which then makes AJAX calls to the server and renders the pages. There is a separate .js file for each web page that encapsulates all rendering logic within ExtJS functions.

This is the first time I am seeing an application coded this way. I would like to know if this is a common approach to use these days or is this an extreme use of a javascript library. What are some pros and cons of this design ?


Pro:

The system looks and behaves much better than with regular plain HTML

Con:

The system is hard to debug and modify if is not coded by developers with good experience on the framework.

You can mitigate that cons by using a server side library such as GWT that even can be used with Ext: GWT-Ext


Cons:

  • Pages won't work at all if the user has JavaScript disabled.
  • The user has to wait for the script to be downloaded, parsed, and executed before any content appears. Depending on the design, the user may also have to wait on some AJAX requests after that.
  • Accessiblity is harder to implement.


My company develops RIAs like you describe as its main focus. These applications (some are in Flex, some in ExtJS) are designed to be highly functional applications for a relatively small set of people.

For ExtJS applications, our main approach is to have static HTML and JavaScript files that then build the UI on the client side (for users, they generally experience sub-second load times as everything is cached and JavaScript runtimes in newer browsers are amazingly fast). Whether it is an all-in-one 'HTML' page, or spread across multiple HTML pages depends on the app (or segment of an app).

All data is then served via AJAX requests through web services (mostly ESTful APIs). The ExtJS grid for example can be served with data with such a trivial server side component it's almost embarrassing.

All complex server side components that we write end up being complex business logic that is not suitable for the client side (or is a duplication of client side functionality for security or checking purposes).

All-in-all I am a big fan of this approach, for the right situation. I would not suggest it for public web sites - but it has a really nice niche in the business application space for example.


One advantage of a Rich Internet Application is that you free up your server(s) from the rendering responsibility, and delegate this to the clients (the browsers).

In a 3-tier architecture, you would literally take the whole presentation layer away from your hardware. You would just need to serve the static files (XHTML, CSS, JavaScript and images).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜