1 17 package org.alfresco.web.ui.repo.component.shelf; 18 19 import java.io.IOException ; 20 import java.util.Iterator ; 21 22 import javax.faces.component.UIComponent; 23 import javax.faces.context.FacesContext; 24 import javax.faces.context.ResponseWriter; 25 import javax.faces.el.ValueBinding; 26 27 import org.alfresco.web.ui.common.Utils; 28 import org.alfresco.web.ui.common.component.SelfRenderingComponent; 29 30 33 public class UIShelfGroup extends SelfRenderingComponent 34 { 35 38 41 public String getFamily() 42 { 43 return "org.alfresco.faces.Shelf"; 44 } 45 46 49 public void restoreState(FacesContext context, Object state) 50 { 51 Object values[] = (Object [])state; 52 super.restoreState(context, values[0]); 54 this.expanded = ((Boolean )values[1]).booleanValue(); 55 this.label = (String )values[2]; 56 } 57 58 61 public Object saveState(FacesContext context) 62 { 63 Object values[] = new Object [3]; 64 values[0] = super.saveState(context); 66 values[1] = (this.expanded ? Boolean.TRUE : Boolean.FALSE); 67 values[2] = this.label; 68 return values; 69 } 70 71 74 public void encodeChildren(FacesContext context) throws IOException 75 { 76 if (isRendered() == false) 77 { 78 return; 79 } 80 81 ResponseWriter out = context.getResponseWriter(); 82 83 out.write("<table cellspacing=0 cellpadding=0 border=0 width=100%>"); 85 for (Iterator i=this.getChildren().iterator(); i.hasNext(); ) 86 { 87 UIComponent child = (UIComponent)i.next(); 88 if (child instanceof UIShelfItem) 89 { 90 out.write("<tr><td>"); 92 Utils.encodeRecursive(context, child); 93 out.write("</tr></td>"); 94 } 95 } 96 out.write("</table>"); 97 } 98 99 102 public boolean getRendersChildren() 103 { 104 return true; 105 } 106 107 108 111 114 public String getLabel() 115 { 116 ValueBinding vb = getValueBinding("label"); 117 if (vb != null) 118 { 119 this.label = (String )vb.getValue(getFacesContext()); 120 } 121 122 return this.label; 123 } 124 125 128 public void setLabel(String label) 129 { 130 this.label = label; 131 } 132 133 136 public boolean isExpanded() 137 { 138 ValueBinding vb = getValueBinding("expanded"); 139 if (vb != null) 140 { 141 Boolean expanded = (Boolean )vb.getValue(getFacesContext()); 142 if (expanded != null) 143 { 144 this.expanded = expanded.booleanValue(); 145 } 146 } 147 148 return this.expanded; 149 } 150 151 154 public void setExpanded(boolean expanded) 155 { 156 this.expanded = expanded; 157 } 158 159 160 private String label = null; 161 private boolean expanded = false; 162 } 163 | Popular Tags |