1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.primefaces.extensions.component.creditcard;
23
24 import javax.faces.application.ResourceDependency;
25 import javax.faces.component.UIComponentBase;
26
27 import org.primefaces.component.api.Widget;
28
29
30
31
32
33
34
35 @ResourceDependency(library = "primefaces", name = "components.css")
36 @ResourceDependency(library = "primefaces", name = "jquery/jquery.js")
37 @ResourceDependency(library = "primefaces", name = "jquery/jquery-plugins.js")
38 @ResourceDependency(library = "primefaces", name = "core.js")
39 @ResourceDependency(library = "primefaces-extensions", name = "creditcard/creditcard.css")
40 @ResourceDependency(library = "primefaces-extensions", name = "creditcard/creditcard.js")
41 public class CreditCard extends UIComponentBase implements Widget {
42
43 public static final String COMPONENT_TYPE = "org.primefaces.extensions.component.CreditCard";
44 public static final String COMPONENT_FAMILY = "org.primefaces.extensions.component";
45 public static final String STYLE_CLASS = "ui-credit-card ";
46
47 private static final String DEFAULT_RENDERER = "org.primefaces.extensions.component.CreditCardRenderer";
48
49 @SuppressWarnings("java:S115")
50 protected enum PropertyKeys {
51
52
53 widgetVar,
54 width,
55 formatting,
56 labelValidDate,
57 labelMonthYear,
58 placeholderNumber,
59 placeholderName,
60 placeholderExpiry,
61 placeholderCvc
62
63 }
64
65
66
67
68 public CreditCard() {
69 setRendererType(DEFAULT_RENDERER);
70 }
71
72
73
74
75 @Override
76 public String getFamily() {
77 return COMPONENT_FAMILY;
78 }
79
80 public String getWidgetVar() {
81 return (String) getStateHelper().eval(PropertyKeys.widgetVar, null);
82 }
83
84 public void setWidgetVar(final String _widgetVar) {
85 getStateHelper().put(PropertyKeys.widgetVar, _widgetVar);
86 }
87
88 public int getWidth() {
89 return (Integer) getStateHelper().eval(PropertyKeys.width, 350);
90 }
91
92 public void setWidth(final int _width) {
93 getStateHelper().put(PropertyKeys.width, _width);
94 }
95
96 public boolean isFormatting() {
97 return (Boolean) getStateHelper().eval(PropertyKeys.formatting, true);
98 }
99
100 public void setFromatting(final boolean _formatting) {
101 getStateHelper().put(PropertyKeys.formatting, _formatting);
102 }
103
104 public String getLabelValidDate() {
105 return (String) getStateHelper().eval(PropertyKeys.labelValidDate, "valid\\nthru");
106 }
107
108 public void setLabelValidDate(final String _labelValidDate) {
109 getStateHelper().put(PropertyKeys.labelValidDate, _labelValidDate);
110 }
111
112 public String getLabelMonthYear() {
113 return (String) getStateHelper().eval(PropertyKeys.labelMonthYear, "month/year");
114 }
115
116 public void setLabelMonthYear(final String _labelMonthYear) {
117 getStateHelper().put(PropertyKeys.labelMonthYear, _labelMonthYear);
118 }
119
120 public String getPlaceholderNumber() {
121 return (String) getStateHelper().eval(PropertyKeys.placeholderNumber, null);
122 }
123
124 public void setPlaceholderNumber(final String _placeholderNumber) {
125 getStateHelper().put(PropertyKeys.placeholderNumber, _placeholderNumber);
126 }
127
128 public String getPlaceholderName() {
129 return (String) getStateHelper().eval(PropertyKeys.placeholderName, "Full Name");
130 }
131
132 public void setPlaceholderName(final String _placeholderName) {
133 getStateHelper().put(PropertyKeys.placeholderName, _placeholderName);
134 }
135
136 public String getPlaceholderExpiry() {
137 return (String) getStateHelper().eval(PropertyKeys.placeholderExpiry, null);
138 }
139
140 public void setPlaceholderExpiry(final String _placeholderExpiry) {
141 getStateHelper().put(PropertyKeys.placeholderExpiry, _placeholderExpiry);
142 }
143
144 public String getPlaceholderCvc() {
145 return (String) getStateHelper().eval(PropertyKeys.placeholderCvc, null);
146 }
147
148 public void setPlaceholderCvc(final String _placeholderCvc) {
149 getStateHelper().put(PropertyKeys.placeholderCvc, _placeholderCvc);
150 }
151 }