Wait for 5.0.5 ... I'm working on code for that right now, so you'll be able to write:
<img src="/products_images/${productImageURL}"/> Still, from a maintainability situation, I would prefer that the complete URL come from the Java code side; if "/product_images" ever becomes, say, "/images/catalog" some day, you may be able to fix it across your entire application in exactly one place. That's the Dont Repeat Yourself principle and your example jumps out at me as a potential problem. On 5/20/07, 蝈蝈龙 <[EMAIL PROTECTED]> wrote:
Thank you very much. My image file is put on file system. It works now. But I feel that it's not flexible. I wrote the img tag like <img t:id="productImage" src="prop:productImageURL"/> But I want write it like <img t:id="productImage" src="/products_images/prop:productImageURL"/> You see, there is a folder prefix for the src property of img tag above For this efffect, what should I do? 2007/5/21, Howard Lewis Ship <[EMAIL PROTECTED]>: > > In order to answer this question, some background is needed. > > If you know the product's id (whatever you use, where it's SKU number or > a > surrogate key) ... what is the exact process from going from that to a URL > suitable for an <img> tag? > > That is ... are the images stored in the database? Or are they on the > file > system somewhere? If they are files on the file system, are those files > mapped to a client-visible URL? > > In the latter case, you can do something like: > > <img t:id="productImage" src="prop:productImageURL"/> > > public String getProductImageURL() { > return "http://static.myco.com/product-images/" + _productId + ".gif"; > } > > > > Assigning a t:id to a tag without specifying a component type creates an > Any > component, a component that just renders whatever tag and informal > parameters you provide it. Here wer'e linking that to some Java code in > the > corresponding page or component that computes the URL of the product based > on an instance variable. Probably your example is more complicated, but > you > get the idea. > > There's another approach used when the data is inside the database, but we > can dive into that if the above solution is insufficient. > > Assets are useful for accessing resources inside the web application > context, or on the classpath, and includes logic related to localization > ... > but it is not always appropriate when accessing resources that are well > outside the web application itself. > > On 5/19/07, Allen Guo <[EMAIL PROTECTED]> wrote: > > > > Hi All, > > > > I want to show the ProductDetail page with product image. It looks like > > <img src="p_001.jpg" />. > > You know, every product has different image name,so I need to pass the > > string 'p_001.jpg' to the corresponding page. > > As result the img tag should look like <img src="${product.image}"/> or > > I can use Asset to do it. > > > > But I tried to do it using the first approach, exception occured. > > And I don't know how to the second approach. > > Can anyone give me an idea? > > > > Thank in advance > > Allen Guo > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Howard M. Lewis Ship > TWD Consulting, Inc. > Independent J2EE / Open-Source Java Consultant > Creator and PMC Chair, Apache Tapestry > Creator, Apache HiveMind > > Professional Tapestry training, mentoring, support > and project work. http://howardlewisship.com >
-- Howard M. Lewis Ship TWD Consulting, Inc. Independent J2EE / Open-Source Java Consultant Creator and PMC Chair, Apache Tapestry Creator, Apache HiveMind Professional Tapestry training, mentoring, support and project work. http://howardlewisship.com