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.custom.statechangednotifier;
20  
21  
22  
23  /**
24   * A component that listens to changes in the components
25   * 
26   * Shows a confirmation window if some of the input fields of the form have changed its value
27   * 
28   * @JSFComponent
29   *   name = "s:stateChangedNotifier"
30   *   class = "org.apache.myfaces.custom.statechangednotifier.StateChangedNotifier"
31   *   tagClass = "org.apache.myfaces.custom.statechangednotifier.StateChangedNotifierTag"
32   *   
33   * @author Bruno Aranda (latest modification by $Author: lu4242 $)
34   * @version $Revision: 663481 $ $Date: 2008-06-05 02:00:34 -0500 (Thu, 05 Jun 2008) $
35   */
36  public abstract class AbstractStateChangedNotifier extends javax.faces.component.html.HtmlInputHidden {
37      
38      public static final String COMPONENT_TYPE        = "org.apache.myfaces.StateChangedNotifier";
39      public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.StateChangedNotifierRenderer";
40  
41      private static final String DEFAULT_MESSAGE = "Are you sure?";
42  
43      /**
44       * enable the state changed notification for this cycle
45       *
46       */
47      public void enableStateChanged() {
48          super.setValue("true");
49      }
50  
51      /**
52       * Confirmation message to show if something in the form has changed
53       * 
54       * @JSFProperty
55       *   defaultValue="Are you sure?"
56       */
57      public abstract String getConfirmationMessage();
58  
59      /**
60       * If disabled, the confirmation window will not be shown
61       * 
62       * @JSFProperty
63       */
64      public abstract Boolean getDisabled();
65  
66      /**
67       * Comma-separated list of cliend id of the commands which will be excluded 
68       * from the confirmation message
69       * 
70       * @JSFProperty
71       */
72      public abstract String getExcludedIds();
73  
74      /**
75       * a helper reset to reset the notifier
76       * to a non state changed state
77       */
78      public void reset() {
79          super.setValue("false");
80      }
81  
82  }