1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.custom.datascroller;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.event.ActionEvent;
23
24 /**
25 * An event representing a click on some scroller control to
26 * change the currently displayed table rows.
27 *
28 * @author Mathias Broekelmann (latest modification by $Author$)
29 * @version $Revision$ $Date$
30 */
31 public class ScrollerActionEvent extends ActionEvent
32 {
33 private static final long serialVersionUID = -5692343289423906802L;
34
35 private final String mScrollerfacet;
36
37 private final int mPageIndex;
38
39 /**
40 * An event representing a user's choice of navigation option
41 * <i>except</i> jumping to a specific page.
42 * <o>
43 * Param scrollerFacet contains the name of the operation performed,
44 * which matches one of the public HtmlDataScroller.FACET_* constants.
45 */
46 public ScrollerActionEvent(UIComponent component, String scrollerfacet)
47 {
48 super(component);
49 mScrollerfacet = scrollerfacet;
50 mPageIndex = -1;
51 }
52
53 /**
54 * An event representing a user's choice to jump straight to page
55 * #pageIndex of the available pages of data.
56 *
57 * @param component is the DataScroller component
58 * @param pageIndex is in the range 0..(nPages-1), where nPages
59 * is (rowsOfDataAvailable/rowsPerPage).
60 */
61 public ScrollerActionEvent(UIComponent component, int pageIndex)
62 {
63 super(component);
64 if (pageIndex < 0)
65 {
66 throw new IllegalArgumentException("wrong pageindex");
67 }
68 mPageIndex = pageIndex;
69 mScrollerfacet = null;
70 }
71
72 /**
73 * Returns a string which matches one of the HtmlDataScroller.FACET_*
74 * public constants, or null if the user chose a page# navigation option.
75 */
76 public String getScrollerfacet()
77 {
78 return mScrollerfacet;
79 }
80
81 /**
82 * Return the page of data the user wants to see, or -1 if the
83 * user didn't choose a page# navigation option.
84 */
85 public int getPageIndex()
86 {
87 return mPageIndex;
88 }
89 }