force to refresh browser

J

Jay

I'm trying to refresh browser when some new information is available in DB.
is there any way to force to refresh browser?
Thanks.

-Kev
 
J

Jay

Thanks!

well, window.location.reload(true) does whenever control is hit that line,
it does refresh.
What I want to do is server side trigger send message to client browser to
refresh it.

-Kev
 
K

kaeli

[email protected] enlightened us said:
Thanks!

well, window.location.reload(true) does whenever control is hit that line,
it does refresh.
What I want to do is server side trigger send message to client browser to
refresh it.

Technically, you can't in a normal cross-browser internet environment
(that is, activeX, applets, and COM notwithstanding).

If the page should be refreshed every so often, put it in a setTimeout.
This is common.

If the user updates the DB via a popup with the main window on a
particular page you want to refresh, write a script as output to the
popup that calls window.opener.location.reload(true).

Other situation, please elaborate. We can probably find something that
works for you.
 
J

Jay

Thank you for your help.
I'm displaying hotel information from DB.

What I want to is
First, I will get the hotel list and display with no rate. ( since getting
rate takes time)
Whenever rate information is ready to update. refresh user's browser.

but how?

Thanks.
-Kev
 
K

kaeli

[email protected] enlightened us said:
Thank you for your help.
I'm displaying hotel information from DB.

What I want to is
First, I will get the hotel list and display with no rate. ( since getting
rate takes time)
Whenever rate information is ready to update. refresh user's browser.

but how?

If you are getting the hotel list from the DB, getting the rate should
take an inconsequential amount of time, especially if the DB is set up
properly and a concise SQL statement is used. Views can be helpful for
this if the rate is a calculated field or is keyed by a number rather
than a hotel name.
Rates do not change often enough to need to refresh the user's browser
more than with a setTimeout for some amount of time.
Perhaps what you really need is help with your SQL query.

If you're not getting the hotel list from the DB, why not? That is much
easier than manually changing pages. :)
The DB must have the hotels in there or it would be impossible to look
up rates.

How I would do this: query the DB for the list of hotels and rates and
write the whole thing dynamically at once. I do much more complicated
things with billing data for one of my pages and it takes less than 10
seconds to run and load.

--
~kaeli~
Not one shred of evidence supports the notion that life is
serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
J

Jay

Thanks.

I did not explained in detail so I can avoid some confusions.
But I guess it did more harm than good.

Hotel list are coming from our DB and rate are coming from GDS in XML.
I have a java object created with list first and displays and trying to
update as soon as I got XML response.

XML response is quite slow. ( you know there is nothing I can do).
I can wait XML and display all together. but I'm just seeking a way to
display list of hotel first with some animation indicating
rate is being updated and display rate when it's available.

is that make sense now?

-Kev
 
K

kaeli

[email protected] enlightened said:
I did not explained in detail so I can avoid some confusions.
But I guess it did more harm than good.

Hotel list are coming from our DB and rate are coming from GDS in XML.
I have a java object created with list first and displays and trying to
update as soon as I got XML response.

XML response is quite slow. ( you know there is nothing I can do).
I can wait XML and display all together. but I'm just seeking a way to
display list of hotel first with some animation indicating
rate is being updated and display rate when it's available.

is that make sense now?

Yes, much.

Okay, there really isn't a good way that I know of (cross-browser) to do
this. If you're using IE only (intranet application) let me know,
because you have more options. Generally speaking, once the page is
written, the server knows nothing else about it. It can't refresh the
browser, because the connection is over. COM and ActiveX are exceptions,
but are IE only (AFAIK).

Anyway, the way I would handle this is with an "invisible" iframe
(styled to hidden or 1px by 1px the same background color as the main
page). I would have the iframe wait for the XML, then when it is
received, update the encompassing page. This doesn't require a refresh,
just DHTML.
That still requires NN6+/IE5+ and other browsers that support
iframes/DHTML, but it's better than IE only. Last I checked at my site,
95% of my viewers had browsers that were IE5+ or compatible (opera can
spoof this so be careful).

Do your target users have updated browsers? Do they have permissions to
update their browsers if they need to (i.e. people at schools and
libraries do not.)?

I'm sure there are other ways to handle this, such as applets, COM,
ActiveX, etc, but all require knowing quite a bit about your users'
browsers. For example, using an applet is a bad idea if your users
access the site from public facilities, since they don't have permission
to install an updated JVM should they need to.
 
J

Jay

do you have any iframe sample I can look?
or please direct me to web site I can get some info from.
Thanks again.

-Kev
 
K

kaeli

[email protected] enlightened said:
do you have any iframe sample I can look?
or please direct me to web site I can get some info from.
Thanks again.

Tested in NN7.1 and IE6.0 successfully.

test1.htm
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>This is a test page with an iframe that fills in the form below.</p>
<form name="form1" method="post" action="">
<p>item 1:&nbsp;&nbsp;
<input name="item1" type="text" id="item1">
</p>
<p>item 2:&nbsp;&nbsp;
<input name="item2" type="text" id="item2">
</p>
<p>item 3:&nbsp;&nbsp;
<input name="item3" type="text" id="item3">
</p>
</form>
<iframe height="1px" width="1px" src="test2.htm" style="top:-
50;position:absolute;"></iframe>
</body>
</html>


