Commit 4dd5e2335185decd80b0e1f6d2c5e0fe96204e9d
1 parent
c2dd5150
Restructuring repo to match branches/tags/trunk.
Showing
20 changed files
with
1454 additions
and
0 deletions
showcase/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
4 | + | ||
5 | + <modelVersion>4.0.0</modelVersion> | ||
6 | + <version>3.3.4-SNAPSHOT</version> | ||
7 | + <groupId>org.richfaces.sandbox</groupId> | ||
8 | + <artifactId>showcase</artifactId> | ||
9 | + <name>showcase</name> | ||
10 | + <packaging>war</packaging> | ||
11 | + | ||
12 | + <build> | ||
13 | + <finalName>${project.artifactId}</finalName> | ||
14 | + <plugins> | ||
15 | + <plugin> | ||
16 | + <artifactId>maven-compiler-plugin</artifactId> | ||
17 | + <version>2.3.2</version> | ||
18 | + <configuration> | ||
19 | + <source>1.5</source> | ||
20 | + <target>1.5</target> | ||
21 | + <encoding>${project.build.sourceEncoding}</encoding> | ||
22 | + </configuration> | ||
23 | + </plugin> | ||
24 | + <plugin> | ||
25 | + <groupId>org.apache.maven.plugins</groupId> | ||
26 | + <artifactId>maven-resources-plugin</artifactId> | ||
27 | + <version>2.4.3</version> | ||
28 | + <configuration> | ||
29 | + <encoding>${project.build.sourceEncoding}</encoding> | ||
30 | + </configuration> | ||
31 | + </plugin> | ||
32 | + </plugins> | ||
33 | + </build> | ||
34 | + | ||
35 | + <dependencies> | ||
36 | + <dependency> | ||
37 | + <groupId>org.richfaces.sandbox.ui</groupId> | ||
38 | + <artifactId>richfaces-assembly</artifactId> | ||
39 | + <version>3.3.4-SNAPSHOT</version> | ||
40 | + </dependency> | ||
41 | + <dependency> | ||
42 | + <groupId>org.richfaces.ui</groupId> | ||
43 | + <artifactId>richfaces-ui</artifactId> | ||
44 | + <version>3.3.4-SNAPSHOT</version> | ||
45 | + </dependency> | ||
46 | + <dependency> | ||
47 | + <groupId>org.richfaces.framework</groupId> | ||
48 | + <artifactId>richfaces-impl</artifactId> | ||
49 | + <version>${project.version}</version> | ||
50 | + </dependency> | ||
51 | + <dependency> | ||
52 | + <groupId>com.uwyn</groupId> | ||
53 | + <artifactId>jhighlight</artifactId> | ||
54 | + <version>1.0</version> | ||
55 | + </dependency> | ||
56 | + <dependency> | ||
57 | + <groupId>javax.faces</groupId> | ||
58 | + <artifactId>jsf-api</artifactId> | ||
59 | + <version>1.2_12</version> | ||
60 | + </dependency> | ||
61 | + <dependency> | ||
62 | + <groupId>javax.faces</groupId> | ||
63 | + <artifactId>jsf-impl</artifactId> | ||
64 | + <version>1.2_12</version> | ||
65 | + </dependency> | ||
66 | + <!-- | ||
67 | + <dependency> | ||
68 | + <groupId>javax.el</groupId> | ||
69 | + <artifactId>el-api</artifactId> | ||
70 | + <version>2.2</version> | ||
71 | + </dependency> --> | ||
72 | + <dependency> | ||
73 | + <groupId>javax.servlet</groupId> | ||
74 | + <artifactId>jstl</artifactId> | ||
75 | + <version>1.2</version> | ||
76 | + </dependency> | ||
77 | + <dependency> | ||
78 | + <groupId>com.sun.facelets</groupId> | ||
79 | + <artifactId>jsf-facelets</artifactId> | ||
80 | + <version>1.1.15.B1</version> | ||
81 | + </dependency> | ||
82 | + </dependencies> | ||
83 | + | ||
84 | + <profiles> | ||
85 | + <profile> | ||
86 | + | ||
87 | + </profile> | ||
88 | + </profiles> | ||
89 | + <properties> | ||
90 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
91 | + <netbeans.hint.deploy.server>Tomcat</netbeans.hint.deploy.server> | ||
92 | + </properties> | ||
93 | +</project> |
1 | +package org.richfaces.schedule; | ||
2 | + | ||
3 | +import org.ajax4jsf.model.DataVisitor; | ||
4 | +import org.ajax4jsf.model.ExtendedDataModel; | ||
5 | +import org.ajax4jsf.model.Range; | ||
6 | +import org.richfaces.component.UISchedule; | ||
7 | +import org.richfaces.component.event.ScheduleDateRangeChangeEvent; | ||
8 | +import org.richfaces.component.event.ScheduleDateRangeChangeListener; | ||
9 | +import org.richfaces.component.event.ScheduleDateRangeSelectEvent; | ||
10 | +import org.richfaces.component.event.ScheduleDateRangeSelectListener; | ||
11 | +import org.richfaces.component.event.ScheduleDateSelectEvent; | ||
12 | +import org.richfaces.component.event.ScheduleDateSelectListener; | ||
13 | +import org.richfaces.component.event.ScheduleItemMoveEvent; | ||
14 | +import org.richfaces.component.event.ScheduleItemMoveListener; | ||
15 | +import org.richfaces.component.event.ScheduleItemResizeEvent; | ||
16 | +import org.richfaces.component.event.ScheduleItemResizeListener; | ||
17 | +import org.richfaces.component.event.ScheduleItemSelectEvent; | ||
18 | +import org.richfaces.component.event.ScheduleItemSelectListener; | ||
19 | +import org.richfaces.component.event.ScheduleViewChangeEvent; | ||
20 | +import org.richfaces.component.event.ScheduleViewChangeListener; | ||
21 | +import org.richfaces.component.model.DateRange; | ||
22 | + | ||
23 | +import javax.faces.application.FacesMessage; | ||
24 | +import javax.faces.application.FacesMessage.Severity; | ||
25 | +import javax.faces.context.FacesContext; | ||
26 | +import javax.faces.event.FacesEvent; | ||
27 | +import java.io.IOException; | ||
28 | +import java.util.ArrayList; | ||
29 | +import java.util.Calendar; | ||
30 | +import java.util.Date; | ||
31 | +import java.util.HashMap; | ||
32 | +import java.util.List; | ||
33 | +import java.util.Map; | ||
34 | +import java.util.Random; | ||
35 | + | ||
36 | +public class Bean { | ||
37 | + | ||
38 | + private String text; | ||
39 | + private boolean allowTaskMoving; | ||
40 | + private List<ScheduleTask> allTasks = new ArrayList<ScheduleTask>(); | ||
41 | + private ExtendedDataModel lazyDataModel = new MyDataModel(); | ||
42 | + private String selectedEventId; | ||
43 | + private int firstDay = Calendar.SUNDAY; | ||
44 | + private boolean showWeekends; | ||
45 | + private Date initialDate; | ||
46 | + private boolean allowTaskResizing; | ||
47 | + private String weekMode = UISchedule.WEEK_MODE_FIXED; | ||
48 | + private String allDayText = "All day"; | ||
49 | + private boolean allDayByDefault; | ||
50 | + private boolean allDaySlot = true; | ||
51 | + private Double aspectRatio = 1.; | ||
52 | + private String axisFormat = "h(:mm)tt"; | ||
53 | + private Integer defaultEventMinutes = 90; | ||
54 | + private Integer contentHeight = 400; | ||
55 | + private Double dragOpacity = .2; | ||
56 | + private Integer dragRevertDuration = 2000; | ||
57 | + private Boolean editable = true; | ||
58 | + private Boolean selectable = true; | ||
59 | + private Boolean selectHelper = true; | ||
60 | + private Boolean unselectAuto = true; | ||
61 | + private String unselectCancel = ""; | ||
62 | + private Integer firstHour = 8; | ||
63 | + private String headerCenter = "title"; | ||
64 | + private String headerLeft = "prevYear,nextYear"; | ||
65 | + private String headerRight = "basicDay,basicWeek agendaDay,agendaWeek month today prev,next"; | ||
66 | + private Integer height = 400; | ||
67 | + private boolean isRTL; | ||
68 | + private Integer maxTime = 17; | ||
69 | + private Integer minTime = 8; | ||
70 | + private Integer slotMinutes = 30; | ||
71 | + private String columnFormat = null; | ||
72 | + private String titleFormat = null; | ||
73 | + private String timeFormat = null; | ||
74 | + private String view = UISchedule.VIEW_MONTH; | ||
75 | + private String locale; | ||
76 | + private CustomScheduleListener additionalListener = new CustomScheduleListener(); | ||
77 | + private int taskIdSequence = 1; | ||
78 | + | ||
79 | + public Bean() { | ||
80 | + Calendar instance = Calendar.getInstance(); | ||
81 | + instance.setTime(getInitialDate()); | ||
82 | + Random random = new Random(); | ||
83 | + for (int i = -30; i < 60; i++) { | ||
84 | + instance.set(Calendar.HOUR, minTime + random.nextInt(maxTime - minTime)); | ||
85 | + instance.set(Calendar.MINUTE, random.nextInt(59)); | ||
86 | + instance.add(Calendar.DAY_OF_YEAR, 1); | ||
87 | + Map<String, Object> data = new HashMap<String, Object>(); | ||
88 | + data.put("category", "category-" + (i % 3)); | ||
89 | + int taskId = taskIdSequence++; | ||
90 | + allTasks.add(new ScheduleTask("" + taskId, "Title " + taskId, instance.getTime(), instance.getTime(), data)); | ||
91 | + } | ||
92 | + | ||
93 | + } | ||
94 | + | ||
95 | + public Boolean taskMoved(ScheduleItemMoveEvent event) { | ||
96 | + System.out.println("taskMoved invoked " + event + " : " + isAllowTaskMoving()); | ||
97 | + if (isAllowTaskMoving()) { | ||
98 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Item moved", event.toString())); | ||
99 | + ScheduleTask task = getTask(event.getEventId()); | ||
100 | + selectedEventId = event.getEventId(); | ||
101 | + if (task != null) { | ||
102 | + boolean endDateEqualsStartDate = task.getStartDate().equals(task.getEndDate()); | ||
103 | + Calendar calendar = Calendar.getInstance(); | ||
104 | + calendar.setTime(task.getStartDate()); | ||
105 | + calendar.add(Calendar.DAY_OF_MONTH, event.getDayDelta()); | ||
106 | + calendar.add(Calendar.MINUTE, event.getMinuteDelta()); | ||
107 | + task.setStartDate(calendar.getTime()); | ||
108 | + if (!event.isAllDay() && endDateEqualsStartDate) { | ||
109 | + calendar.setTime(task.getStartDate()); | ||
110 | + calendar.add(Calendar.MINUTE, getDefaultEventMinutes()); | ||
111 | + } else { | ||
112 | + calendar.setTime(task.getEndDate()); | ||
113 | + calendar.add(Calendar.DAY_OF_MONTH, event.getDayDelta()); | ||
114 | + calendar.add(Calendar.MINUTE, event.getMinuteDelta()); | ||
115 | + } | ||
116 | + task.setEndDate(calendar.getTime()); | ||
117 | + task.setAllDay(event.isAllDay()); | ||
118 | + } | ||
119 | + } else { | ||
120 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "It is not allowed to move this item", event.toString())); | ||
121 | + } | ||
122 | + return isAllowTaskMoving(); | ||
123 | + } | ||
124 | + | ||
125 | + public Boolean taskResized(ScheduleItemResizeEvent event) { | ||
126 | + System.out.println("taskResized invoked " + event + " : " + isAllowTaskResizing()); | ||
127 | + if (isAllowTaskResizing()) { | ||
128 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Item resized", event.toString())); | ||
129 | + ScheduleTask task = getTask(event.getEventId()); | ||
130 | + selectedEventId = event.getEventId(); | ||
131 | + if (task != null) { | ||
132 | + Calendar calendar = Calendar.getInstance(); | ||
133 | + Date date = task.getEndDate() == null ? task.getStartDate() : task.getEndDate(); | ||
134 | + calendar.setTime(date); | ||
135 | + calendar.add(Calendar.DAY_OF_MONTH, event.getDayDelta()); | ||
136 | + calendar.add(Calendar.MINUTE, event.getMinuteDelta()); | ||
137 | + task.setEndDate(calendar.getTime()); | ||
138 | + } | ||
139 | + } else { | ||
140 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "It is not allowed to resize this item", event.toString())); | ||
141 | + } | ||
142 | + return isAllowTaskResizing(); | ||
143 | + } | ||
144 | + | ||
145 | + public void viewChanged(ScheduleViewChangeEvent event) { | ||
146 | + System.out.println("viewChanged invoked " + event); | ||
147 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("View changed", event.toString())); | ||
148 | + setView(event.getView()); | ||
149 | + } | ||
150 | + | ||
151 | + public void taskSelected(ScheduleItemSelectEvent event) { | ||
152 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Task selected", event.toString())); | ||
153 | + selectedEventId = event.getEventId(); | ||
154 | + } | ||
155 | + | ||
156 | + public void dateRangeChanged(ScheduleDateRangeChangeEvent event) { | ||
157 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Date range changed", event.toString())); | ||
158 | + if (UISchedule.VIEW_MONTH.equals(getView())) { | ||
159 | + Calendar calendar = Calendar.getInstance(); | ||
160 | + calendar.setTime(event.getStartDate()); | ||
161 | + calendar.add(Calendar.DATE, 15); | ||
162 | + setInitialDate(calendar.getTime()); | ||
163 | + } else { | ||
164 | + setInitialDate(event.getStartDate()); | ||
165 | + } | ||
166 | + } | ||
167 | + | ||
168 | + public void dateRangeSelected(ScheduleDateRangeSelectEvent event) { | ||
169 | + if (editable) { | ||
170 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Date range selected", event.toString())); | ||
171 | + int taskId = taskIdSequence++; | ||
172 | + allTasks.add(new ScheduleTask("" + taskId, "Title-" + taskId, event.getStartDate(), event.getEndDate(), event.isAllDay())); | ||
173 | + } else { | ||
174 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Date range selected", "Cannot create item. Not in edit mode.")); | ||
175 | + } | ||
176 | + } | ||
177 | + | ||
178 | + public void dateSelected(ScheduleDateSelectEvent event) { | ||
179 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Date selected", event.toString())); | ||
180 | + setInitialDate(event.getDate()); | ||
181 | + } | ||
182 | + | ||
183 | + public ScheduleTask getSelectedTask() { | ||
184 | + return getTask(getSelectedEventId()); | ||
185 | + } | ||
186 | + | ||
187 | + protected ScheduleTask getTask(String id) { | ||
188 | + if (id == null) { | ||
189 | + return null; | ||
190 | + } | ||
191 | + for (ScheduleTask task : allTasks) { | ||
192 | + if (id.equals(task.getId())) { | ||
193 | + return task; | ||
194 | + } | ||
195 | + } | ||
196 | + return null; | ||
197 | + } | ||
198 | + | ||
199 | + public String getText() { | ||
200 | + return text; | ||
201 | + } | ||
202 | + | ||
203 | + public void setText(String text) { | ||
204 | + this.text = text; | ||
205 | + } | ||
206 | + | ||
207 | + public List<ScheduleTask> getAllEvents() { | ||
208 | + return allTasks; | ||
209 | + } | ||
210 | + | ||
211 | + public ExtendedDataModel getLazyDataModel() { | ||
212 | + return lazyDataModel; | ||
213 | + } | ||
214 | + | ||
215 | + public boolean isAllowTaskMoving() { | ||
216 | + return allowTaskMoving; | ||
217 | + } | ||
218 | + | ||
219 | + public void setAllowTaskMoving(boolean allowTaskMoving) { | ||
220 | + this.allowTaskMoving = allowTaskMoving; | ||
221 | + } | ||
222 | + | ||
223 | + public boolean isAllowTaskResizing() { | ||
224 | + return allowTaskResizing; | ||
225 | + } | ||
226 | + | ||
227 | + public void setAllowTaskResizing(boolean allowTaskResizing) { | ||
228 | + this.allowTaskResizing = allowTaskResizing; | ||
229 | + } | ||
230 | + | ||
231 | + public String getSelectedEventId() { | ||
232 | + return selectedEventId; | ||
233 | + } | ||
234 | + | ||
235 | + public Date getInitialDate() { | ||
236 | + if (initialDate == null) { | ||
237 | + Calendar instance = Calendar.getInstance(); | ||
238 | + instance.set(Calendar.YEAR, 2012); | ||
239 | + instance.set(Calendar.MONTH, 7); | ||
240 | + instance.set(Calendar.DATE, 22); | ||
241 | + initialDate = instance.getTime(); | ||
242 | + } | ||
243 | + return initialDate; | ||
244 | + } | ||
245 | + | ||
246 | + public int getFirstDay() { | ||
247 | + return firstDay; | ||
248 | + } | ||
249 | + | ||
250 | + public void setFirstDay(int firstDay) { | ||
251 | + this.firstDay = firstDay; | ||
252 | + } | ||
253 | + | ||
254 | + public boolean isShowWeekends() { | ||
255 | + return showWeekends; | ||
256 | + } | ||
257 | + | ||
258 | + public void setShowWeekends(boolean showWeekends) { | ||
259 | + this.showWeekends = showWeekends; | ||
260 | + } | ||
261 | + | ||
262 | + public void setInitialDate(Date initialDate) { | ||
263 | + this.initialDate = initialDate; | ||
264 | + } | ||
265 | + | ||
266 | + public String getWeekMode() { | ||
267 | + return weekMode; | ||
268 | + } | ||
269 | + | ||
270 | + public void setWeekMode(String weekMode) { | ||
271 | + this.weekMode = weekMode; | ||
272 | + } | ||
273 | + | ||
274 | + public void setAllDayText(String allDayText) { | ||
275 | + this.allDayText = allDayText; | ||
276 | + } | ||
277 | + | ||
278 | + public String getAllDayText() { | ||
279 | + return allDayText; | ||
280 | + } | ||
281 | + | ||
282 | + public void setAllDayByDefault(boolean allDayByDefault) { | ||
283 | + this.allDayByDefault = allDayByDefault; | ||
284 | + } | ||
285 | + | ||
286 | + public boolean getAllDayByDefault() { | ||
287 | + return allDayByDefault; | ||
288 | + } | ||
289 | + | ||
290 | + public void setAllDaySlot(boolean allDaySlot) { | ||
291 | + this.allDaySlot = allDaySlot; | ||
292 | + } | ||
293 | + | ||
294 | + public boolean getAllDaySlot() { | ||
295 | + return allDaySlot; | ||
296 | + } | ||
297 | + | ||
298 | + public void setAspectRatio(Double aspectRatio) { | ||
299 | + this.aspectRatio = aspectRatio; | ||
300 | + } | ||
301 | + | ||
302 | + public Double getAspectRatio() { | ||
303 | + return aspectRatio; | ||
304 | + } | ||
305 | + | ||
306 | + public void setAxisFormat(String axisFormat) { | ||
307 | + this.axisFormat = axisFormat; | ||
308 | + } | ||
309 | + | ||
310 | + public String getAxisFormat() { | ||
311 | + return axisFormat; | ||
312 | + } | ||
313 | + | ||
314 | + public void setDefaultEventMinutes(Integer defaultEventMinutes) { | ||
315 | + this.defaultEventMinutes = defaultEventMinutes; | ||
316 | + } | ||
317 | + | ||
318 | + public Integer getDefaultEventMinutes() { | ||
319 | + return defaultEventMinutes; | ||
320 | + } | ||
321 | + | ||
322 | + public void setContentHeight(Integer contentHeight) { | ||
323 | + this.contentHeight = contentHeight; | ||
324 | + } | ||
325 | + | ||
326 | + public Integer getContentHeight() { | ||
327 | + return contentHeight; | ||
328 | + } | ||
329 | + | ||
330 | + public void setDragOpacity(Double dragOpacity) { | ||
331 | + this.dragOpacity = dragOpacity; | ||
332 | + } | ||
333 | + | ||
334 | + public Double getDragOpacity() { | ||
335 | + return dragOpacity; | ||
336 | + } | ||
337 | + | ||
338 | + public void setDragRevertDuration(Integer dragRevertDuration) { | ||
339 | + this.dragRevertDuration = dragRevertDuration; | ||
340 | + } | ||
341 | + | ||
342 | + public Integer getDragRevertDuration() { | ||
343 | + return dragRevertDuration; | ||
344 | + } | ||
345 | + | ||
346 | + public void setEditable(Boolean editable) { | ||
347 | + this.editable = editable; | ||
348 | + } | ||
349 | + | ||
350 | + public Boolean getEditable() { | ||
351 | + return editable; | ||
352 | + } | ||
353 | + | ||
354 | + public void setSelectable(Boolean selectable) { | ||
355 | + this.selectable = selectable; | ||
356 | + } | ||
357 | + | ||
358 | + public Boolean getSelectable() { | ||
359 | + return selectable; | ||
360 | + } | ||
361 | + | ||
362 | + public void setFirstHour(Integer firstHour) { | ||
363 | + this.firstHour = firstHour; | ||
364 | + } | ||
365 | + | ||
366 | + public Integer getFirstHour() { | ||
367 | + return firstHour; | ||
368 | + } | ||
369 | + | ||
370 | + public void setHeaderCenter(String headerCenter) { | ||
371 | + this.headerCenter = headerCenter; | ||
372 | + } | ||
373 | + | ||
374 | + public String getHeaderCenter() { | ||
375 | + return headerCenter; | ||
376 | + } | ||
377 | + | ||
378 | + public void setHeaderLeft(String headerLeft) { | ||
379 | + this.headerLeft = headerLeft; | ||
380 | + } | ||
381 | + | ||
382 | + public String getHeaderLeft() { | ||
383 | + return headerLeft; | ||
384 | + } | ||
385 | + | ||
386 | + public void setHeaderRight(String headerRight) { | ||
387 | + this.headerRight = headerRight; | ||
388 | + } | ||
389 | + | ||
390 | + public String getHeaderRight() { | ||
391 | + return headerRight; | ||
392 | + } | ||
393 | + | ||
394 | + public void setHeight(Integer height) { | ||
395 | + this.height = height; | ||
396 | + } | ||
397 | + | ||
398 | + public Integer getHeight() { | ||
399 | + return height; | ||
400 | + } | ||
401 | + | ||
402 | + public void setIsRTL(Boolean isRTL) { | ||
403 | + this.isRTL = isRTL; | ||
404 | + } | ||
405 | + | ||
406 | + public Boolean getIsRTL() { | ||
407 | + return isRTL; | ||
408 | + } | ||
409 | + | ||
410 | + public void setMaxTime(Integer maxTime) { | ||
411 | + this.maxTime = maxTime; | ||
412 | + } | ||
413 | + | ||
414 | + public Integer getMaxTime() { | ||
415 | + return maxTime; | ||
416 | + } | ||
417 | + | ||
418 | + public void setMinTime(Integer minTime) { | ||
419 | + this.minTime = minTime; | ||
420 | + } | ||
421 | + | ||
422 | + public Integer getMinTime() { | ||
423 | + return minTime; | ||
424 | + } | ||
425 | + | ||
426 | + public void setSlotMinutes(Integer slotMinutes) { | ||
427 | + this.slotMinutes = slotMinutes; | ||
428 | + } | ||
429 | + | ||
430 | + public Integer getSlotMinutes() { | ||
431 | + return slotMinutes; | ||
432 | + } | ||
433 | + | ||
434 | + public void setView(String view) { | ||
435 | + this.view = view; | ||
436 | + } | ||
437 | + | ||
438 | + public String getView() { | ||
439 | + return view; | ||
440 | + } | ||
441 | + | ||
442 | + public String getColumnFormat() { | ||
443 | + return columnFormat; | ||
444 | + } | ||
445 | + | ||
446 | + public void setColumnFormat(String columnFormat) { | ||
447 | + this.columnFormat = columnFormat; | ||
448 | + } | ||
449 | + | ||
450 | + public String getTitleFormat() { | ||
451 | + return titleFormat; | ||
452 | + } | ||
453 | + | ||
454 | + public void setTitleFormat(String titleFormat) { | ||
455 | + this.titleFormat = titleFormat; | ||
456 | + } | ||
457 | + | ||
458 | + public String getTimeFormat() { | ||
459 | + return timeFormat; | ||
460 | + } | ||
461 | + | ||
462 | + public void setTimeFormat(String timeFormat) { | ||
463 | + this.timeFormat = timeFormat; | ||
464 | + } | ||
465 | + | ||
466 | + public CustomScheduleListener getAdditionalListener() { | ||
467 | + return additionalListener; | ||
468 | + } | ||
469 | + | ||
470 | + public Boolean getSelectHelper() { | ||
471 | + return selectHelper; | ||
472 | + } | ||
473 | + | ||
474 | + public void setSelectHelper(Boolean selectHelper) { | ||
475 | + this.selectHelper = selectHelper; | ||
476 | + } | ||
477 | + | ||
478 | + public Boolean getUnselectAuto() { | ||
479 | + return unselectAuto; | ||
480 | + } | ||
481 | + | ||
482 | + public void setUnselectAuto(Boolean unselectAuto) { | ||
483 | + this.unselectAuto = unselectAuto; | ||
484 | + } | ||
485 | + | ||
486 | + public String getUnselectCancel() { | ||
487 | + return unselectCancel; | ||
488 | + } | ||
489 | + | ||
490 | + public void setUnselectCancel(String unselectCancel) { | ||
491 | + this.unselectCancel = unselectCancel; | ||
492 | + } | ||
493 | + | ||
494 | + public String getLocale() { | ||
495 | + if (locale == null) { | ||
496 | + locale = FacesContext.getCurrentInstance().getViewRoot().getLocale().getLanguage(); | ||
497 | + } | ||
498 | + return locale; | ||
499 | + } | ||
500 | + | ||
501 | + public void setLocale(String locale) { | ||
502 | + this.locale = locale; | ||
503 | + } | ||
504 | + | ||
505 | + private class MyDataModel extends ExtendedDataModel { | ||
506 | + | ||
507 | + Object rowKey; | ||
508 | + java.util.Map wrappedDataMap = new HashMap(); | ||
509 | + java.util.Map indexToRowKey = new HashMap(); | ||
510 | + java.util.Map rowKeyToIndex = new HashMap(); | ||
511 | + int rowCount = -1; | ||
512 | + int rowIndex = -1; | ||
513 | + | ||
514 | + @Override | ||
515 | + public void setRowKey(Object key) { | ||
516 | + this.rowKey = key; | ||
517 | + Integer index = (Integer) rowKeyToIndex.get(key); | ||
518 | + if (index == null) { | ||
519 | + index = -1; | ||
520 | + } | ||
521 | + if (index != getRowIndex()) { | ||
522 | + setRowIndex(rowIndex); | ||
523 | + } | ||
524 | + } | ||
525 | + | ||
526 | + @Override | ||
527 | + public Object getRowKey() { | ||
528 | + return rowKey; | ||
529 | + } | ||
530 | + | ||
531 | + @Override | ||
532 | + public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException { | ||
533 | + Date startDate = ((DateRange) range).getStartDate(); | ||
534 | + Date endDate = ((DateRange) range).getEndDate(); | ||
535 | + wrappedDataMap.clear(); | ||
536 | + indexToRowKey.clear(); | ||
537 | + rowKeyToIndex.clear(); | ||
538 | + int i = 0; | ||
539 | + for (ScheduleTask task : allTasks) { | ||
540 | + if ((startDate == null || task.getStartDate().compareTo(startDate) >= 0) && (endDate == null || task.getStartDate().compareTo(endDate) < 0)) { | ||
541 | + wrappedDataMap.put(task.getId(), task); | ||
542 | + int index = i++; | ||
543 | + indexToRowKey.put(index, task.getId()); | ||
544 | + rowKeyToIndex.put(task.getId(), index); | ||
545 | + visitor.process(context, task.getId(), argument); | ||
546 | + } | ||
547 | + } | ||
548 | + rowCount = -1; | ||
549 | + } | ||
550 | + | ||
551 | + @Override | ||
552 | + public boolean isRowAvailable() { | ||
553 | + if (getRowKey() == null) { | ||
554 | + return false; | ||
555 | + } else { | ||
556 | + return null != wrappedDataMap.get(getRowKey()); | ||
557 | + } | ||
558 | + } | ||
559 | + | ||
560 | + @Override | ||
561 | + public int getRowCount() { | ||
562 | + if (rowCount == -1) { | ||
563 | + rowCount = wrappedDataMap.size(); | ||
564 | + } | ||
565 | + return rowCount; | ||
566 | + } | ||
567 | + | ||
568 | + @Override | ||
569 | + public Object getRowData() { | ||
570 | + if (getRowKey() == null) { | ||
571 | + return null; | ||
572 | + } else { | ||
573 | + return wrappedDataMap.get(getRowKey()); | ||
574 | + } | ||
575 | + } | ||
576 | + | ||
577 | + @Override | ||
578 | + public int getRowIndex() { | ||
579 | + return rowIndex; | ||
580 | + } | ||
581 | + | ||
582 | + @Override | ||
583 | + public void setRowIndex(int rowIndex) { | ||
584 | + this.rowIndex = rowIndex; | ||
585 | + Object key = indexToRowKey.get(rowIndex); | ||
586 | + if ((key != null && !key.equals(getRowKey())) || (key == null && getRowKey() != null)) { | ||
587 | + setRowKey(key); | ||
588 | + } | ||
589 | + } | ||
590 | + | ||
591 | + @Override | ||
592 | + public Object getWrappedData() { | ||
593 | + throw new UnsupportedOperationException("Not supported yet."); | ||
594 | + } | ||
595 | + | ||
596 | + @Override | ||
597 | + public void setWrappedData(Object data) { | ||
598 | + throw new UnsupportedOperationException("Not supported yet."); | ||
599 | + } | ||
600 | + } | ||
601 | + | ||
602 | + public static class CustomScheduleListener implements ScheduleDateRangeChangeListener, ScheduleDateSelectListener, ScheduleItemMoveListener, ScheduleItemResizeListener, ScheduleItemSelectListener, ScheduleViewChangeListener, ScheduleDateRangeSelectListener { | ||
603 | + | ||
604 | + private static FacesEvent recentlyProcessedEvent; | ||
605 | + | ||
606 | + private void addMessage(String text, Severity severity) { | ||
607 | + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, "Additional listener", text)); | ||
608 | + } | ||
609 | + | ||
610 | + public void dateRangeChanged(ScheduleDateRangeChangeEvent event) { | ||
611 | + if (event != recentlyProcessedEvent) { | ||
612 | + recentlyProcessedEvent = event; | ||
613 | + addMessage(event.toString(), FacesMessage.SEVERITY_INFO); | ||
614 | + } | ||
615 | + } | ||
616 | + | ||
617 | + public void dateSelected(ScheduleDateSelectEvent event) { | ||
618 | + if (event != recentlyProcessedEvent) { | ||
619 | + recentlyProcessedEvent = event; | ||
620 | + addMessage(event.toString(), FacesMessage.SEVERITY_INFO); | ||
621 | + } | ||
622 | + } | ||
623 | + | ||
624 | + public void itemMove(ScheduleItemMoveEvent event) { | ||
625 | + if (event != recentlyProcessedEvent) { | ||
626 | + recentlyProcessedEvent = event; | ||
627 | + addMessage("I'd like to veto moving, but nobody cares!", FacesMessage.SEVERITY_WARN); | ||
628 | + } | ||
629 | + } | ||
630 | + | ||
631 | + public void itemResize(ScheduleItemResizeEvent event) { | ||
632 | + if (event != recentlyProcessedEvent) { | ||
633 | + recentlyProcessedEvent = event; | ||
634 | + addMessage("I'd like to veto resizing, but nobody cares!", FacesMessage.SEVERITY_WARN); | ||
635 | + } | ||
636 | + } | ||
637 | + | ||
638 | + public void itemSelected(ScheduleItemSelectEvent event) { | ||
639 | + if (event != recentlyProcessedEvent) { | ||
640 | + recentlyProcessedEvent = event; | ||
641 | + addMessage(event.toString(), FacesMessage.SEVERITY_INFO); | ||
642 | + } | ||
643 | + } | ||
644 | + | ||
645 | + public void viewChanged(ScheduleViewChangeEvent event) { | ||
646 | + if (event != recentlyProcessedEvent) { | ||
647 | + recentlyProcessedEvent = event; | ||
648 | + addMessage(event.toString(), FacesMessage.SEVERITY_INFO); | ||
649 | + } | ||
650 | + } | ||
651 | + | ||
652 | + public void dateRangeSelected(ScheduleDateRangeSelectEvent event) { | ||
653 | + if (event != recentlyProcessedEvent) { | ||
654 | + recentlyProcessedEvent = event; | ||
655 | + addMessage(event.toString(), FacesMessage.SEVERITY_INFO); | ||
656 | + } | ||
657 | + } | ||
658 | + } | ||
659 | +} |
1 | +package org.richfaces.schedule; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | +import java.util.Map; | ||
5 | + | ||
6 | +//TODO base this example on classroom schedule | ||
7 | +public class ScheduleTask { | ||
8 | + // TODO shouldn't ID be an object? | ||
9 | + private String id; | ||
10 | + private String title; | ||
11 | + private Date startDate; | ||
12 | + private Date endDate; | ||
13 | + private Boolean allDay; | ||
14 | + private Map<String, Object> data; | ||
15 | + private Boolean editable; | ||
16 | + private String url; | ||
17 | + private String details; | ||
18 | + | ||
19 | + public ScheduleTask() { | ||
20 | + } | ||
21 | + | ||
22 | + public ScheduleTask(String id, String title, Date start, Date end) { | ||
23 | + this.id = id; | ||
24 | + this.title = title; | ||
25 | + this.startDate = start; | ||
26 | + this.endDate = end; | ||
27 | + } | ||
28 | + | ||
29 | + public ScheduleTask(String id, String title, Date start, Date end, boolean allDay) { | ||
30 | + this.id = id; | ||
31 | + this.title = title; | ||
32 | + this.startDate = start; | ||
33 | + this.endDate = end; | ||
34 | + this.allDay = allDay; | ||
35 | + } | ||
36 | + | ||
37 | + public ScheduleTask(String id, String title, Date start, Date end, Map<String, Object> data) { | ||
38 | + this.id = id; | ||
39 | + this.title = title; | ||
40 | + this.startDate = start; | ||
41 | + this.endDate = end; | ||
42 | + this.data = data; | ||
43 | + } | ||
44 | + | ||
45 | + public String getId() { | ||
46 | + return id; | ||
47 | + } | ||
48 | + | ||
49 | + public void setId(String id) { | ||
50 | + this.id = id; | ||
51 | + } | ||
52 | + | ||
53 | + public String getTitle() { | ||
54 | + return title; | ||
55 | + } | ||
56 | + | ||
57 | + public void setTitle(String title) { | ||
58 | + this.title = title; | ||
59 | + } | ||
60 | + | ||
61 | + public Date getStartDate() { | ||
62 | + return startDate; | ||
63 | + } | ||
64 | + | ||
65 | + public void setStartDate(Date startDate) { | ||
66 | + this.startDate = startDate; | ||
67 | + } | ||
68 | + | ||
69 | + public Date getEndDate() { | ||
70 | + return endDate; | ||
71 | + } | ||
72 | + | ||
73 | + public void setEndDate(Date endDate) { | ||
74 | + this.endDate = endDate; | ||
75 | + } | ||
76 | + | ||
77 | + public Boolean getAllDay() { | ||
78 | + return allDay; | ||
79 | + } | ||
80 | + | ||
81 | + public void setAllDay(boolean allDay) { | ||
82 | + this.allDay = allDay; | ||
83 | + } | ||
84 | + | ||
85 | + public Map<String, Object> getData() { | ||
86 | + return data; | ||
87 | + } | ||
88 | + | ||
89 | + public void setData(Map<String, Object> data) { | ||
90 | + this.data = data; | ||
91 | + } | ||
92 | + | ||
93 | + public Boolean getEditable() { | ||
94 | + return editable; | ||
95 | + } | ||
96 | + | ||
97 | + public void setEditable(Boolean editable) { | ||
98 | + this.editable = editable; | ||
99 | + } | ||
100 | + | ||
101 | + public String getURL() { | ||
102 | + return url; | ||
103 | + } | ||
104 | + | ||
105 | + public void setURL(String url) { | ||
106 | + this.url = url; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public boolean equals(Object obj) { | ||
111 | + if (this == obj) { | ||
112 | + return true; | ||
113 | + } | ||
114 | + if (!(obj instanceof ScheduleTask)) { | ||
115 | + return false; | ||
116 | + } | ||
117 | + | ||
118 | + ScheduleTask toCompare = (ScheduleTask) obj; | ||
119 | + return this.id != null && this.id.equals(toCompare.id); | ||
120 | + | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public int hashCode() { | ||
125 | + int hash = 1; | ||
126 | + if (this.id != null) { | ||
127 | + hash = hash * 31 + this.id.hashCode(); | ||
128 | + } | ||
129 | + return hash; | ||
130 | + } | ||
131 | + | ||
132 | + public String getDetails() { | ||
133 | + return details; | ||
134 | + } | ||
135 | + | ||
136 | + public void setDetails(String details) { | ||
137 | + this.details = details; | ||
138 | + } | ||
139 | +} |
1 | +<?xml version='1.0' encoding='UTF-8'?> | ||
2 | +<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:p="http://primefaces.prime.com.tr/ui" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"> | ||
4 | + | ||
5 | + | ||
6 | +</faces-config> |
showcase/src/main/webapp/WEB-INF/web.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> | ||
3 | + <context-param> | ||
4 | + <param-name>javax.faces.CONFIG_FILES</param-name> | ||
5 | + <param-value>/WEB-INF/faces-config.xml</param-value> | ||
6 | + </context-param> | ||
7 | + <context-param> | ||
8 | + <param-name>org.richfaces.SKIN</param-name> | ||
9 | + <param-value>classic</param-value> | ||
10 | + </context-param> | ||
11 | + <context-param> | ||
12 | + <param-name>javax.faces.DEFAULT_SUFFIX</param-name> | ||
13 | + <param-value>.xhtml</param-value> | ||
14 | + </context-param> | ||
15 | + <context-param> | ||
16 | + <param-name>facelets.REFRESH_PERIOD</param-name> | ||
17 | + <param-value>2</param-value> | ||
18 | + </context-param> | ||
19 | + <context-param> | ||
20 | + <param-name>facelets.DEVELOPMENT</param-name> | ||
21 | + <param-value>true</param-value> | ||
22 | + </context-param> | ||
23 | + <context-param> | ||
24 | + <param-name>facelets.SKIP_COMMENTS</param-name> | ||
25 | + <param-value>true</param-value> | ||
26 | + </context-param> | ||
27 | + <context-param> | ||
28 | + <param-name>javax.faces.STATE_SAVING_METHOD</param-name> | ||
29 | + <param-value>server</param-value> | ||
30 | + </context-param> | ||
31 | + <context-param> | ||
32 | + <param-name>com.sun.faces.validateXml</param-name> | ||
33 | + <param-value>true</param-value> | ||
34 | + </context-param> | ||
35 | + <context-param> | ||
36 | + <param-name>com.sun.faces.verifyObjects</param-name> | ||
37 | + <param-value>false</param-value> | ||
38 | + </context-param> | ||
39 | + <context-param> | ||
40 | + <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name> | ||
41 | + <param-value>com.sun.facelets.FaceletViewHandler</param-value> | ||
42 | + </context-param> | ||
43 | + <context-param> | ||
44 | + <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name> | ||
45 | + <param-value>false</param-value> | ||
46 | + </context-param> | ||
47 | + <filter> | ||
48 | + <display-name>Ajax4jsf Filter</display-name> | ||
49 | + <filter-name>ajax4jsf</filter-name> | ||
50 | + <filter-class>org.ajax4jsf.Filter</filter-class> | ||
51 | + </filter> | ||
52 | + <filter-mapping> | ||
53 | + <filter-name>ajax4jsf</filter-name> | ||
54 | + <servlet-name>Faces Servlet</servlet-name> | ||
55 | + <dispatcher>REQUEST</dispatcher> | ||
56 | + <dispatcher>FORWARD</dispatcher> | ||
57 | + <dispatcher>INCLUDE</dispatcher> | ||
58 | + <dispatcher>ERROR</dispatcher> | ||
59 | + </filter-mapping> | ||
60 | + <servlet> | ||
61 | + <servlet-name>Faces Servlet</servlet-name> | ||
62 | + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> | ||
63 | + <load-on-startup>1</load-on-startup> | ||
64 | + </servlet> | ||
65 | + <servlet-mapping> | ||
66 | + <servlet-name>Faces Servlet</servlet-name> | ||
67 | + <url-pattern>/faces/*</url-pattern> | ||
68 | + </servlet-mapping> | ||
69 | + <servlet-mapping> | ||
70 | + <servlet-name>Faces Servlet</servlet-name> | ||
71 | + <url-pattern>*.jsf</url-pattern> | ||
72 | + </servlet-mapping> | ||
73 | + <welcome-file-list> | ||
74 | + <welcome-file>faces/index.xhtml</welcome-file> | ||
75 | + </welcome-file-list> | ||
76 | +</web-app> |
showcase/src/main/webapp/index.xhtml
0 → 100644
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
2 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | + | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:f="http://java.sun.com/jsf/core"> | ||
8 | + | ||
9 | + <ui:composition template="template.xhtml"> | ||
10 | + <ui:define name="htmlHead" /> | ||
11 | + | ||
12 | + <ui:define name="header"> | ||
13 | + <ul> | ||
14 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_1.jsf">Focus Samples</h:outputLink></li> | ||
15 | + </ul> | ||
16 | + </ui:define> | ||
17 | + <ui:define name="content"> | ||
18 | + | ||
19 | + </ui:define> | ||
20 | + <ui:define name="footer"> | ||
21 | + | ||
22 | + </ui:define> | ||
23 | + </ui:composition> | ||
24 | +</html> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + <p>Focus should be placed on email: | ||
22 | + <ul> | ||
23 | + <li>username gets default priority 0</li> | ||
24 | + <li>email gets priority -1</li> | ||
25 | + </ul> | ||
26 | + </p> | ||
27 | + | ||
28 | + <h:form> | ||
29 | + <h:panelGrid columns="3"> | ||
30 | + <h:outputLabel value="Username" for="username"/> | ||
31 | + <h:inputText value="#{username}" id="username" required="true"> | ||
32 | + <sand:focus/> | ||
33 | + </h:inputText> | ||
34 | + <h:message for="username"/> | ||
35 | + | ||
36 | + <h:outputLabel value="Email" for="email"/> | ||
37 | + <h:inputText value="#{email}" id="email" required="true"/> | ||
38 | + <h:message for="email"/> | ||
39 | + </h:panelGrid> | ||
40 | + <h:commandButton value="Submit"/> | ||
41 | + <sand:focus for="email" priority="-1"/> | ||
42 | + </h:form> | ||
43 | + | ||
44 | + </ui:define> | ||
45 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + <p>Focus should be placed on first radio : | ||
23 | + <ul> | ||
24 | + <li>username gets priority 9999</li> | ||
25 | + <li>email gets default priority 1</li> | ||
26 | + </ul> | ||
27 | + </p> | ||
28 | + <h:form> | ||
29 | + <h:panelGrid columns="3"> | ||
30 | + | ||
31 | + <h:outputLabel value="Username" for="username"/> | ||
32 | + <h:inputText value="#{username}" id="username" required="true"> | ||
33 | + <sand:focus priority="9999"/> | ||
34 | + </h:inputText> | ||
35 | + <h:message for="username"/> | ||
36 | + | ||
37 | + <h:outputLabel value="Option" for="option"/> | ||
38 | + <h:selectOneRadio value="#{option}" id="option" required="true"> | ||
39 | + <f:selectItem itemLabel="Option 1" itemValue="1"/> | ||
40 | + <f:selectItem itemLabel="Option 2" itemValue="2"/> | ||
41 | + <f:selectItem itemLabel="Option 3" itemValue="3"/> | ||
42 | + <sand:focus suffix=":0"/> | ||
43 | + </h:selectOneRadio> | ||
44 | + <h:message for="option"/> | ||
45 | + | ||
46 | + </h:panelGrid> | ||
47 | + <h:commandButton value="Submit"/> | ||
48 | + </h:form> | ||
49 | + | ||
50 | + <rich:insert src="#{request.contextPath}/pages/focus/focus_2.xhtml" highlight="html"/> | ||
51 | + </ui:define> | ||
52 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + <p>Focus should be placed on username : | ||
23 | + <ul> | ||
24 | + <li>username gets default priority 0</li> | ||
25 | + <li>email gets priority 1</li> | ||
26 | + </ul> | ||
27 | + </p> | ||
28 | + <h:form> | ||
29 | + <h:panelGrid columns="3"> | ||
30 | + <h:outputLabel value="Username" for="username"/> | ||
31 | + <h:inputText value="#{username}" id="username" required="true"> | ||
32 | + <sand:focus/> | ||
33 | + </h:inputText> | ||
34 | + <h:message for="username"/> | ||
35 | + | ||
36 | + <h:outputLabel value="Email" for="email"/> | ||
37 | + <h:inputText value="#{email}" id="email" required="true"/> | ||
38 | + <h:message for="email"/> | ||
39 | + </h:panelGrid> | ||
40 | + <h:commandButton value="Submit"/> | ||
41 | + <sand:focus for="email"/> | ||
42 | + </h:form> | ||
43 | + | ||
44 | + <rich:insert src="/focus_3.xhtml" highlight="html"/> | ||
45 | + | ||
46 | + </ui:define> | ||
47 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + | ||
23 | + <p>This example shows that focus can be put on non JSF control</p> | ||
24 | + <h:panelGrid columns="3"> | ||
25 | + <h:outputLabel value="Non JSF control" for="option"/> | ||
26 | + <input type="radio" id="option_1" name="option"/> 1 | ||
27 | + <input type="radio" id="option_2" name="option"/> 2 | ||
28 | + </h:panelGrid> | ||
29 | + <sand:focus targetClientId="option_2"/> | ||
30 | + | ||
31 | + <rich:insert src="/focus_4.xhtml" highlight="html"/> | ||
32 | + </ui:define> | ||
33 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + <p>On initial request focus should be placed on username. This is because direct parent of | ||
23 | + focus component is not UIInput. | ||
24 | + In such situation focus is put on first UIInput in parent form. | ||
25 | + Please not that focus component is not direct child of form. | ||
26 | + This sample is to ensure you that UIInput is not searched | ||
27 | + within direct parent of focus component, but within nesting form. | ||
28 | + </p> | ||
29 | + <ul> | ||
30 | + <li>username gets default priority 0</li> | ||
31 | + <li>email gets priority 1</li> | ||
32 | + </ul> | ||
33 | + <p>On form submit, when username is valid and email is invalid, focus | ||
34 | + should be placed on email. | ||
35 | + </p> | ||
36 | + | ||
37 | + <p>On form submit, when all fields are valid, focus | ||
38 | + should be placed on username. | ||
39 | + </p> | ||
40 | + <h:form> | ||
41 | + <h:panelGrid columns="3"> | ||
42 | + <h:outputLabel value="Username" for="username"/> | ||
43 | + <h:inputText value="#{username}" id="username" required="true"/> | ||
44 | + <h:message for="username"/> | ||
45 | + </h:panelGrid> | ||
46 | + <h:panelGrid columns="3"> | ||
47 | + <h:outputLabel value="Email" for="email"/> | ||
48 | + <h:inputText value="#{email}" id="email" required="true"/> | ||
49 | + <h:message for="email"/> | ||
50 | + <sand:focus/> | ||
51 | + </h:panelGrid> | ||
52 | + <h:commandButton value="Submit"/> | ||
53 | + </h:form> | ||
54 | + | ||
55 | + <rich:insert src="/focus_5.xhtml" highlight="html"/> | ||
56 | + | ||
57 | + </ui:define> | ||
58 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + | ||
23 | + | ||
24 | + <p> | ||
25 | + Some components like h:selectOneRadio render elements that have identifiers matching component's clientId+suffix. | ||
26 | + This might be a pain if we want to have single "focus" component inside form, but be able to focus any type of the invalid | ||
27 | + components. | ||
28 | + That's what focusModifier component is for. | ||
29 | + Some components cause even grater pain cause you cannot nest anything inside (rich:calendar). | ||
30 | + To cope with this put focusModifier inside "focusModifier" facet. </p> | ||
31 | + <h:form> | ||
32 | + <sand:focus/> | ||
33 | + <h:panelGrid columns="3"> | ||
34 | + <h:outputLabel value="Option" for="option"/> | ||
35 | + <h:selectOneRadio value="#{option}" id="option" required="true"> | ||
36 | + <f:selectItem itemLabel="Option 1" itemValue="1"/> | ||
37 | + <f:selectItem itemLabel="Option 2" itemValue="2"/> | ||
38 | + <f:selectItem itemLabel="Option 3" itemValue="3"/> | ||
39 | + <sand:focusModifier suffix=":2"/> | ||
40 | + </h:selectOneRadio> | ||
41 | + <h:message for="option"/> | ||
42 | + | ||
43 | + <h:outputLabel value="Email" for="email"/> | ||
44 | + <h:inputText value="#{email}" id="email" required="true"/> | ||
45 | + <h:message for="email"/> | ||
46 | + <h:outputLabel value="Date" for="date"/> | ||
47 | + <rich:calendar value="#{date}" id="date" enableManualInput="true" required="true"> | ||
48 | + <f:facet name="focusModifier"> | ||
49 | + <sand:focusModifier suffix="InputDate"/> | ||
50 | + </f:facet> | ||
51 | + </rich:calendar> | ||
52 | + <h:message for="date"/> | ||
53 | + </h:panelGrid> | ||
54 | + <h:commandButton value="submit"/> | ||
55 | + </h:form> | ||
56 | + | ||
57 | + <rich:insert src="/focus_7.xhtml" highlight="html"/> | ||
58 | + | ||
59 | + | ||
60 | + </ui:define> | ||
61 | +</ui:composition> |
1 | +<?xml version='1.0' encoding='UTF-8' ?> | ||
2 | +<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | +<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
4 | + xmlns:ui="http://java.sun.com/jsf/facelets" | ||
5 | + xmlns:f="http://java.sun.com/jsf/core" | ||
6 | + xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:a4j="http://richfaces.org/a4j" | ||
9 | + xmlns:rich="http://richfaces.org/rich" | ||
10 | + template="./../../template.xhtml"> | ||
11 | + | ||
12 | + <ui:define name="htmlHead"> | ||
13 | + <title>Focus sample</title> | ||
14 | + </ui:define> | ||
15 | + | ||
16 | + <ui:define name="header"> | ||
17 | + <ui:include src="menu.xhtml"/> | ||
18 | + </ui:define> | ||
19 | + | ||
20 | + <ui:define name="content"> | ||
21 | + | ||
22 | + | ||
23 | + <p> | ||
24 | + Focus is placed on control withing modal panel. Modal panel is rendered before it is shown, thus | ||
25 | + javascript that sets focus should not be invoked at that moment. | ||
26 | + To cope with that focus component has "timing" attribute which, when valued to "onJScall" | ||
27 | + allows setting focus later whenever user wishes. When "timing" is set to "onJScall" then "name" attribute | ||
28 | + must be also specified. It is name of JavaScript function that will be generated and can be called by user | ||
29 | + to set focus in any moment. | ||
30 | + In this example we put onshow="focusTheForm();" in modal panel which causes | ||
31 | + focus to be placed after the modal is visible. | ||
32 | + Notice that "name" attribute of focuse component is equal to "focusTheForm". | ||
33 | + </p> | ||
34 | + <h:form> | ||
35 | + <h:commandButton value="Show modal"> | ||
36 | + <rich:componentControl for="panel" event="onclick" operation="show" disableDefault="true"/> | ||
37 | + </h:commandButton> | ||
38 | + </h:form> | ||
39 | + <rich:modalPanel id="panel" autosized="true" onshow="focusTheForm();"> | ||
40 | + <h:form id="theForm"> | ||
41 | + <sand:focus name="focusTheForm" timing="onJScall"/> | ||
42 | + <h:panelGrid columns="3"> | ||
43 | + <h:outputLabel value="Username" for="username"/> | ||
44 | + <h:inputText value="#{username}" id="username" required="true"/> | ||
45 | + <h:message for="username"/> | ||
46 | + <h:outputLabel value="Email" for="email"/> | ||
47 | + <h:inputText value="#{email}" id="email" required="true"/> | ||
48 | + <h:message for="email"/> | ||
49 | + </h:panelGrid> | ||
50 | + <a4j:commandButton value="Submit" reRender="theForm" oncomplete="Richfaces.FocusManager.focus();"/> | ||
51 | + <h:commandButton value="Close"> | ||
52 | + <rich:componentControl for="panel" event="onclick" operation="hide" disableDefault="true"/> | ||
53 | + </h:commandButton> | ||
54 | + </h:form> | ||
55 | + </rich:modalPanel> | ||
56 | + | ||
57 | + <rich:insert src="/focus_6.xhtml" highlight="html"/> | ||
58 | + | ||
59 | + </ui:define> | ||
60 | +</ui:composition> |
1 | +<ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" | ||
2 | + xmlns:h="http://java.sun.com/jsf/html"> | ||
3 | + <div> | ||
4 | + <ul> | ||
5 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_1.jsf">Example 1</h:outputLink></li> | ||
6 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_2.jsf">Example 2</h:outputLink></li> | ||
7 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_3.jsf">Example 3</h:outputLink></li> | ||
8 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_4.jsf">Example 4</h:outputLink></li> | ||
9 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_5.jsf">Example 5</h:outputLink></li> | ||
10 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_6.jsf">Example 6</h:outputLink></li> | ||
11 | + <li><h:outputLink value="#{request.contextPath}/pages/focus/focus_7.jsf">Example 7</h:outputLink></li> | ||
12 | + </ul> | ||
13 | + </div> | ||
14 | +</ui:component> |
1 | +@CHARSET "UTF-8"; | ||
2 | +html, body, div, span, applet, object, iframe, | ||
3 | +h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
4 | +a, abbr, acronym, address, big, cite, code, | ||
5 | +del, dfn, em, img, ins, kbd, q, s, samp, | ||
6 | +small, strike, strong, sub, sup, tt, var, | ||
7 | +b, u, i, center, | ||
8 | +dl, dt, dd, ol, ul, li, | ||
9 | +fieldset, form, label, legend, | ||
10 | +table, caption, tbody, tfoot, thead, tr, th, td, | ||
11 | +article, aside, canvas, details, embed, | ||
12 | +figure, figcaption, footer, header, hgroup, | ||
13 | +menu, nav, output, ruby, section, summary, | ||
14 | +time, mark, audio, video { | ||
15 | + margin: 0; | ||
16 | + padding: 0; | ||
17 | + border: 0; | ||
18 | + font-size: 100%; | ||
19 | + font: inherit; | ||
20 | + vertical-align: baseline; | ||
21 | +} | ||
22 | +/* HTML5 display-role reset for older browsers */ | ||
23 | +article, aside, details, figcaption, figure, | ||
24 | +footer, header, hgroup, menu, nav, section { | ||
25 | + display: block; | ||
26 | +} | ||
27 | +body { | ||
28 | + line-height: 1; | ||
29 | +} | ||
30 | +ol, ul { | ||
31 | + list-style: none; | ||
32 | +} | ||
33 | +blockquote, q { | ||
34 | + quotes: none; | ||
35 | +} | ||
36 | +blockquote:before, blockquote:after, | ||
37 | +q:before, q:after { | ||
38 | + content: ''; | ||
39 | + content: none; | ||
40 | +} | ||
41 | +table { | ||
42 | + border-collapse: collapse; | ||
43 | + border-spacing: 0; | ||
44 | +} |
showcase/src/main/webapp/template.xhtml
0 → 100644
1 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
2 | + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
3 | + | ||
4 | +<html xmlns="http://www.w3.org/1999/xhtml" | ||
5 | +xmlns:ui="http://java.sun.com/jsf/facelets" | ||
6 | +xmlns:h="http://java.sun.com/jsf/html" | ||
7 | + xmlns:sand="http://richfaces.org/sandbox" | ||
8 | + xmlns:f="http://java.sun.com/jsf/core"> | ||
9 | + | ||
10 | + | ||
11 | +<head> | ||
12 | + <title>Sandbox samples</title> | ||
13 | + <link rel="stylesheet" type="text/css" href="#{request.contextPath}/resources/css/reset.css" /> | ||
14 | + <link rel="stylesheet" type="text/css" href="#{request.contextPath}/resources/css/main.css" /> | ||
15 | + <ui:insert name="htmlHead"></ui:insert> | ||
16 | +</head> | ||
17 | + | ||
18 | +<body> | ||
19 | + <div id="pageWrapper"> | ||
20 | + <div> | ||
21 | + <ui:insert name="header" /> | ||
22 | + </div> | ||
23 | + <div> | ||
24 | + <ui:insert name="content" /> | ||
25 | + </div> | ||
26 | + <div> | ||
27 | + <ui:insert name="footer" /> | ||
28 | + </div> | ||
29 | + </div> | ||
30 | +</body> | ||
31 | +</html> |
Please
register
or
login
to post a comment