Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeFaces' p:wizard validation not working

I have a p:wizard with some tabs. In the first tab, the user selects a value (t:selectOneRadio - I'm using Tomahawk). That's a required value.

If the user doesn't select a value, it won't go to the next tab, but no validation error is displayed. Hm.

If the user has chosen a value, goes to the next tab, goes back to the first tab and chooses a different value, it will behave as if no value was chosen this time. (No validation error either, but the second tab can't be invoked).

And even worse: The user chooses a value in the first tab, goes to the second tab, tries invoke an action from there... a validation message appears; it acts as if no value was chosen in the first tab.

Is there any explanation for this?

UPDATE

The solution suggested in the PrimeFaces forum worked for me. (Adding process="@this" to the commandButton.)

like image 586
geeehhdaa Avatar asked May 30 '11 14:05

geeehhdaa


1 Answers

Another thing you might want to consider..

If you are having trouble with required fields across tabs, you can manually perform your own validations between steps by implementing a flow event in your wizard component.

    public String onFlowProcess(FlowEvent event) {  
    //First perform check to see if the user is attempting to remove the last visitor
    if ("confirm".equals(event.getNewStep()) && (visitors == null || visitors.isEmpty())) {
        log.debug("Validation failed for empty visitors");
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Visit must have at least one visitor.", null);
        FacesContext.getCurrentInstance().addMessage(null, msg);
        return event.getOldStep();
    }

    return event.getNewStep();  
}

And the .xhtml file I declare the flowListener event. Try this and see if the validation messages go away.

<p:wizard showNavBar="true" widgetVar="scheduler" flowListener="#{scheduleVisit.onFlowProcess}" showStepStatus="true">
like image 106
maple_shaft Avatar answered Oct 26 '22 07:10

maple_shaft