View Javadoc

1   /*
2    * AbstractContainerWidget.java
3    *
4    * Created on February 3, 2007, 7:01 AM
5    */
6   
7   package net.sf.tacos.components.dojo;
8   
9   import org.apache.tapestry.IMarkupWriter;
10  import org.apache.tapestry.IRequestCycle;
11  import org.apache.tapestry.dojo.AbstractWidget;
12  
13  /**
14   * A widget that can also be a container.
15   * 
16   * @author andyhot
17   */
18  public abstract class GenericWidget extends AbstractWidget{
19      
20      public abstract boolean getIsContainer();
21      public abstract boolean getNeverDestroy();
22      
23      /**
24       * If this component is a container.
25       */
26      public boolean getContainerState()
27      {
28          return getIsContainer();
29      }
30      
31      public void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
32      {
33          if(!cycle.isRewinding() && !getNeverDestroy()) {            
34              if (!cycle.getResponseBuilder().isDynamic() 
35                      || cycle.getResponseBuilder().explicitlyContains(this)) {                
36                  setDestroy(false);
37              } else
38                  setDestroy(true);
39          }
40          
41          // don't render if not part of update response and we're not containers
42          if (!getContainerState()) {            
43              if (cycle.getResponseBuilder().isDynamic()
44                      && (!cycle.getResponseBuilder().explicitlyContains(this) 
45                              && !cycle.getResponseBuilder().contains(this))) {
46                  return;
47              }
48          }
49          
50          renderWidget(writer, cycle);
51      }    
52      
53      
54  }