aspose file tools*
The moose likes Servlets and the fly likes JSP INSTANT UPDATION Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP INSTANT UPDATION" Watch "JSP INSTANT UPDATION" New topic
Author

JSP INSTANT UPDATION

ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
My web page is divided into four frames 'Top' , 'MiddleLeft', "MiddleRight' and 'Bottom'.
The 'Bottom' is displaying certain values from database.
Now , I am entering certain value in MiddleRight frame and on hitting the button there , I want the bottom
frame to be instantly updated with these values.
Now this is the solution what I have arrived at, On click of the button , I am calling a JavaScript
function, which first invokes a ReleasePlayer.jsp which saves the values in the database and then after that
it tries to invoke SpecificPlayerRecord in 'Bottom' which is as good as trying to reload the 'Bottom' frame after
the former action.
Here is my code

function release()
{
parent.MiddleRight.location.href="ReleasePlayer.jsp?tf="+document.myForm.tf.value+"&textarea="+document.myForm.textarea.value+"&tf1="+document.myForm.tf1.value;

parent.Bottom.location.href="SpecificPlayerRecord.jsp?tf="+document.myForm.tf.value;

}

I could achieve the desired result to a certain degree , like what is happening is it doesn't update the value on the
first press of the button but it does so on subseqeunt press of buttons or sometime it gets instantly updated and sometime it doesn't.
I guess this is happening because sometime the ReleasePlayer.jsp gets executed before SpecificPlayerRecord.jsp or vice versa.
Can someone suggest a suitable solution
Thanks in advance
Ravi

SCJP, SCJD, SCWCD, SCBCD, SCEA
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The only clean solution I can think of that doesn't change your architecture is to move the SpecificPlayerRecord request to the body onLoad of ReleasePlayer.jsp. Your page would look like:
function release()
{
parent.MiddleRight.location.href="ReleasePlayer.jsp?tf="+document.myForm.tf.value+"&textarea="+document.myForm.textarea.value+"&tf1="+document.myForm.tf1.value;
}
function updatebottom() {
parent.Bottom.location.href="SpecificPlayerRecord.jsp?tf="+document.myForm.tf.value;
}
<body onLoad="updatebottom()">
...
The net result is that the request to SpecificPlayerRecord is sent only after the new ReleasePlayer has been submitted.
Perhaps I should add that, in theory, you can implement server-side code to fix things without rearranging requests. You could use a session-scoped JavaBean with a flag. ReleasePlayer would set that flag after doing the update. SpecificPlayerRecord would wait for that flag to be set. Problem solved, but, in the meantime you've impaired the scalability of your application. Probably not a good idea.
Is this really necessary? Are you displaying new information into the MiddleRight area as well? If not, then what is the reason for submitting a request to ReleasePlayer? If you're doing this because you want to keep the update code out of SpecificPlayerRecord, then my response would be that you chose the wrong solution for the right problem. The right solution would be to move to an MVC architecture; the Controller would do the update, then forward the request to the SpecificPlayerRecord view.
- Peter
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Thanks Peter
Your first solution has worked.
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi Peter,
Thinking in terms of the MVC architecture,
Say I would like to invoke a Servlet on click of a button in MiddleRight frame
which does updation in the database. I want the control to return to ModifyPlayer.jsp in MiddleRight frame
which contain the below mentioned block of code ( inside JavaScript ) after updation.
.
Also, SpecificPlayerRecord is already displaying data from some tables in Bottom frame.
What I would like to have is the result of execution of EnforcePlayerServlet to be automatically
reflected in the Bottom frame
url="http://majdemo.dmz.ea.com/servlet/EnforcePlayerServlet??tf="+document.myForm.tf.value+"&textarea="+document.myForm.textarea.value+"&tf1="+document.myForm.tf1.value+"&radio_cho ice="+radio_choice;
parent.MiddleRight.location.href= url;
parent.Bottom.location.href="SpecificPlayerRecord.jsp?tf="+document.myForm.tf.value;
Any suggestions,
Thanks
Ravi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP INSTANT UPDATION