-
1. Re: general problems with validation errors
ilya_shaikovsky Jul 24, 2009 7:57 AM (in response to hrbaer)learn about a4j:region component and ajaxSingle property of ajax components for processing limitations.
-
2. Re: general problems with validation errors
hrbaer Jul 24, 2009 10:26 AM (in response to hrbaer)"ilya_shaikovsky" wrote:
learn about a4j:region component and ajaxSingle property of ajax components for processing limitations.
As far as I understood the a4j:region tag there is no usage in this content. I don't validate the input field by an ajax request but by a normal f:validate tag?! -
3. Re: general problems with validation errors
alexsmirnov Jul 24, 2009 5:08 PM (in response to hrbaer)To bypass validation and update for a such links you can use 'immediate' attribute for these command components.
-
4. Re: general problems with validation errors
radhesh Jul 26, 2009 6:38 AM (in response to hrbaer)"immediate" maynot be the right solution:
Try this:
Whener you want to disable Validations, add an actionParam to the eventSource with a "disable" flag. Add a PhaseListener, and in the beforePhase of processValidations phase, check for the existence of this flag. If present, iterate through all the children and unplug all the defined validators; but, remember to back them up. Now, let the processValidations Phase complete without any validators. In the afterPhase, you may add all the validators back to EditableValueHolders.
Hope this helps! -
5. Re: general problems with validation errors
hrbaer Jul 29, 2009 6:04 AM (in response to hrbaer)Thanks for this info.
But I'm having a few problems to contain my PhaseListener...
faces-config:<faces-config> <application>...</application> <lifecycle> <phase-listener>my.package.PhaseListener</phase-listener> </lifecycle> </faces-config>
and my phaselistener:package my.package; import javax.faces.context.FacesContext; import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; public class PhaseListener implements javax.faces.event.PhaseListener { public void afterPhase( PhaseEvent event ) { System.out.println( "AFTER - " + event.getPhaseId() ); FacesContext.getCurrentInstance().getExternalContext().log( "AFTER - "+ event.getPhaseId() ); } public void beforePhase( PhaseEvent event ) { System.out.println( "BEFORE - " + event.getPhaseId() ); if( event.getPhaseId().equals( PhaseId.PROCESS_VALIDATIONS ) ){ System.out.println( "Validierung beginnt!" ); } FacesContext.getCurrentInstance().getExternalContext().log( "BEFORE - "+ event.getPhaseId() ); } public PhaseId getPhaseId() { return null; } }
I restartet the server but there is no output. Am I missing some configurations?
And just another question: What did you mean by "adding some actionParam to the eventSource with a 'disable' flag? I'm having a commandButton and as far as I know I cant't use the f:param-Tag for it? And how do I get the information from the bean to the PhaseListener? Do I have add the information to my actionEvent in the manged bean and how can I access this information in my phaselistener??
Sorry, I'm a little bit confused ;( -
6. Re: general problems with validation errors
nbelaevski Jul 29, 2009 8:12 AM (in response to hrbaer)Try:
public PhaseId getPhaseId() { return PhaseId.ANY_PHASE; }
-
7. Re: general problems with validation errors
hrbaer Jul 29, 2009 9:13 AM (in response to hrbaer)@nbelaevski: Thanks - that helps!
"radhesh" wrote:
Whener you want to disable Validations, add an actionParam to the eventSource with a "disable" flag. Add a PhaseListener, and in the beforePhase of processValidations phase, check for the existence of this flag. If present, iterate through all the children and unplug all the defined validators; but, remember to back them up. Now, let the processValidations Phase complete without any validators. In the afterPhase, you may add all the validators back to EditableValueHolders.
Now I'm still having the problem that I can react on the VALIDATION_PROCESS but I don't know how...
In my example there is an input field with an invalid value. If I click one of several links which don't validate this input field I don't know what to do.
F.ex. I added to a link an a4j:actionparam which I can check in the BEFORE_VALIDATION_PROCESS but even if I know I don't want to validate for this request how can I achieve it? How do I iterate through all the children (of what?) and unplug all the defined validators? -
8. Re: general problems with validation errors
nbelaevski Jul 29, 2009 7:20 PM (in response to hrbaer)I'd suggest to let component tree live its own life and think about another solution, such as:
1. Usage of "immediate" attribute
2. Emulate behavior of a4j:region using "rendered" attribute. The idea behind this is the fact that non-rendered components are not processed (together with all their kids). So, you can write something like rendered="#{bean.skipThis}", where value of "bean.skipThis" depends on the current lifecycle phase (this is necessary for 2-4th phases only - components disappearing from the page won't suit our needs) and request parameter. If you go this way, think thoroughly about securing actions from wrong data.
3. Some exotic way, like validating model state by action method itself - no validators in the view, everything in Java code.