test2.htm
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
This is the contents of the iframe for test1.html
<script type="text/javascript">
top.document.form1.item1.value="hi there";
top.document.form1.item2.value="this is from an iframe";
top.document.form1.item3.value="boo!";

</script>
</body>
</html>
 
J

Jay

Thanks, Kaeli,

I see how iframe works.
However, I do not understand how ifram helps my situation.

Do I constantly refresh test1.htm?

-kev
 
J

Jay

Anyway, the way I would handle this is with an "invisible" iframe
(styled to hidden or 1px by 1px the same background color as the main
page). I would have the iframe wait for the XML, then when it is
received, update the encompassing page. This doesn't require a refresh,
just DHTML.


"update the encompassing page" I don't know how to do that..

Thanks.
 
K

kaeli

[email protected] enlightened said:
Anyway, the way I would handle this is with an "invisible" iframe
(styled to hidden or 1px by 1px the same background color as the main
page). I would have the iframe wait for the XML, then when it is
received, update the encompassing page. This doesn't require a refresh,
just DHTML.


"update the encompassing page" I don't know how to do that..

The pages I gave you show that. test2 updates test1. I used a form for
ease and quickness, but you could do any block-level element.

What you do is have the query / xml run in what was my test2.htm. When
it loads, the xml is done. When it loads, have the script write to what
was my test1.htm.


--
~kaeli~
The man who fell into an upholstery machine is fully
recovered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
J

Jay

then Until test2 is fully updated user is not seeing test1?

Well, my task is while user watching test1.
updates test2 and when update test2 is done refresh test1.
so user can see updated info.

is user has to wait test2 is updated and while doing updating, user don't
see any info.
It is kinda same as before.
 
J

Jay

I tried with test1 and test2.
What I did was while I'm watching test1.htm.

modify values in test2 and save.
test1.htm.values in text box is not changed.
Unless I refresh test.htm.

Could I force to refresh test1.htm from test2?
Thanks alot.
 
K

kaeli

[email protected] enlightened said:
I tried with test1 and test2.
What I did was while I'm watching test1.htm.

modify values in test2 and save.
test1.htm.values in text box is not changed.
Unless I refresh test.htm.

Could I force to refresh test1.htm from test2?

Yes, but you're doing someting wrong if the write didn't show in test1.
Test2 is dynamic in practice - the values are assumed to be gotten from
XML or some other server-side language. The hardcoded values are for
testing only, to show you it could be done. You'd need to refresh only
if you changed hardcoded values (hardcoded values would defeat the
entire purpose of this exercise). When you make it dynamic, you don't
have to refresh.

I don't use xml or I'd give you an example.
I can give you an example with ASP or JSP...?
 
J

Jay

JSP would be great.
Thanks.


kaeli said:
Yes, but you're doing someting wrong if the write didn't show in test1.
Test2 is dynamic in practice - the values are assumed to be gotten from
XML or some other server-side language. The hardcoded values are for
testing only, to show you it could be done. You'd need to refresh only
if you changed hardcoded values (hardcoded values would defeat the
entire purpose of this exercise). When you make it dynamic, you don't
have to refresh.

I don't use xml or I'd give you an example.
I can give you an example with ASP or JSP...?

--
~kaeli~
You feel stuck with your debt if you can't budge it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
 
K

kaeli

[email protected] enlightened said:
JSP would be great.
Thanks.

Okay, this is tested successfully in NN6+ only.


test1.jsp has a table with just a header.
test2.jsp queries a DB, then writes the results to the table in
test1.jsp.

When the user brings up test1, they see only the table headers until the
query from test2 is completed. When the query is done, the page loads
and fills in test1's table.

test1.jsp
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>This is a test page with an iframe that fills in the table below.</p>
<table width="75%" border="1" cellspacing="1" cellpadding="5">
<tbody id="cTbl">
<tr>
<td width="10%" nowrap>Customer Id</td>
<td width="90%" nowrap>Customer Name</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<iframe height="1px" width="1px" src="test2.jsp" style="top:-
50;position:absolute;"></iframe>
</body>
</html>


test2.jsp
<%@ page import="OPS.*" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
This is the contents of the iframe for test1.jsp
<%
String q;
String userName="";
String psswd="";
ResultSet rs;
int x = 0; // keep row count
// connect to the database
OPS_dbInteract opsConn = new OPS_dbInteract();
opsConn.connect();
q = "select unique customerName, UPPER(customerName) as CN, customerId
" +
"from customerTbl where customerName like 'A%' "+
"order by CN";
rs = opsConn.queryDB(q);
// for each customer, fill table in test1.jsp
while (rs != null && rs.next())
{
x++; //row count
%>
<script type="text/javascript">
TR = document.createElement("TR");
TD = document.createElement("TD");
txt = document.createTextNode("<%= rs.getLong("customerId") %>");
TD.appendChild(txt);
TR.appendChild(TD);
TD = document.createElement("TD");
txt = document.createTextNode("<%= rs.getString("customerName")
%>");
TD.appendChild(txt);
TR.appendChild(TD);
top.document.getElementById("cTbl").appendChild(TR);
</script>
<%
}
opsConn.close();
%>

</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top