| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Copyright 2004, 2005 The Apache Software Foundation |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <document> |
| <properties> |
| <title>Image</title> |
| </properties> |
| <body> |
| |
| <section name="Image"> |
| |
| <p> |
| Displays an image, deriving the source URL for the image from an asset. |
| <br /> |
| <a href="../link/rollover.html">Rollover</a> |
| is a similar component that can create dynamic mouse-over effects as well. |
| </p> |
| |
| <p> |
| <strong> |
| See also: |
| <a href="../form/imagesubmit.html">ImageSubmit</a> |
| , |
| <a href="../link/rollover.html">Rollover</a> |
| </strong> |
| </p> |
| |
| <section name="Parameters"> |
| <table> |
| <tr> |
| <th>Name</th> |
| <th>Type</th> |
| <th>Required</th> |
| <th>Default</th> |
| <th>Description</th> |
| </tr> |
| <tr> |
| <td>image</td> |
| <td> |
| <a href="../../apidocs/org/apache/tapestry/IAsset.html"> |
| IAsset |
| </a> |
| </td> |
| <td>yes</td> |
| <td></td> |
| <td>The image to show.</td> |
| </tr> |
| </table> |
| |
| <p> |
| Body: |
| <strong>removed</strong> |
| </p> |
| |
| <p> |
| Informal parameters: |
| <strong>allowed</strong> |
| </p> |
| |
| <p> |
| Reserved parameters: |
| <em>src</em> |
| </p> |
| |
| </section> |
| |
| <section name="Examples"> |
| |
| <p> |
| Inserts the static context path based image. |
| <br /> |
| This example uses a <code><context-asset></code> to reference the image. |
| </p> |
| <img src="../../images/ComponentReference/PoweredByTapestry.png" |
| alt="PoweredByTapestry Screen Shot" /> |
| <p>HTML Template</p> |
| <source xml:space="preserve"> |
| <table cellpadding="8" valign="middle"> |
| <tr> |
| <td> |
| <a href="http://jakarta.apache.org/tapestry/"> |
| <img jwcid="@Image" image="asset:imageAsset" alt="View Tapestry Home"/> |
| </a> |
| </td> |
| <td> |
| <font color="navy" size="+2"><b><i>Powered by Tapestry</i></b></font> |
| </td> |
| </tr> |
| </table> |
| </source> |
| |
| <p>Page Specification</p> |
| <source xml:space="preserve"> |
| <asset name="imageAsset" path="/images/poweredby.png"/> |
| </source> |
| |
| <p> |
| <br /> |
| Inserts the dynamic image obtained from the page's NewsItem property. |
| <br /> |
| This example uses the |
| <a href="../../apidocs/org/apache/tapestry/asset/ExternalAsset.html"> |
| ExternalAsset |
| </a> |
| to reference the image's URL. |
| </p> |
| <img src="../images/ComponentReference/Image.png" |
| alt="Image Screen Shot" /> |
| <p>HTML Template</p> |
| <source xml:space="preserve"> |
| <table cellpadding="8"> |
| <tr> |
| <td> |
| <h4><span jwcid="@Insert" value="ognl:newsItem.title"/></h4> |
| <span jwcid="@Insert" value="ognl:newsItem.body"/> |
| <p> |
| Date : <span jwcid="@Insert" value="ognl:newsItem.date" format="ognl:@NewsItemPage@DATE_FORMAT"/> |
| </td> |
| <td> |
| <img jwcid="@Image" image="ognl:newsItem.imageAsset" alt="ognl:newsItem.summary"/> |
| </td> |
| </tr> |
| </table> |
| </source> |
| |
| <p>Page Specification</p> |
| <source xml:space="preserve"> |
| <property name="orderItem" type="com.dsconsulting.cms.model.NewsItem"/> |
| </source> |
| |
| <p>Java classes</p> |
| <source xml:space="preserve"> |
| public abstract class NewsItemPage extends BasePage { |
| public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd MMM yyyy"); |
| |
| public abstract NewsItem getNewsItem(); |
| } |
| |
| public class NewsItem implements Serializable { |
| private String title; |
| private String body; |
| private String summary; |
| private Date date; |
| private String imageURL; |
| |
| public NewsItem(String title, String summary, String body, Date date, |
| String imageURL) { |
| this.title = title; |
| this.body = body; |
| this.summary = summary; |
| this.date = date; |
| this.imageURL = imageURL; |
| } |
| |
| public String getTitle() { return title; } |
| |
| public String getBody() { return body; } |
| |
| public String getSummary() { return summary; } |
| |
| public String getDate() { return date; } |
| |
| public IAsset getImageAsset() { return new ExternalAsset(imageURL, null); } |
| } |
| </source> |
| </section> |
| |
| </section> |
| |
| </body> |
| </document> |