1 15 package org.apache.tapestry.contrib.components; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.tapestry.IMarkupWriter; 19 import org.apache.tapestry.IRequestCycle; 20 import org.apache.tapestry.Tapestry; 21 import org.apache.tapestry.components.Conditional; 22 23 32 public abstract class When extends Conditional 33 { 34 35 36 private Choose _choose; 37 38 43 44 protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) 45 { 46 Choose choose = getChoose(); 47 48 if (choose == null) 49 throw new ApplicationRuntimeException( 50 Tapestry.getMessage("When.must-be-contained-by-choose"), 51 this, 52 null, 53 null); 54 55 if (!choose.isConditionMet() && getCondition()) 56 { 57 choose.setConditionMet(true); 58 super.renderComponent(writer, cycle); 59 } 60 } 61 62 protected boolean evaluateCondition() 63 { 64 return true; 65 } 66 67 public boolean getInvert() 68 { 69 return false; 71 } 72 73 76 public Choose getChoose() 77 { 78 return _choose; 79 } 80 81 85 public void setChoose(Choose value) 86 { 87 _choose = value; 88 } 89 90 } 91 | Popular Tags |