Hi, after a long absence, I'm back again in the struts world ;-) I have the following problem, I'd like to add an image on my page, where the name of this image is stored in the database ( not the image itself, just the pathlocation and the name); So I've a form bean with a 'getImagePath()' method that returns a String. But the name & property attributes in the img tag are already reserved for multiple parameters, so, the question is, how can I get my Image coming from my get method, without using scriptlets and all that stuff ? Thanks for your help, Thierry
I've subclassed the ImgTag from Struts and created my own custom tag for doing this kind of thing. I gave some code examples of it in a past message to this list that you could find in the archives. Erik ----- Original Message ----- From: "Thierry Cools" <tc...@billobox.com> To: <st...@jakarta.apache.org> Sent: Friday, September 14, 2001 6:38 AM Subject: <html:img question Hi, after a long absence, I'm back again in the struts world ;-) I have the following problem, I'd like to add an image on my page, where the name of this image is stored in the database ( not the image itself, just the pathlocation and the name); So I've a form bean with a 'getImagePath()' method that returns a String. But the name & property attributes in the img tag are already reserved for multiple parameters, so, the question is, how can I get my Image coming from my get method, without using scriptlets and all that stuff ? Thanks for your help, Thierry
On Fri, 14 Sep 2001, Thierry Cools wrote: > Date: Fri, 14 Sep 2001 15:38:33 +0200 > From: Thierry Cools <tc...@billobox.com> > Reply-To: struts-user@jakarta.apache.org > To: struts-user@jakarta.apache.org > Subject: <html:img question > > Hi, after a long absence, I'm back again in the struts world ;-) > > I have the following problem, I'd like to add an image on my page, > where the name of this image is stored in the database ( not the image > itself, just the pathlocation and the name); So I've a form bean with > a 'getImagePath()' method that returns a String. > > But the name & property attributes in the img tag are already reserved for multiple parameters, > so, the question is, how can I get my Image coming from my get method, without using scriptlets and all that stuff ? > > Thanks for your help, > Thierry Hello Thierry, Welcome back! If your need is to display a different image depending on the user's Locale, this can be satisfied with the "pageKey" or "srcKey" attribute: <html:img pageKey="image.key" .../> which looks up "image.key" in the application resources for the user's current Locale. If you need something more generalized (such as images that are personalized per user, independent of Locale), a runtime exression might be your best bet: <img src="<%= bean.getImagePath() %>"> Craig McClanahan