Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

postback model and AJAX  RSS feed

Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My web page is divided into Tabs,Header,Body and Footer.

Tabs : Tabs and their sub tabs . for each tab there is different header and body but for all the subtabs that belong to one tab share same header but body is different.
Header : Header contains couple of drop down boxes. They are being populated from database. One is main combo box and other are filter combo boxes. They filter out records of the main combo box. So this is also DB trip.
Body : No. of elements being populated from database.
Footer : Not much of importance for the question.

Now the flow is,
- I click on one of the Tabs. It loads the header and body for that tab. Now I can move to different sub tabs with different body but same header.

1) Postback Model : If I go with this, the whole page will get refreshed as it is postback model but ideally only the body contents should be changed and whenever I change the combo boxes to filter out the records of main combo box, header would be refreshed but this is not as frequent as move-from-one-tab-to-another. Because of this I thought of using AJAX.

2) AJAX : In this I come out from the issues of postback model and only the body part is getting refreshed. But the way it's been implemented is highly doubtful. We used vanilla AJAX and not any frameworks like scriptaculous,DWR etc. The way programmers are saving the code is, On click of save button, call a JS function that makes the AJAX call. To save, need to get the values of different elements, for that they are doing getElementById. And we have 100s elements in the body so the code gets clumsy,messy. Now If you compare it with postback model, the elements are bound to model/POJO, and we use hibernate, so everything gets saved in one shot.

So both the models have their pros and cons.
I tried my best to be clear and to the point with my question.
I think this is very common scenario. How do you handle this? Am I thinking correct or completely off the road?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!