001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.html;
016    
017    import org.apache.tapestry.AbstractComponent;
018    import org.apache.tapestry.IEngine;
019    import org.apache.tapestry.IMarkupWriter;
020    import org.apache.tapestry.IRequestCycle;
021    import org.apache.tapestry.Tapestry;
022    import org.apache.tapestry.engine.IEngineService;
023    import org.apache.tapestry.engine.ILink;
024    
025    /**
026     * Implements a &lt;frame&gt; within a &lt;frameset&gt;. [ <a
027     * href="../../../../../ComponentReference/Frame.html">Component Reference </a>]
028     * 
029     * @author Howard Lewis Ship
030     */
031    
032    public abstract class Frame extends AbstractComponent
033    {
034        protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
035        {
036            if (cycle.isRewinding())
037                return;
038    
039            IEngine engine = cycle.getEngine();
040            IEngineService pageService = engine.getService(Tapestry.PAGE_SERVICE);
041            ILink link = pageService.getLink(cycle, false, getTargetPage());
042    
043            writer.beginEmpty("frame");
044            writer.attribute("src", link.getURL());
045    
046            renderInformalParameters(writer, cycle);
047    
048            writer.closeTag();
049        }
050    
051        public abstract String getTargetPage();
052    
053        public abstract void setTargetPage(String targetPage);
054    }