View Javadoc

1   // Copyright May 16, 2006 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  package net.sf.tacos.components.dojo.old;
15  
16  import java.util.HashMap;
17  import java.util.Map;
18  
19  import org.apache.tapestry.AbstractComponent;
20  import org.apache.tapestry.IMarkupWriter;
21  import org.apache.tapestry.IRequestCycle;
22  import org.apache.tapestry.IScript;
23  import org.apache.tapestry.PageRenderSupport;
24  import org.apache.tapestry.TapestryUtils;
25  import org.apache.tapestry.dojo.DojoUtils;
26  import org.apache.tapestry.dojo.IWidget;
27  import org.apache.tapestry.json.JSONObject;
28  
29  /**
30   * Implementation of dojo's FloatingPane.
31   *
32   * @author andyhot
33   * @since 4.1
34   * @deprecated Use the {@link DojoWidget} component.
35   */
36  public abstract class TitlePane extends AbstractComponent implements IWidget, IDojoTitlePane 
37  {
38      /** id. */
39      public abstract String getIdParameter();
40  
41      /** More js options - JSON style. */
42      public abstract String getOptions();
43  
44      /** Injected script. */
45      public abstract IScript getScript();
46      
47      /**
48       * {@inheritDoc}
49       */
50      public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
51      {
52          renderComponent(writer, cycle);
53      }    
54  
55      /**
56       * @see org.apache.tapestry.AbstractComponent#renderComponent(org.apache.tapestry.IMarkupWriter,
57       *      org.apache.tapestry.IRequestCycle)
58       */
59      protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
60      {
61          writer.begin("div");
62          writer.attribute("id", getIdParameter());
63          
64          renderInformalParameters(writer, cycle);
65          renderBody(writer, cycle);
66          
67          writer.end();
68          
69          JSONObject obj = DojoUtils.parseJSONParameter(this, "options");
70  
71          obj.put("labelNode", getLabelNode());
72          obj.put("labelNodeClass", getLabelNodeClass());
73          obj.put("label", getLabel());
74          obj.put("containerNodeClass", getContainerNodeClass());      
75  
76          //Setup our script includes
77          Map scriptParms = new HashMap();
78          scriptParms.put("id", getIdParameter());
79          scriptParms.put("props", obj.toString());
80          
81          PageRenderSupport pageRenderSupport = TapestryUtils.getPageRenderSupport(cycle, this);
82          
83          getScript().execute(this, cycle, pageRenderSupport, scriptParms);
84      }
85  }