aspose file tools*
The moose likes Struts and the fly likes why onload() in body unable to call out ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "why onload() in body unable to call out ?" Watch "why onload() in body unable to call out ?" New topic
Author

why onload() in body unable to call out ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
good day to all ,

i try to put my code as below, but seem that the onload() for javascript unable to call out


how do i call the onload function ?

thank you very much for guiding
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
Remove the second n from onnload (so that is is just onload).

- Brent
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
no , i purposely to put onnload function to avoid any conflict
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
well, you are in conflict with the html specs. looks like you will need to modify your browser engine in order to make it execute any JS on onnload()

:-)
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
sorry for confuse everyone here , the reason to put onnload() , the extra "n" is to simply avoid having an error when post for this thread, there have an error show when i click "add reply" button for reply.

back to this case, the onload() function not detected would it be caused by tiles ? for your information, i'm using tiles in my struts application.
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
well, i thought you had too many posts for these kind of mistakes ;-)

okay, the code looks fine.

so, check your html-code (not the jsp code), to see if function and function call are in one html file. i doubt it, which can be related to a tiles misconfiguration you did.

but generally spoken - of course tiles and js work together. these are unrelated technologies.

you might also have forgotten to include a taglib or so.

if nothing works, check the js-console (firefox) or use a js-debugger (venkman) to get down to the cause of your problem.

this should help,
jan
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi jan,

the case here is if i using drop down(select/options) list to make onchange event to call out the function, it able to called , just that the body onload() is not work
[ January 16, 2007: Message edited by: Nakata kokuyo ]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
If you are using tiles then maybe that is the problem. Generally your html and body tags are located in your higher level layout files. The easiest way to troubleshoot this is to look at the html generated.

I have to admit that there is a lot about JavaScript that I do not understand. I have been able to run JavaScript in my tiles by sticking some code in a script tag at the bottom of my jsp file. Like this:


- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
A <head> stanza with an embedded <title> stanza are required by the HTML spec. Try adding the following and see if it works:



Merrill
Consultant, Sima Solutions
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi Merrill Higginson, thanks for reply, i have try it out, it having the same result, after few try, i figure out the problem is caused by another tile page which also have a body with onnload()

the page is header page, which generate the menu, and the page named as "header.jsp" .

the tile definition as below :


eventually attribute body and header page have onnload function, so the body page onnload() doesn't call out when page load but header page's onnload function is called, how to i solve this issue ? if i add the body page onnload() function to header page onnload(), it will work, but for other page which use the header page will hit up error cause the onnload() function is not in that page
[ January 17, 2007: Message edited by: Nakata kokuyo ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I believe Brent has already given the answer. Call the function inline within the body of the document, rather than calling in from the body's onload event.
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
thank you Brent Sterling and Merrill Higginson for the idea , it work now .
is that an answer why we have to do this odd way ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When you're using tiles, you have to remember that each jsp is only a page fragment. Tiles merges all the fragments together and then composes a single html page to be presented to the user. A page can have only one <body> tag and hence only one onload event, and that's usually provided in your header fragments. When you want something to execute when a given fragment is loaded, simply putting it inline with the document seems to work.
[ January 18, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why onload() in body unable to call out ?