public class FormElement extends BodyTagSupport
<appNG:formElement>
is used as a wrapper for standard HTML form input fields, which are
<input>
<textarea>
<select>
<option>
true
if the field is mandatory<span>
with the error message<appNG:formElement errorClass="error" rule="email" mandatory="true" errorElementId="emailError" mandatoryMessage="E-mail is mandatory!" errorMessage="Not a valid e-mail!"> <input type="text" name="email" value=""/> <div id="emailError"></div> </appNG:formElement>Output (no value given):
<input class="error" type="text" name="email" value=""/> <div id="emailError"><span>E-mail is mandatory!</span></div>Output (invalid value given):
<input class="error" type="text" name="email" value=""/> <div id="emailError"><span>Not a valid e-mail!</span></div>Rules:
rule
attribute
name | description | example |
---|---|---|
string | only word characters ([a-zA-Z_0-9] allowed) | rule="string" |
must be a valid email address | rule="email" |
|
equals | must be equal to another field or value | rule="equals('foo') rule="equals(anotherfield) " |
regExp | must match the given regular expression | rule="regExp('[A-F0-9]+')" |
number | must be a number | rule="number" |
numberFractionDigits | must be a number with up to x digits, and y fractional digits | rule="number(2,4)" |
size | must have an exact length of x | rule="size(3)" |
sizeMin | must have a minimum length of x | rule="sizeMin(3)" |
sizeMax | must have a maximum length of x | rule="sizeMax(3)" |
sizeMinMax | must have a minimum length of x and a maximum length of y | rule="sizeMinMax(3,5)" |
fileType | must have one of the comma-separated types ( <input type="file"> only) |
rule="fileType('tif,pdf')" |
fileSizeMin | must have a minimum size of x MB/KB ( <input type="file"> only) |
rule="fileSizeMin('0.5MB')" |
fileSizeMax | must have a maximum size of x MB/KB ( <input type="file"> only) |
rule="fileSizeMax('5.0MB')" |
fileSize | must have a size between x and y MB/KB ( <input type="file"> only) |
rule="fileSize('500KB','5.0MB')" |
fileCount | between x and y files must have been selected ( <input type="file" multiple="true"> only) |
rule="fileCount(1,10)" |
fileCountMin | at least x files must have been selected ( <input type="file" multiple="true"> only) |
rule="fileCountMin(5)" |
fileCountMax | at most x files must have been selected ( <input type="file" multiple="true"> only) |
rule="fileCountMax(5)" |
captcha | Must match a captcha value. The result of the captcha is stored in the variable SESSION['SESSION']['captcha'], where the first SESSION means the HTTP Session, ['SESSION'] the name of an attribute within the HTTP session. Since this attribute is also a map, you can use ['captcha'] to retrieve the result. |
rule="captcha(SESSION['SESSION']['captcha']) |
Modifier and Type | Field and Description |
---|---|
protected FormElement |
wrappedFormElement |
bodyContent
id, pageContext
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
EVAL_BODY_AGAIN
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
Constructor and Description |
---|
FormElement() |
Modifier and Type | Method and Description |
---|---|
int |
doAfterBody() |
int |
doEndTag() |
int |
doStartTag() |
String |
getContent() |
String |
getDesc() |
String |
getErrorClass() |
String |
getErrorElementId() |
String |
getErrorMessage() |
FormData |
getFormData() |
FormGroup |
getFormGroup() |
String |
getMandatoryMessage() |
String |
getName() |
String |
getRule() |
protected FormElement |
getWrappedFormElement() |
boolean |
isForwardValidation() |
boolean |
isMandatory() |
String |
processContent() |
void |
release() |
void |
setContent(String content) |
void |
setDesc(String desc) |
void |
setErrorClass(String errorClass) |
void |
setErrorElementId(String errorElementId) |
void |
setErrorMessage(String errorMessage) |
void |
setForwardValidation(boolean forwardValidation) |
void |
setMandatory(boolean mandatory) |
void |
setMandatoryMessage(String mandatoryMessage) |
void |
setName(String name) |
void |
setRule(String rule) |
doInitBody, getBodyContent, getPreviousOut, setBodyContent
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getParent, setPageContext, setParent
protected FormElement wrappedFormElement
public int doStartTag() throws JspException
doStartTag
in interface Tag
doStartTag
in class BodyTagSupport
JspException
public int doEndTag() throws JspException
doEndTag
in interface Tag
doEndTag
in class BodyTagSupport
JspException
public int doAfterBody()
doAfterBody
in interface IterationTag
doAfterBody
in class BodyTagSupport
public String processContent()
public boolean isMandatory()
public void setMandatory(boolean mandatory)
public String getRule()
public void setRule(String rule)
public String getErrorClass()
public void setErrorClass(String errorClass)
public boolean isForwardValidation()
public void setForwardValidation(boolean forwardValidation)
public String getContent()
public void setContent(String content)
public String getName()
public void setName(String name)
public String getErrorMessage()
public void setErrorMessage(String errorMessage)
public String getMandatoryMessage()
public void setMandatoryMessage(String mandatoryMessage)
public String getErrorElementId()
public void setErrorElementId(String errorElementId)
protected FormElement getWrappedFormElement()
public void release()
release
in interface Tag
release
in class BodyTagSupport
public FormData getFormData()
public FormGroup getFormGroup()
public String getDesc()
public void setDesc(String desc)
Copyright © 2011–2017 aiticon GmbH. All rights reserved.