View Javadoc

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.trinidad.event;
20  
21  import java.util.List;
22  
23  import javax.faces.component.UIComponent;
24  import javax.faces.event.FacesEvent;
25  import javax.faces.event.FacesListener;
26  
27  import org.apache.myfaces.trinidad.model.SortCriterion;
28  
29  /**
30   * The Event generated when a Collection is to be sorted.
31   */
32  public final class SortEvent extends FacesEvent
33  {
34    /**
35     * Creates a new SortEvent.
36     * @param criteria each element must be of type SortCriterion
37     * @see org.apache.myfaces.trinidad.model.SortCriterion
38     */
39    public SortEvent(UIComponent source, List<SortCriterion> criteria)
40    {
41      super(source);
42      _criteria = criteria;
43    }
44  
45    /**
46     * Each element of this List is of type SortCriterion
47     * @see org.apache.myfaces.trinidad.model.SortCriterion
48     */
49    public List<SortCriterion> getSortCriteria()
50    {
51      return _criteria;
52    }
53  
54    @Override
55    public boolean isAppropriateListener(FacesListener listener)
56    {
57      return (listener instanceof SortListener);
58    }
59  
60    @Override
61    public void processListener(FacesListener listener)
62    {
63      ((SortListener) listener).processSort(this);
64    }
65    
66    
67    private final List<SortCriterion> _criteria;
68  
69    private static final long serialVersionUID = 1L;
70  }