KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > wml > Image


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.wml;
16
17 import org.apache.tapestry.AbstractComponent;
18 import org.apache.tapestry.IAsset;
19 import org.apache.tapestry.IMarkupWriter;
20 import org.apache.tapestry.IRequestCycle;
21
22 /**
23  * The Image component indicates that an image is to be included in the text flow. Image layout is done within the
24  * context of normal text layout.
25  *
26  * @author David Solis
27  * @since 3.0
28  *
29  **/

30
31 public abstract class Image extends AbstractComponent
32 {
33     /**
34      * @see org.apache.tapestry.AbstractComponent#renderComponent(org.apache.tapestry.IMarkupWriter, org.apache.tapestry.IRequestCycle)
35      **/

36
37     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
38     {
39         boolean render = !cycle.isRewinding();
40
41         if (render)
42         {
43             writer.beginEmpty("img");
44
45             writer.attribute("src", getImage().buildURL(cycle));
46
47             writer.attribute("alt", getAlt());
48
49             renderInformalParameters(writer, cycle);
50
51             writer.closeTag();
52         }
53     }
54
55     public abstract IAsset getImage();
56
57     public abstract String JavaDoc getAlt();
58 }
59
Popular Tags