001    // Copyright May 16, 2006 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    package net.sf.tacos.components.dojo;
015    
016    import java.util.HashMap;
017    import java.util.Map;
018    import net.sf.tacos.util.JSONMarkupWriter;
019    import org.apache.tapestry.IMarkupWriter;
020    import org.apache.tapestry.IRequestCycle;
021    import org.apache.tapestry.IScript;
022    import org.apache.tapestry.TapestryUtils;
023    import org.apache.tapestry.json.JSONObject;
024    
025    /**
026     * Implementation of dojo's ContentPane.
027     *
028     * @since 4.1.1
029     */
030    public abstract class ContentPane extends GenericWidget
031    {
032        public abstract String getStyle();
033        
034        /**
035         * {@inheritDoc}
036         */
037        public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
038        {
039            if (!cycle.isRewinding()) {
040                writer.begin(getTemplateTagName()); // use element specified
041                renderIdAttribute(writer, cycle); // render id="" client id
042                writer.attribute("style", getStyle());
043            }
044            
045            renderBody(writer, cycle);
046            
047            if (!cycle.isRewinding()) {
048                writer.end();
049            }
050            
051            if (!cycle.isRewinding()) {
052                JSONMarkupWriter jsonWriter = new JSONMarkupWriter();
053                renderInformalParameters(jsonWriter, cycle);
054                JSONObject json = jsonWriter.getAttributes();
055    
056                Map parms = new HashMap();            
057                parms.put("component", this);
058                parms.put("props", json.toString());
059                parms.put("tabcontainer", cycle.getAttribute(TabContainer.class.getName()));
060                
061    
062                getScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), parms);
063            }
064        }
065    
066        /** Injected script. */
067        public abstract IScript getScript();
068    }