Examples
Inserts the static context path based image. This example uses a
<context-asset> to reference the image.
|
Powered by Tapestry
|
<table cellpadding="8" valign="middle">
<tr>
<td>
<a href="http://tapestry.sourceforge.net/">
<img jwcid="@Image" image="ognl:assets.imageAsset" alt="View Tapestry Home"/>
</a>
</td>
<td>
<font color="navy" size="+2"><b><i>Powered by Tapestry</i></b></font>
</td>
</tr>
</table>
<context-asset name="imageAsset" path="/images/poweredby.png"/>
Inserts the dynamic image obtained from the page's NewsItem property.
This example uses the
ExternalAsset to reference the image's URL.
Elvis helitanker Saves 14 Lives
Elvis (Erickson S-64F ) super helitanker used to fight Sydney Australia
Christmas bushfires. Credited with saving hundreds of homes and
14 firefighters lives in the Black Christmas crisis. Photo of Elvis
helicoper on loan from US refueling at Glenbrook RAAF base.
Date : 4 January 2002
|
|
<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>
<property-specification name="orderItem" type="com.dsconsulting.cms.model.NewsItem"/>
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); }
}
|