Hidden Component Index ImageSubmit

Image
net.sf.tapestry.html.Image
Image Component
 
Description
Used to insert an image. Rollover is a similar component that can create dynamic mouse-over effects as well.
See Also
ImageSubmit, Rollover
Parameters
Name Type Direction Required Default Description
image IAsset in yes   The image to show.
border int in no 0 Corresponds to the HTML "border" attribute.

Body: removed
Informal parameters: allowed
Reserved parameters: "src"
Examples

Inserts the static context path based image. This example uses a <context-asset> to reference the image.

View Tapestry Home Powered by Tapestry

<table cellpadding="8" valign="middle">
<tr>
 <td>
  <a href="http://tapestry.sourceforge.net/">
   <img jwcid="poweredbyImage" alt="View Tapestry Home"/>
  </a>
 </td>  
 <td>
  <font color="navy" size="+2"><b><i>Powered by Tapestry</i></b></font>
 </td>
</tr>
</table>


<component id="poweredbyImage" type="Image">
    <binding name="image" expression="assets.imageAsset"/>
</component>

<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

Elvis super helitanker save 14 firefighters lives

<table cellpadding="8">
<tr>
 <td>
  <h4><span jwcid="newsItemTitle"/></h4>
  <span jwcid="newsItemBody"/>
  <p>
  Date : <span jwcid="newsItemDate"/> 
 </td>
 <td>
  <img jwcid="newsItemImage"/>
 </td>
</tr>
</table>

<component id="newsItemImage" type="Image">
    <binding name="image" expression="newsItem.imageAsset"/>
    <binding name="alt" expression="newsItem.summary"/>
</component>

<component id="newsItemTitle" type="Insert">
    <binding name="value" expression="newsItem.title"/>
</component>

<component id="newsItemBody" type="Insert">
    <binding name="value" expression="newsItem.body"/>
</component>

<component id="newsItemDate" type="Insert">
    <binding name="value" expression="newsItem.date"/>
    <field-binding name="format" field-name="NewsItemPage.DATE_FORMAT"/>
</component>


public class NewsItemPage extends BasePage {
    public static final SimpleDateFormat DATE_FORMAT =
        new SimpleDateFormat("dd MMM yyyy");
        
    private NewsItem newsItem;
    
    public NewsItem getNewsItem () { return newsItem; }
    
    public void detach() {
        newsItem = null;
        super.detach();    
    }
}

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); }    
}

Hidden Component Index ImageSubmit