|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.Field org.apache.click.control.TextField org.apache.click.extras.control.CreditCardField
public class CreditCardField
Provides a Credit Card control: <input type='text'><select>.
Credit Card |
<html> <head> $headElements </head> <body> $form $jsElements </body> </html>An example page using CreditCardField is provided below:
public class PaymentPage extends Page { private Form form = new Form("form"); private CreditCardField creditCardField = new CreditCardField("creditCard", true); private IntegerField expiryField = new IntegerField("expiryDate", true); public PaymentPage() { form.add(creditCardField); expiryField.setMinLength(4); expiryField.setMaxLength(4); expiryField.setSize(4); form.add(expiryField); form.add(new Submit("ok", " OK ")); form.add(new Submit("cancel", this, "onCancelClick")); addControl(form); } public boolean onCancelClick() { setRedirect("index.htm"); return false; } public void onPost() { if (form.isValid()) { String cardType = creditCardField.getCardType(); Long cardNumber = creditCardField.getCardNumber(); String expiryDate = expiryField.getInteger(); // Make payment .. } } }See also W3C HTML reference INPUT
Field Summary | |
---|---|
static String |
AMEX
The American Express type credit card: "AMEX". |
protected static List<Option> |
CARD_OPTIONS
The statically initialized card type options list. |
protected String |
cardType
The type of credit card: ["VISA" | "MASTER" | "AMEX" | "DINERS" | "DISCOVER"]. |
protected Select |
cardTypeSelect
The card type Select. |
static String |
DINERS
The Diners Club type credit card: "DINERS". |
static String |
DISCOVER
The Discovery type credit card: "DISCOVER". |
static String |
MASTER
The MasterCard type credit card: "MASTER". |
protected static String |
SELECT_NAME
The card type Select name. |
protected static String |
VALIDATE_CREDITCARD_FUNCTION
The field validation JavaScript function template. |
static String |
VISA
The Visa type credit card: "VISA". |
Fields inherited from class org.apache.click.control.TextField |
---|
maxLength, minLength, size, VALIDATE_TEXTFIELD_FUNCTION |
Fields inherited from class org.apache.click.control.Field |
---|
disabled, error, focus, form, help, label, labelStyle, labelStyleClass, parentStyleClassHint, parentStyleHint, readonly, required, tabindex, title, trim, validate, value |
Fields inherited from class org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.click.Control |
---|
CONTROL_MESSAGES |
Constructor Summary | |
---|---|
CreditCardField()
Create a credit card field with no name defined. |
|
CreditCardField(String name)
Construct the credit card field with the given name. |
|
CreditCardField(String name,
boolean required)
Construct the credit card field with the given name and required status. |
|
CreditCardField(String name,
String label)
Construct the credit card field with the given name and label. |
|
CreditCardField(String name,
String label,
boolean required)
Construct the credit card field with the given name, label and required status. |
|
CreditCardField(String name,
String label,
int size)
Construct a CreditCardField with the given name, label and size. |
|
CreditCardField(String name,
String label,
int size,
boolean required)
Construct the CreditCardField with the given name, label, size and required status. |
Method Summary | |
---|---|
void |
bindRequestValue()
Bind the request submission, setting the value property and cardType property if defined in the request. |
Long |
getCardNumber()
Return the Credit Card number. |
String |
getCardType()
Return the selected Credit Card type: [ "VISA" | "MASTER" | "AMEX" | "DINERS" | "DISCOVER" ]. |
int |
getControlSizeEst()
|
List<Element> |
getHeadElements()
Returns the CreditCardField HTML head imports statements for the click/extras-control.js resource. |
String |
getValidationJavaScript()
Return the field JavaScript client side validation function. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the CreditCardField. |
void |
validate()
Validate the CreditCardField request submission, using the card type to validate the card number. |
Methods inherited from class org.apache.click.control.TextField |
---|
getMaxLength, getMinLength, getSize, getTag, getType, setMaxLength, setMinLength, setSize |
Methods inherited from class org.apache.click.control.Field |
---|
getError, getErrorLabel, getFocus, getFocusJavaScript, getForm, getHelp, getId, getLabel, getLabelStyle, getLabelStyleClass, getParentStyleClassHint, getParentStyleHint, getRequestValue, getState, getTabIndex, getTextAlign, getTitle, getValidate, getValue, getValueObject, getWidth, isDisabled, isHidden, isReadonly, isRequired, isTrim, isValid, onProcess, removeState, renderTagBegin, restoreState, saveState, setDisabled, setError, setErrorMessage, setErrorMessage, setFocus, setForm, setHelp, setLabel, setLabelStyle, setLabelStyleClass, setListener, setParent, setParentStyleClassHint, setParentStyleHint, setReadonly, setRequired, setState, setTabIndex, setTextAlign, setTitle, setTrim, setValidate, setValue, setValueObject, setWidth |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, isAjaxTarget, onDeploy, onDestroy, onInit, onRender, removeBehavior, removeStyleClass, renderTagEnd, setActionListener, setAttribute, setId, setName, setStyle, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String VISA
public static final String MASTER
public static final String AMEX
public static final String DINERS
public static final String DISCOVER
protected static final List<Option> CARD_OPTIONS
protected static final String SELECT_NAME
protected static final String VALIDATE_CREDITCARD_FUNCTION
protected String cardType
protected Select cardTypeSelect
Constructor Detail |
---|
public CreditCardField(String name)
name
- the name of the fieldpublic CreditCardField(String name, String label)
name
- the name of the fieldlabel
- the label of the fieldpublic CreditCardField(String name, boolean required)
name
- the name of the fieldrequired
- the field required statuspublic CreditCardField(String name, String label, boolean required)
name
- the name of the fieldlabel
- the label of the fieldrequired
- the field required statuspublic CreditCardField(String name, String label, int size)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldpublic CreditCardField(String name, String label, int size, boolean required)
name
- the name of the fieldlabel
- the label of the fieldsize
- the size of the fieldrequired
- the field required statuspublic CreditCardField()
Method Detail |
---|
public String getCardType()
public Long getCardNumber()
public List<Element> getHeadElements()
getHeadElements
in interface Control
getHeadElements
in class AbstractControl
Control.getHeadElements()
public void bindRequestValue()
cardType
property if defined in the request.
bindRequestValue
in class Field
public int getControlSizeEst()
getControlSizeEst
in class TextField
AbstractControl.getControlSizeEst()
public void render(HtmlStringBuffer buffer)
render
in interface Control
render
in class TextField
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
public String getValidationJavaScript()
getValidationJavaScript
in class TextField
public void validate()
- /click-control.properties
- field-maxlength-error
- field-minlength-error
- field-required-error
- /org/apache/click/extras/control/CreditCardField.properties
- creditcard-number-error
validate
in class TextField
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |