1 17 package org.alfresco.web.ui.repo.renderer.property; 18 19 import java.io.IOException ; 20 import java.util.List ; 21 22 import javax.faces.component.UIComponent; 23 import javax.faces.context.FacesContext; 24 import javax.faces.context.ResponseWriter; 25 26 import org.alfresco.web.ui.common.Utils; 27 import org.alfresco.web.ui.common.renderer.BaseRenderer; 28 import org.alfresco.web.ui.repo.component.property.UIChildAssociation; 29 import org.apache.commons.logging.Log; 30 import org.apache.commons.logging.LogFactory; 31 32 37 public class ChildAssociationRenderer extends BaseRenderer 38 { 39 private static Log logger = LogFactory.getLog(ChildAssociationRenderer.class); 40 41 44 public void encodeBegin(FacesContext context, UIComponent component) throws IOException 45 { 46 if (component.isRendered() == false) 47 { 48 return; 49 } 50 51 context.getResponseWriter().write("</td>"); 53 } 54 55 58 public void encodeChildren(FacesContext context, UIComponent component) throws IOException 59 { 60 if (component.isRendered() == false) 61 { 62 return; 63 } 64 65 UIChildAssociation association = (UIChildAssociation)component; 66 ResponseWriter out = context.getResponseWriter(); 67 68 int count = association.getChildCount(); 70 71 if (count == 2) 72 { 73 List <UIComponent> kids = association.getChildren(); 75 UIComponent label = kids.get(0); 76 UIComponent control = kids.get(1); 77 78 String labelStylceClass = (String )association.getParent().getAttributes().get("labelStyleClass"); 80 out.write("</td><td"); 81 if (labelStylceClass != null) 82 { 83 outputAttribute(out, labelStylceClass, "class"); 84 } 85 86 out.write(">"); 88 Utils.encodeRecursive(context, label); 90 context.getResponseWriter().write("</td><td>"); 92 Utils.encodeRecursive(context, control); 93 94 } 96 } 97 98 101 public void encodeEnd(FacesContext context, UIComponent component) throws IOException 102 { 103 } 105 106 109 public boolean getRendersChildren() 110 { 111 return true; 112 } 113 } 114 | Popular Tags |