1 23 package com.sun.enterprise.tools.jsfext.layout.descriptor; 24 25 import com.sun.enterprise.tools.jsfext.event.AfterLoopEvent; 26 import com.sun.enterprise.tools.jsfext.event.BeforeLoopEvent; 27 import com.sun.enterprise.tools.jsfext.el.PermissionChecker; 28 29 import java.io.IOException ; 30 31 import javax.faces.context.FacesContext; 32 import javax.faces.component.UIComponent; 33 34 35 47 public class LayoutWhile extends LayoutIf implements LayoutElement { 48 49 52 public LayoutWhile(LayoutElement parent, String condition) { 53 super(parent, condition); 54 } 55 56 57 69 protected boolean encodeThis(FacesContext context, UIComponent component) { 70 return true; 71 } 72 73 82 protected boolean shouldContinue(UIComponent component) { 83 PermissionChecker checker = 84 new PermissionChecker(this, component, getCondition()); 85 return checker.hasPermission(); 87 } 88 89 99 public void encode(FacesContext context, UIComponent component) throws IOException { 100 Object result = dispatchHandlers(context, BEFORE_LOOP, 101 new BeforeLoopEvent((UIComponent) component)); 102 while (shouldContinue(component)) { 103 super.encode(context, component); 104 } 105 result = dispatchHandlers(context, AFTER_LOOP, 106 new AfterLoopEvent((UIComponent) component)); 107 } 108 109 115 public static final String AFTER_LOOP = "afterLoop"; 116 117 123 public static final String BEFORE_LOOP = "beforeLoop"; 124 } 125 | Popular Tags |