aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Checking for load finished Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Checking for load finished" Watch "Checking for load finished" New topic
Author

Checking for load finished

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
I am using the following to load some default attributes and clear frame contents before a logon json command runs. How can I make sure the page is loaded before the logon code runs?



Here is my logon function which includes the code line above:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

So you want to delay the execution of some code in the parent until the child loads?

If so, you can use the onload handler in the child to let the parent know it has executed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
Since my servlet does not actually post a response to an html page how can I use the onload event?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

A request always returns a response. If you have nothing to display, what's the purpose of opening a new window?
[ June 10, 2008: Message edited by: Bear Bibeault ]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
I now have the servlet responding to a blank html page. I have put in a javascript function to run in the onload event.

Now I have no idea what code I would put in the javascript function of the child or back in the parent to handle to tell the parent the child is loaded.

Also, when I use the window.open to populate a frame content the page loads forever until I click something on the loaded page. Clicking the stop loading button will not even work.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

You still haven't answered my question. Why are you doing a window.open if you have nothing to display?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
Sorry about that.

My main web page has three Frames. A header frame, navigation frame, and content frame. In the nav frame I have logon and log off links amoung others which depend on if user is logged on and authority settings). If a person logs on and clicks a link that they have access to it populates the content frame with that page which is set up according to their security settings. When the user clicks the logoff link a servlet is requested that sets certain attributed to default values, hides links in the nav frame as necessary, then displays a blank page in the content frame just in case it was loaded with content that is not authorized for guest.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
Still need help on this issue.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Originally posted by Steve Dyke:
Sorry about that.

My main web page has three Frames. A header frame, navigation frame, and content frame. In the nav frame I have logon and log off links amoung others which depend on if user is logged on and authority settings). If a person logs on and clicks a link that they have access to it populates the content frame with that page which is set up according to their security settings. When the user clicks the logoff link a servlet is requested that sets certain attributed to default values, hides links in the nav frame as necessary, then displays a blank page in the content frame just in case it was loaded with content that is not authorized for guest.


Nothing in this answers my question. Why the window.open()?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
I am not sure what you are asking anymore. The frame as I explained displays content on users request(a HTML page controled by the src value). The src value is a file, in my case a .jsp file. I use the window.open() to request a servlet to set some values and display contents in the frame. Please help me to know exactly what you are asking for. I seem to be missing the meaning of the question.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Here's the disconnect:
Originally posted by Steve Dyke:
I use the window.open() to request a servlet to set some values and display contents in the frame.

window.open() is used to create a new browser window. How are you using it to display something within an existing frame? Why would you use it for such?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
If my content frame src is set to frame_d and I execute the following javascript code from my navigation frame the content frame displays the servlet requestdispatcher jsp link page.



This is obviously not the proper way do this with reguard to your previous post. Can you tell me how to handle this. I have this method used through out my application/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

The easiest way to change the frame source is to set the src attribute to a new value.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
Ok, if I use the following javascript in my navigation frame will this be correct or do I need the JSON to return status so I will know the page is loaded?


[ June 12, 2008: Message edited by: Steve Dyke ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

If you want to make sure that the getJSON request is finished before reloading the frame, then you need to move the reload code to a completion callback for the $.getJSON() call.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1409
Well there is another problem. The servlet that I am calling is a doPost which if I use getJSON I never get a return. If I use jQuery.post I still don't get a return. What syntax do I use in the servlet for my call back using a jQuery.post call.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Well of course if your servlet only supports POST, a GET won't work. You'll either need to modify the servlet or do a POST.

The best way to see what's going on with your Ajax requests is to use Firebug in Firefox which will show you exactly what was submitted in the request, and what was returned as the response.

The callback function is specified on the $.getJSON() method (or $.post() or whatever), not in the servlet. A servlet, or any other server-side resource, has no notion that an Ajax call is being made. It's just a request like any other.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checking for load finished