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.old; 015 016 import java.util.HashMap; 017 import java.util.Map; 018 019 import org.apache.tapestry.AbstractComponent; 020 import org.apache.tapestry.IMarkupWriter; 021 import org.apache.tapestry.IRequestCycle; 022 import org.apache.tapestry.IScript; 023 import org.apache.tapestry.PageRenderSupport; 024 import org.apache.tapestry.TapestryUtils; 025 import org.apache.tapestry.dojo.DojoUtils; 026 import org.apache.tapestry.dojo.IWidget; 027 import org.apache.tapestry.json.JSONObject; 028 029 /** 030 * Implementation of dojo's FloatingPane. 031 * 032 * @author andyhot 033 * @since 4.1 034 * @deprecated Use the {@link DojoWidget} component. 035 */ 036 public abstract class TitlePane extends AbstractComponent implements IWidget, IDojoTitlePane 037 { 038 /** id. */ 039 public abstract String getIdParameter(); 040 041 /** More js options - JSON style. */ 042 public abstract String getOptions(); 043 044 /** Injected script. */ 045 public abstract IScript getScript(); 046 047 /** 048 * {@inheritDoc} 049 */ 050 public void renderWidget(IMarkupWriter writer, IRequestCycle cycle) 051 { 052 renderComponent(writer, cycle); 053 } 054 055 /** 056 * @see org.apache.tapestry.AbstractComponent#renderComponent(org.apache.tapestry.IMarkupWriter, 057 * org.apache.tapestry.IRequestCycle) 058 */ 059 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) 060 { 061 writer.begin("div"); 062 writer.attribute("id", getIdParameter()); 063 064 renderInformalParameters(writer, cycle); 065 renderBody(writer, cycle); 066 067 writer.end(); 068 069 JSONObject obj = DojoUtils.parseJSONParameter(this, "options"); 070 071 obj.put("labelNode", getLabelNode()); 072 obj.put("labelNodeClass", getLabelNodeClass()); 073 obj.put("label", getLabel()); 074 obj.put("containerNodeClass", getContainerNodeClass()); 075 076 //Setup our script includes 077 Map scriptParms = new HashMap(); 078 scriptParms.put("id", getIdParameter()); 079 scriptParms.put("props", obj.toString()); 080 081 PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this); 082 083 getScript().execute(this, cycle, pageRenderSupport, scriptParms); 084 } 085 }