1 16 package org.apache.myfaces.custom.sortheader; 17 18 import org.apache.myfaces.component.UserRoleUtils; 19 import org.apache.myfaces.component.html.ext.HtmlDataTable; 20 import org.apache.myfaces.renderkit.RendererUtils; 21 import org.apache.myfaces.renderkit.html.HtmlLinkRendererBase; 22 23 import javax.faces.component.UIComponent; 24 import javax.faces.context.FacesContext; 25 import javax.faces.context.ResponseWriter; 26 import java.io.IOException ; 27 28 48 public class HtmlSortHeaderRenderer 49 extends HtmlLinkRendererBase 50 { 51 53 public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException 54 { 55 RendererUtils.checkParamValidity(facesContext, component, HtmlCommandSortHeader.class); 56 57 if (UserRoleUtils.isEnabledOnUserRole(component)) 58 { 59 HtmlCommandSortHeader sortHeader = (HtmlCommandSortHeader)component; 60 HtmlDataTable dataTable = sortHeader.findParentDataTable(); 61 62 if (sortHeader.isArrow() && sortHeader.getColumnName().equals(dataTable.getSortColumn())) 63 { 64 ResponseWriter writer = facesContext.getResponseWriter(); 65 66 if (dataTable.isSortAscending()) 67 { 68 writer.write("↑"); 69 } 70 else 71 { 72 writer.write("↓"); 73 } 74 } 75 } 76 super.encodeEnd(facesContext, component); 77 } 78 79 } 80 | Popular Tags |