public class RelationalValidator extends AbstractValidator implements Serializable
<h:outputLabel value="Left:"/>
<jh:InputText id="idLeftString" value="#{relationalValidatorTestBean.leftString}" label="Left:"/>
<h:outputLabel value="Right:"/>
<jh:InputText id="idRightString" value="#{relationalValidatorTestBean.rightString}" label="Right">
<jf:relationalValidator
for="idInputText"
leftValue="#{relationalValidatorTestBean.leftString}"
relationalOperator="EQUAL" />
</jh:InputText>
Note: Both left and right values must be of the same type and be Comparable
.Constructor and Description |
---|
RelationalValidator() |
Modifier and Type | Method and Description |
---|---|
Object |
getLeftValue()
Gets the value of the left operand.
|
RelationalValidationOperator |
getRelationalOperator()
Gets the relational operator.
|
void |
restoreState(javax.faces.context.FacesContext facesContext,
Object state)
Restores the state saved by
saveState(FacesContext) . |
Object |
saveState(javax.faces.context.FacesContext facesContext)
Saves the state of this validator.
|
void |
setLeftValue(Object leftValue)
Sets the value of the left operand.
|
void |
setRelationalOperator(RelationalValidationOperator relationalValidationOperator)
Sets the relational operator.
|
void |
validate(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent rightComponent,
Object rightValue)
Validates two values using a relational operator.
|
getFormattedErrorMessage, getMessage, hasMessage, isComponentOfTypeUIInput, setMessage
isTransient, setTransient
public Object getLeftValue()
public void setLeftValue(Object leftValue)
leftValue
- The value of the left operand.public RelationalValidationOperator getRelationalOperator()
public void setRelationalOperator(RelationalValidationOperator relationalValidationOperator)
relationalValidationOperator
- The relational operator.public void validate(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent rightComponent, Object rightValue)
validate
in interface javax.faces.validator.Validator
facesContext
- The FacesContext.rightComponent
- The component at the right of the relational operator.rightValue
- The value of the right operand.javax.faces.validator.ValidatorException
- When the two values are not valid with respect to the relational operator.public Object saveState(javax.faces.context.FacesContext facesContext)
saveState
in interface javax.faces.component.StateHolder
saveState
in class AbstractValidator
facesContext
- The FacesContext.public void restoreState(javax.faces.context.FacesContext facesContext, Object state)
saveState(FacesContext)
.
restoreState
in interface javax.faces.component.StateHolder
restoreState
in class AbstractValidator
facesContext
- The FacesContext.state
- The state saved by saveState(FacesContext)
.Copyright © 2008–2018. All rights reserved.