File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes onload for JSP 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 "onload for JSP" Watch "onload for JSP" New topic
Author

onload for JSP

lijun wang
Greenhorn

Joined: Jan 20, 2006
Posts: 28
is there a onload()(javascript) method when I load JSP file?
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Do you mean this:

<BODY onload='alert("zut!")'>


There is no emoticon for what I am feeling!
lijun wang
Greenhorn

Joined: Jan 20, 2006
Posts: 28
I'm using JSF, so there is no body tag, but f:view instead
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62275
    
  68

Moved to the HTML/Javascript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62275
    
  68

Originally posted by lijun wang:
I'm using JSF, so there is no body tag, but f:view instead


If the f:view tag doesn't allow you to specify an onload handler (did you check?), you can do so in the header section of your page like so:

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Originally posted by lijun wang:
I'm using JSF, so there is no body tag, but f:view instead
Thanks


In fact, there is still a body tag. f:view doesn't replace or supercede it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 62275
    
  68

Originally posted by Jeff Albertson:

In fact, there is still a body tag. f:view doesn't replace or supercede it.


In that case, I suspect the issue is that the OP is creating malformed HTML.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
Also, if you have more than one user contributing to the page (i.e. the page composed from a different pieces that created by different people) you might want to add your onload functionality to the one that already exists.You can put this code anywhere inside body tag
 
jQuery in Action, 2nd edition
 
subject: onload for JSP