KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > custom > sortheader > HtmlSortHeaderRenderer


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc;
27
28 /**
29  * @author Manfred Geiler (latest modification by $Author: matze $)
30  * @version $Revision: 1.6 $ $Date: 2004/10/13 11:50:58 $
31  * $Log: HtmlSortHeaderRenderer.java,v $
32  * Revision 1.6 2004/10/13 11:50:58 matze
33  * renamed packages to org.apache
34  *
35  * Revision 1.5 2004/07/01 21:53:10 mwessendorf
36  * ASF switch
37  *
38  * Revision 1.4 2004/06/04 12:10:35 royalts
39  * added check on isArrow
40  *
41  * Revision 1.3 2004/05/18 14:31:38 manolito
42  * user role support completely moved to components source tree
43  *
44  * Revision 1.2 2004/04/22 09:20:55 manolito
45  * derive from HtmlLinkRendererBase instead of HtmlLinkRenderer
46  *
47  */

48 public class HtmlSortHeaderRenderer
49         extends HtmlLinkRendererBase
50 {
51     //private static final Log log = LogFactory.getLog(HtmlSortHeaderRenderer.class);
52

53     public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException JavaDoc
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