Sunday, March 29, 2009

Java Issues and Solutions - 4

Scenario 1: One large object (the object is to display dynamic fields on the page with different is dynamic in nature without having one unique field for field Ex: Company.Accounts[*].AccountNumber) should be displayed on the page,after selecting one radio button the object should be modified using service call and the updated value should be dispayed on the page without refreshing the complete page.

Possible Solution:Using AJAX: On change of the radio button javascript should be called, from the java script make ajax call to process to call a servlet. The servlet makes a business service call updated the object.But using AJAX only littl information can be returned to the javascript, the complete object can not be returned.

Alternative; Use JSON to modify the object with service call and return the updated object

On change of radio button call javascript which makes an JSON call. It hits the servlet, the servlet makes a business call and updates the object. the object is returned back to the javascript using JSON notation.But the updated object can not be displayed in the page without reloading the page. Since the object is dynamic the values can not set using Javascript.

Possible way is after making AJAX call and updating the object, only the part of the page where the object should be displayed needs to reloaded without realoding the complete page.

Scenario 2:

Problem: unlocking the DB when the user closed the browser using the broswers closing button (that is not logging off) (locking and unlocking the DB in the sense a flag is set to Y or N in the DB so that other user can not access that application)
Scenario: The application consists of multiple pages....on load of the first page the DB will be locked as per the requirements, this should be unlocked when the user clicks logoff. but what is the situation when the user closes the browser without logoff. (there should not be any time out option as the user can keep the page open for a long time) Solution; there is a javascriot event "onunload()" which is executed on close of the page, but the problem this will be fired even on click of the other page link or button to navigate to other page. Then how to handle ?on click of each other page link or button an action (application) willl be executed. to catch the event of broswer close the action wil be checked in unonload() javascript funtion.

If the action is something related to application navigation then dont make any call to unlock the DB, if the action is null then that means the broswer is closed in different ways (like clicking brosswer close button. closing it using task manager,right click and close when minimized etc., ). so when the action is null in the onunload() javascript make a call (may be AJAX call or submitdynamic action etc..depending on the applciation type) to unlock the DB.

No comments:

Post a Comment