View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.component.session;
23  
24  import javax.faces.application.ResourceDependency;
25  import javax.faces.component.FacesComponent;
26  import javax.faces.component.UIComponentBase;
27  
28  import org.primefaces.component.api.Widget;
29  
30  /**
31   * <code>Session</code> component.
32   *
33   * @author Frank Cornelis
34   * @since 12.0.4
35   */
36  @FacesComponent(Session.COMPONENT_TYPE)
37  @ResourceDependency(library = "javax.faces", name = "jsf.js")
38  @ResourceDependency(library = "primefaces", name = "jquery/jquery.js")
39  @ResourceDependency(library = "primefaces", name = "jquery/jquery-plugins.js")
40  @ResourceDependency(library = "primefaces", name = "core.js")
41  @ResourceDependency(library = "primefaces-extensions", name = "session/session.js")
42  public class Session extends UIComponentBase implements Widget {
43  
44      public static final String COMPONENT_TYPE = "org.primefaces.extensions.component.Session";
45  
46      public static final String COMPONENT_FAMILY = "org.primefaces.extensions.component";
47  
48      @Override
49      public String getFamily() {
50          return COMPONENT_FAMILY;
51      }
52  
53      enum PropertyKeys {
54          onexpire, onexpired, reactionPeriod, multiWindowSupport
55      }
56  
57      public String getOnexpire() {
58          return (String) getStateHelper().eval(PropertyKeys.onexpire);
59      }
60  
61      public void setOnexpire(String onexpire) {
62          getStateHelper().put(PropertyKeys.onexpire, onexpire);
63      }
64  
65      public String getOnexpired() {
66          return (String) getStateHelper().eval(PropertyKeys.onexpired);
67      }
68  
69      public void setOnexpired(String onexpired) {
70          getStateHelper().put(PropertyKeys.onexpired, onexpired);
71      }
72  
73      public Integer getReactionPeriod() {
74          return (Integer) getStateHelper().eval(PropertyKeys.reactionPeriod);
75      }
76  
77      public void setReactionPeriod(Integer reactionPeriod) {
78          getStateHelper().put(PropertyKeys.reactionPeriod, reactionPeriod);
79      }
80  
81      public boolean isMultiWindowSupport() {
82          return (Boolean) getStateHelper().eval(PropertyKeys.multiWindowSupport, true);
83      }
84  
85      public void setMultiWindowSupport(boolean multiWindowSupport) {
86          getStateHelper().put(PropertyKeys.multiWindowSupport, multiWindowSupport);
87      }
88  
89  }