permaculture playing cards*
The moose likes HTML, CSS and JavaScript and the fly likes Architecture Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Architecture" Watch "Architecture" New topic
Author

Architecture

Stijn Janssens
Greenhorn

Joined: Sep 09, 2008
Posts: 12
I am a back-end developer, been using JEE (web services, ESBs, JEE, ...) for ages but just started playing around with HTML 5, CSS 3 and Javascript....
Could someone give me some inside into best practices for architecting html5-javascript web apps.... What's the best high-level architecture?
Say you want to implement a blog but you don't want to go the Wordpress route... You create a DB and offer some Rest services and then you write your index.html file with the general content (header, body, footer, ...). Now, how do you retrieve the blog articles? Do you use javascript web sockets when the page loads and update the DOM accordingly, adding the HTML code through Javascript at runtime? Or do you use AJAX for that? Or is there some other data binding technique?


<a href="http://zerotreize.com/#/blog/java-certification-matters" target="_blank" rel="nofollow">Java Certification matters?</a><br /><a href="http://www.zerotreize.com" target="_blank" rel="nofollow">Zerotreize.com</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Nothing precludes good old JSP for server-side templating. Why do a lot of work on the client if you don't have to?

The only time I use client-side templating is when I cannot use server-side templating because I'm directly accessing a RESTful API that serves JSON. Even then it's sometimes expedient to digest the web service on the server.

I guess it depends on a lot of factors that aren't apparent in your post.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Or, are you actually trying to figure out how to write exclusively client-side apps give a remote RESTful API?
Stijn Janssens
Greenhorn

Joined: Sep 09, 2008
Posts: 12
Bear Bibeault wrote:Or, are you actually trying to figure out how to write exclusively client-side apps give a remote RESTful API?


Exactly, I am just trying to understand what the best practices are for structuring client-side apps that have dynamic content based on data retrieved from RESTful APIs...
I am aware of alternative approaches (like JSP, PHP, rails, ...) but I'm just interested in a HTML5-Javascript only approach so I was wondering if you should use web sockets for this or AJAX or ???


Thanks!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

There's one app I am working on where an embedded server is too wimpy to be able to run server-side templating. So I'm getting data from that server's RESTful API via Ajax, and using jQuery and its .tmpl() plugin to do client-side templating.

Given a choice, I prefer to do as much work on the server as possible -- but where that's not possible, client-side templating can do the trick.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Architecture
 
Similar Threads
Creating a Persistence Unit in web-app
Webservices and Request/Response
Query on SOA
Will Oracle 10g App Server serve me in learning for SCJWS exam?
Learning Path