• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tiles and image preloading

 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using tiles in an app and the <body> tag is in it's own jsp that includes the other tiles files to complete the layout. If I want to preload images for each jsp how can I accomplish this since the <body> tag is going to be used for every display?
 
Junilu Lacar
Bartender
Pie
Posts: 8757
78
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you mean by "preload images for each jsp". The JSP doesn't load images, the client browser does. If you want to help the client browser load images faster, specify the width and height of images in your markup/tags.
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have explained it a bit better. This is a methodology that will make the 'mouse over' images for buttons loaded right away into the browser cache with JavaScript. I use the onLoad event of the body tag.
So without having a body tag for each individual jsp because of the use of tiles, I'm stuck.
 
Junilu Lacar
Bartender
Pie
Posts: 8757
78
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Sexton:
I should have explained it a bit better. This is a methodology that will make the 'mouse over' images for buttons loaded right away into the browser cache with JavaScript. I use the onLoad event of the body tag.
So without having a body tag for each individual jsp because of the use of tiles, I'm stuck.

I still don't see how this would matter. JavaScript is processed by the client, not when the tiles are being put together so again, the JSP engine has nothing to do with loading your images.
Each JSP does not have to have its own body tag. You can have the body tag and the JavaScript that preloads the images in the layout and all the content in your tiles. The only thing you can't do is to have the opening and closing tags of custom JSP tags on separate pages. Other than that you shouldn't have any problem splitting the content into separate JSPs. When the tiles are all put together they go back to the client as a single HTML page.
Example:
// layout.jsp
<html:html>
<script type="text/javascript" language="JavaScript"
src="<tiles:getAsString name="imageLoadScript" />" />
<body on load="<tiles:getAsString name="imageLoadScriptProcName">" >
<tiles:insert attribute="header" />
<tiles:insert attribute="body" />
<tiles:insert attribute="footer" />
</body>
</html:html>

then in your tiles-def, you can just define puts:
<put name="imageLoadScript" value="myMenuImages.js" />
<put name="imageLoadScriptProcName" value="preLoadMenuImages()" />
You don't even have to make it that complicated if you have only one script to preload your images -- just plug the names in directly into the layout.
[ October 24, 2003: Message edited by: Junilu Lacar ]
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this. I'm just saying that I am required to have all the images for each screen loaded into cache when the page is loaded. The JavaScript is really nothing to do with the question. I was simply not understanding how to make each of these pages load different images, since the <body> was in a different jsp. Your code helped. I'll use puts and that will solve my problem. I just wasn't seeing the solution and it's pretty simple. Thanks for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic