-
-
2. Re: server side validation
wingman Jan 26, 2013 6:16 AM (in response to iabughosh)Hi Ibrahim thanks for the reply, but i am looking for server side validation not client side
in briefly
when text entered into input box i want to display error message if that value alrdy present in db.
just like rich:validator does at client side.
-
3. Re: server side validation
iabughosh Jan 26, 2013 6:48 AM (in response to wingman)i think rich:graphValidator could solve your problem.
-
4. Re: server side validation
just-greg Jan 30, 2013 5:39 PM (in response to wingman)What you are actually asking for (I THINK) is called bean validation.
Just for clarity, the graphValidator is for whole object validation....
For single value you want to use either the rich:validator or for bean validation just have it trigger an ajax event.
ex:
{code:xml}
<h:inputText
style="max-width:150px;text-align:left;min-width:150px;width:150px;"
id="constLCompareId"
value="#{tb.compareValue}">
<a4j:ajax limitRender="true" immediate="true"
render="@this lCondMsgGroupId" event="change"
execute="@this" />
</h:inputText>
<rich:messages id="lCondMsgGroupId" ajaxRendered="true" for="constLCompareId"
></rich:messages>
{code}
where the value is annotated in the backing bean along the lines of:
{code}
@NotNull( message = "The compare value MUST be set!" )
@Size( min = 1, max = 50,
message = "Length must be between 1 and 50" )
private String compareValue ;
{code}
Some references are available at:
(Note, don't try to combine a validator on an input that you trigger ajax for...the ajax automatically will trigger any bean validations).
http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/validator-usingvalidator.html
http://ojitha.blogspot.com/2010/12/jsf-bean-validation-jsr-303-quick.html
And probably you should look at BalusC's blog... he has an article that touches on it...along with a whole lot of other fun stuff!
http://balusc.blogspot.com/2011/01/jsf-20-tutorial-with-eclipse-and.html
Good luck!
- Greg C