2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.shale.usecases.rolodex;
18
19 import javax.faces.component.html.HtmlOutputText;
20 import javax.faces.context.FacesContext;
21 import javax.faces.el.ValueBinding;
22
23 public class HeaderSorter extends HtmlOutputText {
24 private String sortBy = null;
25 private boolean sortAscending = true;
26 private String ascImage = null;
27 private String descImage = null;
28
29
30 /***
31 * <p>Sets the renderer type to "org.apache.shale.HeaderSorter".</p>
32 *
33 */
34 public HeaderSorter() {
35 setRendererType("org.apache.shale.HeaderSorter");
36 }
37
38 /***
39 * <p>Sets the family to "org.apache.shale.Sorter".</p>
40 */
41 public String getFamily() {
42 return "org.apache.shale.Sorter";
43 }
44
45 /***
46 * <p>Returns <code>true</code> if the component was selected.</p>
47 */
48 public boolean wasSelected() {
49 boolean selected = false;
50 if ((getId() != null) && getAttributes().get("defaultSort") != null)
51 selected = (getAttributes().get("defaultSort").equals(getId()));
52 return selected;
53 }
54
55 /***
56 * <p>Restores the component's state.</p>
57 */
58 public void restoreState(FacesContext facescontext, Object obj) {
59 Object[] sobj = (Object[]) obj;
60 super.restoreState(facescontext, sobj[0]);
61
62 sortBy = (String) sobj[1];
63 ascImage = (String) sobj[2];
64 descImage = (String) sobj[3];
65 sortAscending = ((Boolean) sobj[4]).booleanValue();
66 sobj = null;
67
68 }
69
70 /***
71 * <p>Saves the component's state.</p>
72 */
73 public Object saveState(FacesContext facescontext) {
74
75 Object aobj[] = new Object[5];
76 aobj[0] = super.saveState(facescontext);
77 aobj[1] = sortBy;
78 aobj[2] = ascImage;
79 aobj[3] = descImage;
80 aobj[4] = new Boolean(sortAscending);
81
82 return aobj;
83 }
84
85 /***
86 * <p>Returns a comma delimited list of properties to sort by. The property names
87 * are defined in the bean collection contained by the UIData model.</p>
88 */
89 public String getSortBy() {
90
91 if (null != sortBy)
92 return sortBy;
93 ValueBinding valuebinding = getValueBinding("sortBy");
94 if (valuebinding != null)
95 return (String) valuebinding.getValue(getFacesContext());
96 else
97 return null;
98
99 }
100
101 /***
102 * <p>Sets a comma delimited list of properties to sort by. The property names
103 * are defined in the bean collection contained by the UIData model.</p>
104 */
105 public void setSortBy(String s) {
106 sortBy = s;
107 }
108
109 /***
110 * <p>Returns <code>true</code> if the model data is sorted in ascending order
111 * defined by the <code>sortBy</code> property.</p>
112 */
113 public boolean isSortAscending() {
114 return sortAscending;
115 }
116
117 /***
118 * <p>This setter toggles the collating sequence from ascending to descending.</p>
119 */
120 public void setSortAscending(boolean b) {
121 sortAscending = b;
122 }
123
124 /***
125 * <p>Returns the acending image resource location that is relative to the
126 * context root.</p>
127 */
128 public String getAscImage() {
129 return ascImage;
130 }
131
132 /***
133 * <p>Returns the decending image resource location that is relative to the
134 * context root.</p>
135 */
136 public String getDescImage() {
137 return descImage;
138 }
139
140 /***
141 * <p>Sets the acending image resource location that is relative to the
142 * context root.</p>
143 */
144 public void setAscImage(String string) {
145 ascImage = string;
146 }
147
148 /***
149 * <p>Sets the decending image resource location that is relative to the
150 * context root.</p>
151 */
152 public void setDescImage(String string) {
153 descImage = string;
154 }
155
156
157 }