blob: 54cdc6d67183f20b62c8e2767953bb0221a6ed55 [file] [log] [blame]
<?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>&lt;context-asset&gt;</code> to reference the image.
</p>
<img src="../../images/ComponentReference/PoweredByTapestry.png"
alt="PoweredByTapestry Screen Shot" />
<p>HTML Template</p>
<source xml:space="preserve">
&lt;table cellpadding="8" valign="middle"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;a href="http://jakarta.apache.org/tapestry/"&gt;
&lt;img jwcid="@Image" image="asset:imageAsset" alt="View Tapestry Home"/&gt;
&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;font color="navy" size="+2"&gt;&lt;b&gt;&lt;i&gt;Powered by Tapestry&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</source>
<p>Page Specification</p>
<source xml:space="preserve">
&lt;asset name="imageAsset" path="/images/poweredby.png"/&gt;
</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">
&lt;table cellpadding="8"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;h4&gt;&lt;span jwcid="@Insert" value="ognl:newsItem.title"/&gt;&lt;/h4&gt;
&lt;span jwcid="@Insert" value="ognl:newsItem.body"/&gt;
&lt;p&gt;
Date : &lt;span jwcid="@Insert" value="ognl:newsItem.date" format="ognl:@NewsItemPage@DATE_FORMAT"/&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img jwcid="@Image" image="ognl:newsItem.imageAsset" alt="ognl:newsItem.summary"/&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
</source>
<p>Page Specification</p>
<source xml:space="preserve">
&lt;property name="orderItem" type="com.dsconsulting.cms.model.NewsItem"/&gt;
</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>