Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to diplay daynamic image in struts>

 
Robert Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to diplay daynamic image in struts>
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is the image dynamic? Is it based on some session attribute or something?
 
Robert Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to display the daynamic image according to the database record!i.e
i want to search the database for the data,the according to the data ,i display the image ,it all daynamic?
can anyone help me?
 
Franck Tranchant
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,
As far as I know, Struts build-in taglibs don't support images (that are not form-related, such as submit button)
So, you will have to re-create the correct HTML code to display your pictures by yourself.
For example, let's say you have a set of pictures in the \images\ directory of your application. Actually each item you have in a database has a GIF file in this directory. The name of each picture is based on item's unique Id in datase.
Item Id 01 in database <=> picture item01.gif
Item Id 02 in database <=> picture item02.gif
etc..
Now, imagine you want to display item infos + item photo on your JSP.
You could use code similar to this in your JSP :
<logic:iterate id="item" name="itemList">
- <bean:write name="item" property="itemId"/><br>
- <bean:write name="item" property="itemName"/><br>
- <bean:write name="item" property="itemColor"/><br>
- <IMG SRC="images\item<bean:write name="item" property="itemId"/>.gif"><br>
</logic:iterate>
as a result, for each row :
- 01
- TestItem
- black
- [you picture here, with SRC property = "images\item01.gif"]
- 02
- AnotherTestItem
- red
- [you picture here, with SRC property = "images\item02.gif"]
Hope is helps...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic