-
1. RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 1, 2011 3:55 AM (in response to m1ckey)you could remove a4j:ajax and move
#{registration.checkName} code to the validator method of the input.
-
2. RichFaces 4 validation, stuff disappears
m1ckey Apr 1, 2011 4:47 AM (in response to ilya_shaikovsky)Hi Ilya, thanks for your quick answer.
Could you please confirm my idea as of what to causes the problem (multiple requests on one field)?
My goal is to have a field (user name) with standard validators on it, but also have additional (custom) validation that will check the uniqueness against the database. Because that may take a while, I'm using a4j:ajax in the first place to be able to provide a4j:status (to have a message/gif indicating that polling is being made). Perhaps there's a way to satisfy those requirements?
Cheers.
-
3. RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 1, 2011 5:03 AM (in response to m1ckey)https://issues.jboss.org/browse/RF-10731
yes.. caused by the fact that currently if there are two submitting behaviors are present - only one is actually called.
-
4. RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 1, 2011 5:04 AM (in response to m1ckey)and if you will use validator as I described status should be triggered also as ajax fallback for validator should be processed by indication components in the same way as a4j:ajax.
-
5. RichFaces 4 validation, stuff disappears
m1ckey Apr 1, 2011 5:06 AM (in response to ilya_shaikovsky)Aha, sweet. I'll try it out then, thanks a lot, mate!
-
6. RichFaces 4 validation, stuff disappears
m1ckey Apr 1, 2011 5:10 AM (in response to ilya_shaikovsky)Ilya Shaikovsky wrote:
you could remove a4j:ajax and move
#{registration.checkName} code to the validator method of the input.
How can I do it though? I.e. how can I have custom validation combined with standard JSR 303 validation per input? I'm looking at http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=graphValidator&skin=blueSky and that doesn't seem to be it, really...
-
7. RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 1, 2011 6:27 AM (in response to m1ckey)I do not mean to use graphValidator. I mean just register f:validator at input or create custom JSR 303 constraint and it's impl. then rich:validator will validate all the default constrains at client side and if them are ok will fire ajax request to perform that validation additionally.
-
8. RichFaces 4 validation, stuff disappears
m1ckey Apr 1, 2011 6:40 AM (in response to ilya_shaikovsky)I thought custom validators were not supported yet for client side? It seems to suggest so here:
-
9. Re: RichFaces 4 validation, stuff disappears
m1ckey Apr 3, 2011 7:46 PM (in response to ilya_shaikovsky)Hi, I tried that but where do I put the status attribute so that it only applies to this field? I tried on the richvalidator itself and on the inputText, but it only works if I DON'T put in anywhere as an attribute.
<h:outputText value="Name:" /> <h:inputText id="name" value="#{registration.name}"> <rich:validator /> </h:inputText> <rich:message for="name" /> <a4j:status id="nameStatus" startText="Checking name..." startStyle="background-color: FFA500" />
-
10. Re: RichFaces 4 validation, stuff disappears
m1ckey Apr 3, 2011 8:03 PM (in response to m1ckey)Sorry for my third response in a row, but I tried this and it displays the status message for the wrong field (the first one, and not the second one)!
<h:panelGrid columns="3"> <h:outputText value="Email:" /> <h:inputText id="email" value="#{registration.email}"> <rich:validator /> </h:inputText> <rich:message for="email" /> <h:outputText value="Name:" /> <a4j:region id="nameRegion"> <h:inputText id="name" value="#{registration.name}" status="nameStatus"> <rich:validator /> </h:inputText> <a4j:status for="nameRegion" startText="Checking name..." startStyle="background-color: FFA500" /> </a4j:region> <rich:message for="name" /> <a4j:commandButton value="Register" action="#{registration.register}" render="length" /> </h:panelGrid>
I also tried without naming the region - didn't help... Any ideas? Thanks!
-
11. Re: RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 4, 2011 7:39 AM (in response to m1ckey)Original problem:
I thought custom validators were not supported yet for client side?
Yes, but that is what I wanted you to use:
<h:inputText value="#{validationBean.name}" id="name">
<rich:validator />
</h:inputText>
and
@Size(min=3, max=12)
@UniqueName
private String name = null;
where @UniqueName - your custom validator. Then:
- size will be checked by rich:validator on the client side
- if size returned valid - Ajax request will be automatically send by the same rich:validator in order to perform validation for @UniqueName which has no clienty impl.
All that will be done as expected on validation phase and by using only validation stuff and not actions/listeners and so on.
new problems:
1) status now do not attached to regions. (That was actually not a good design in 3.3.x as it doesnt clear why UI indication component are bound to utility limiting processing one). Now you could use at view level(placed outside of all forms without name), form level(in form without name) or referenced:
<a4j:status name="stat">
...
<h:inputText value="#{validationBean.email}" id="email" validatorMessage="bad email">
<rich:validator status="stat"/>
</h:inputText>
...
2) you should realize that status will nto be triggered if there were no ajax requests(if all the validators has proper client implementations - validation will be on the client and status will be never shown). In your case I believe you using Hibernate validator for @email. And it's not available in CSV module currently. We implemented only standard JSR 303 ones and using @Pattern for our demo.
-
12. Re: RichFaces 4 validation, stuff disappears
m1ckey Apr 4, 2011 7:47 AM (in response to ilya_shaikovsky)Hi Ilya, thanks for your reply, once again.
What I want is I want one status per one field that potentially takes a while to validate. It should be placed next to the field, not somewhere above/below. What's my best call?
Cheers.
-
13. Re: RichFaces 4 validation, stuff disappears
ilya_shaikovsky Apr 5, 2011 7:19 AM (in response to m1ckey)As I already written:
1) status now do not attached to regions. (That was actually not a good design in 3.3.x as it doesnt clear why UI indication component are bound to utility limiting processing one). Now you could use at view level(placed outside of all forms without name), form level(in form without name) or referenced:
<a4j:status name="stat">
...
<h:inputText value="#{validationBean.email}" id="email" validatorMessage="bad email">
<rich:validator status="stat"/>
</h:inputText>
...
But it will be shown only when the ajax request called and not in case of pure client side validation(which anyway will not take noticeable time)
-
14. Re: RichFaces 4 validation, stuff disappears
m1ckey Apr 5, 2011 8:25 AM (in response to ilya_shaikovsky)HI Ilya, I replaced id with name on a4j:status and it works as expected now. Thanks!