I want to create web application using Grails.
The main layout consists of few parts, like top, left, content, etc. and I want each part to be partially refreshable. I'm planning to use jQuery to perform ajax request and refresh.
Let's focus on the content layout. I have two options in mind for rendering the view:
Which one of the two options is better?
I mostly consider the following parameters: easy to develop, performance, mantainability, etc. But if you think there are other importants parameters to consider, pls let me know. I'm not an experience web developer.
Or perhaps you know other better options?
Thanks :)
First of all, there might be situations, where you are forced to use a combination of both (for the same structures). Obviously this leaks of maintainability and should be avoided.
From a maintainability, flexibility or speed of development of view, you should consider the first option. This is what grails is done for. There are great advantages for this: You can render your template into the GSP, when the GSP is called first time. When an AJAX action is called you just re-render only this template. It's short, simple and works. The most grails tags can handle those actions. Additionally it is easily testable.
However you lose little reusability with this approach, when you want to update your content based on other events (like WebSockets/comet) and you do not want/cannot to call the server again. In these case you should implement the template logic using jQuery-Template and filling it with JSON data received from your server-push message.
Performance: There are also use-cases, in which you should consider the second option as well: If you have a chat, you only want to display the new messages incrementally (or you need to reduce the used bandwith of server) and don't want to send the complete chat-progress to the user just because there is one small new message. Here you cannot use templates without some hacks or limitations. Additionally if you want to provide realtime feeling to the user, you cannot let him wait for the answer of the server and you need to update the view directly using JQuery, where you cannot reuse your template. Therefore you should have your template data in one place and use jQuery-Template or similar exclusively - at least from my point of view.