001    /*
002     * AbstractContainerWidget.java
003     *
004     * Created on February 3, 2007, 7:01 AM
005     */
006    
007    package net.sf.tacos.components.dojo;
008    
009    import org.apache.tapestry.IMarkupWriter;
010    import org.apache.tapestry.IRequestCycle;
011    import org.apache.tapestry.dojo.AbstractWidget;
012    
013    /**
014     * A widget that can also be a container.
015     * 
016     * @author andyhot
017     */
018    public abstract class GenericWidget extends AbstractWidget{
019        
020        public abstract boolean getIsContainer();
021        public abstract boolean getNeverDestroy();
022        
023        public void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
024        {
025            if(!cycle.isRewinding() && !getNeverDestroy()) {            
026                if (!cycle.getResponseBuilder().isDynamic() 
027                        || cycle.getResponseBuilder().explicitlyContains(this)) {                
028                    setDestroy(false);
029                } else
030                    setDestroy(true);
031            }
032            
033            // don't render if not part of update response and we're not containers
034            if (!getIsContainer()) {            
035                if (cycle.getResponseBuilder().isDynamic()
036                        && (!cycle.getResponseBuilder().explicitlyContains(this) 
037                                && !cycle.getResponseBuilder().contains(this))) {
038                    return;
039                }
040            }
041            
042            renderWidget(writer, cycle);
043        }    
044        
045        
046    }